summaryrefslogtreecommitdiff
path: root/cv/learn_cv/video.py
diff options
context:
space:
mode:
authorzhang <zch921005@126.com>2022-05-21 14:23:49 +0800
committerzhang <zch921005@126.com>2022-05-21 14:23:49 +0800
commit678fab50280b647d95213a9695d07c49542696f2 (patch)
tree74ca60de14311a8a2ff58dbf82d9b7574c9cd3ef /cv/learn_cv/video.py
parent2180c68999eb8dc0c7bcec015b2703f5b8b20223 (diff)
0521
Diffstat (limited to 'cv/learn_cv/video.py')
-rw-r--r--cv/learn_cv/video.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/cv/learn_cv/video.py b/cv/learn_cv/video.py
new file mode 100644
index 0000000..703a2bf
--- /dev/null
+++ b/cv/learn_cv/video.py
@@ -0,0 +1,36 @@
+import numpy as np
+import cv2
+
+
+def load_video(video):
+ cap = cv2.VideoCapture(video)
+ if not cap.isOpened():
+ print("Cannot open camera")
+ exit()
+ print(cap.get(cv2.CAP_PROP_FRAME_WIDTH),
+ cap.get(cv2.CAP_PROP_FRAME_HEIGHT),
+ cap.get(cv2.CAP_PROP_FPS))
+ while True:
+ # Capture frame-by-frame
+ ret, frame = cap.read()
+ # if frame is read correctly ret is True
+ if not ret:
+ print("Can't receive frame (stream end?). Exiting ...")
+ break
+ # Our operations on the frame come here
+ # gray = cv.cvtColor(frame, cv.COLOR_BGR2GRAY)
+ # Display the resulting frame
+ cv2.imshow('frame', frame)
+ print(frame.shape)
+ if cv2.waitKey(1) == ord('q'):
+ break
+ # When everything done, release the capture
+ cap.release()
+ cv2.destroyAllWindows()
+
+
+
+
+if __name__ == '__main__':
+ load_video('../data/vtest.avi')
+