Created
April 9, 2017 01:29
-
-
Save d0p3t/d4ac90bdb8e1894b5e195169591b6ea1 to your computer and use it in GitHub Desktop.
Video capture using OpenCV if you wanna try it. Works on my mac
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import cv2 | |
from PIL import ImageGrab | |
fourcc = cv2.cv.CV_FOURCC(*'XVID') # or cv2.VideoWriter_fourcc('X','V','I','D') if you use opencv 3.0 | |
vid = cv2.VideoWriter('record.avi', fourcc, 8, (500,490)) | |
while(True): | |
img = ImageGrab.grab(bbox=(100, 10, 600, 500)) #x, y, w, h | |
img_np = np.array(img) | |
#frame = cv2.cvtColor(img_np, cv2.COLOR_BGR2GRAY) | |
vid.write(img_np) | |
cv2.imshow("frame", img_np) | |
key = cv2.waitKey(1) | |
if key == 27: | |
break | |
vid.release() | |
cv2.destroyAllWindows() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment