1import numpy as np
2import cv2
3cap = cv2.VideoCapture('videos/wa.avi')
4while(cap.isOpened()):
5 ret, frame = cap.read()
6 gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
7 cv2.imshow('frame',gray)
8 if cv2.waitKey(1) & 0xFF == ord('q'):
9 break
10
11cap.release()
12cv2.destroyAllWindows()
1import cv2
2frameWidth = 640
3frameHeight = 480
4cap = cv2.VideoCapture("Resources/test_ video.mp4")
5while True:
6 success, img = cap.read()
7 img = cv2.resize(img, (frameWidth, frameHeight))
8 cv2.imshow("Result", img)
9 if cv2.waitKey(1) and 0xFF == ord('q'):
10 break
11
1import cv2
2filename_video = "path_to_your_video"
3
4input_video = cv2.VideoCapture(filename_video)
5if input_video.isOpened() == False:
6 print("Video not found")
7 sys.exit(1)
8else:
9 # Read until the video is completed
10 while(input_video.isOpened()):
11 # Capture frame by frame
12 ret, frame = input_video.read()
13 if ret == True:
14 frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
15 cv2.imshow('frame',frame)
16 else:
17 break
18
19 input_video.release()
20 cv2.destroyAllWindows()