[How to save only a part of a long video using OpenCV] I made a script to take a capture wherever I like for a sample image of image processing from a 1-minute video acquired at (https://qiita.com/satsukiya/items/9647e20c4e27b3d0362a): laughing:
Display the View and press the s [save] button on your keyboard to save the capture.
import cv2
if __name__ == '__main__':
cap = cv2.VideoCapture('one_minutes.mp4')
window_name = "Drop Out NHK"
save_press_count = 1
while True:
presskey = cv2.waitKey(1)
if not cap.isOpened():
break
ret, frame = cap.read()
if presskey == ord('q'):
break
elif presskey == ord('s'):
cv2.imwrite("capture_{}.png ".format(save_press_count), frame)
#Save the image just by pressing the capture button
save_press_count += 1
cv2.imshow(window_name,frame)
cap.release()
cv2.destroyWindow(window_name)
I just remembered the code in OpenCV 2 Programming Book and rewrote it to C ++-> Python. I just wanted multiple images for processing.
-Capture opencv-cookbook camera image
Recommended Posts