pip install opencv-python
pip install mss
import time, cv2, mss, numpy
with mss.mss() as sct:
monitor = {'top': 40, 'left': 0, 'width': 800, 'height': 640} # Part of the screen to capture
while True:
last_time = time.time()
img = numpy.array(sct.grab(monitor)) # Get raw pixels from the screen, save it to a Numpy array
cv2.imshow('OpenCV/Numpy normal', img) # Display the picture
print('fps: {0}'.format(1 / (time.time()-last_time)))
# Press "q" to quit
if cv2.waitKey(25) & 0xFF == ord('q'):
cv2.destroyAllWindows()
break
#References
OpenCV https://docs.opencv.org/master/
mss https://pypi.org/project/mss/1.0.2/
https://stackoverflow.com/questions/35097837/capture-video-data-from-screen-in-python
'LANGUAGE > Python' 카테고리의 다른 글
Statistical Visualization or Data Visualization (0) | 2019.08.23 |
---|---|
Python Tutorials (0) | 2019.08.23 |
How to check whether a variable exists or not? (0) | 2019.08.01 |
Send Telegram Message via Telegram Bot (0) | 2019.07.16 |
Reload Module and Function in PyThon (0) | 2019.07.16 |