While(True) causing infinite loop in screencapture.py
cyrusParvereshi opened this issue · comments
Hi! I've just started the tutorial series and it seems that the screen_record() function in the first video's while(True) loop causes an infinite loop to occur where it keeps opening a viewing window for every frame, instead of just showing the frames all in one window. I'm not sure why this happens. The code is the same as in the tutorial:
`import numpy as np
from PIL import ImageGrab
import cv2
import time
def screen_record():
last_time = time.time()
while(True):
printscreen = np.array(ImageGrab.grab(bbox=(0,60,640,512),include_layered_windows=False, all_screens=False))#needed to get 640x528 resolution
print('loop took {} seconds'.format(time.time()-last_time))
last_time = time.time()
cv2.imshow('window',cv2.cvtColor(printscreen, cv2.COLOR_BGR2RGB))
if cv2.waitKey(25) & 0xFF == ord('q'):
cv2.destroyAllWindows()
screen_record()`
I have the same issue !! I have not find a solution yet.
UP...