5,323
edits
Line 20: | Line 20: | ||
==Video== | ==Video== | ||
===Reading Video=== | ===Reading Video=== | ||
<syntaxhighlight> | |||
video_capture = cv2.VideoCapture(path.join(videos_folder, video_filename)) | |||
if not video_capture.isOpened(): | |||
print("Error opening video stream or file") | |||
sys.exit(0) | |||
frame_num = 0 | |||
while video_capture.isOpened() and frame_num < 30: | |||
ret, frame = video_capture.read() | |||
if ret: | |||
cv2.imshow('Frame', frame) | |||
frame_num = frame_num + 1 | |||
if cv2.waitKey(25) & 0xFF == ord('q'): | |||
break | |||
else: | |||
break | |||
</syntaxhighlight> | |||
===Writing Video=== | ===Writing Video=== | ||
[https://docs.opencv.org/master/d7/d9e/tutorial_video_write.html C++ Video Write]<br> | [https://docs.opencv.org/master/d7/d9e/tutorial_video_write.html C++ Video Write]<br> |