擅长:python、mysql、java
<p>关于我的评论,下面是一个在磁盘上显示视频流的示例(请参见<a href="http://docs.opencv.org/modules/highgui/doc/reading_and_writing_images_and_video.html?highlight=videowriter" rel="nofollow">documentation</a>):</p>
<pre><code>import numpy as np
import cv2
video = "../videos/short.avi"
video_capture = cv2.VideoCapture(video)
while(True):
# Capture frame-by-frame
ret, frame = video_capture.read()
# Our operations on the frame comes here
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
# Display the resulting frame
cv2.imshow('frame',gray)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# When everything's done, release the capture
video_capture.release()
cv2.destroyAllWindows()
</code></pre>