Home > other >  Opencv learning if cv2. WaitKey (1)==word (' q ') : break the confusion
Opencv learning if cv2. WaitKey (1)==word (' q ') : break the confusion

Time:09-27

Here is an example of when I was in learning opencv, for if cv2. WaitKey (1)==word (' q ') : break statement is not very understanding, but I type in and out of the loop is, stop updating frames, to solve why do it? I refer to the classic online writing have cv2 waitKey (1)==word (' key ') or if cv2. WaitKey (1) & amp; 0 XFF==word (' q ') : break
 
# to open the camera and grayscale display
The import cv2

The capture=cv2. VideoCapture (0)

While (True) :
# for a frame
Ret, frame=the capture. The read ()
# converts this frame to grayscale
Gray=cv2. CvtColor (frame, cv2 COLOR_BGR2GRAY)

Cv2. Imshow (' frame ', gray)
If cv2. WaitKey (1)==word (' q ') :
Break
  • Related