Learn Before
Concept
Live Video Feed Processing
import numpy as np import cv2 cap = cv2.VideoCapture(0) # 0 is default, otherwise specify with a name or index
Too show what is being captured constantly, we can use a while true loop. We use the ret variable to determine if the camera data in stream is being used already or not.
while True: ret, frame = cap.read() cv2.imshow('frame', frame) if cv2.waitKey(1) == ord('q'): break cap.release() cv2.destroyAllWindows()
We are functionally using the image display method and then running it repeatedly to simulate live video. The include of the waitkey method will allow us to terminate the while loop when we press the q button.
0
1
Updated 2021-06-22
Tags
Python Programming Language
Data Science