I’m trying to capture frames of all or portion of the screen with Python. I reviewed the previous questions asked in the stackoverflow. When I run the code below on my computer, I get this error. How can I solve this?
Python version 3.8.0
mss version : 2.0.22
Python version 3.8.0
mss version : 2.0.22
import time import cv2 import numpy as np from mss import mss mon = {'top': 160, 'left': 160, 'width': 200, 'height': 200} with mss() as sct: # mon = sct.monitors[0] while True: last_time = time.time() img = sct.grab(mon) print('fps: {0}'.format(1 / (time.time()-last_time))) cv2.imw('test', np.array(img)) if cv2.waitKey(25) & 0xFF == ord('q'): cv2.destroyAllWindows() breakERROR:
Error:img = sct.grab(mon)
AttributeError: 'MSS' object has no attribute 'grab'
buran write Jan-27-2022, 12:19 PM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.