Skip to content

Instantly share code, notes, and snippets.

@nunenuh
Created July 30, 2018 00:55
Show Gist options
  • Save nunenuh/7fe8d3bcfaa66765ef975ca01838262c to your computer and use it in GitHub Desktop.
Save nunenuh/7fe8d3bcfaa66765ef975ca01838262c to your computer and use it in GitHub Desktop.
opencv webcam record
import numpy as np
import cv2
x1, x2 = 100,400
y1, y2 = 10, 310
cap = cv2.VideoCapture(0)
while(True):
ret, frame = cap.read()
r = cv2.rectangle(frame,(y1,x2),(y2,x1),(0,255,0),3)
crop = frame[x1:x2, y1:y2]
cv2.imshow('frame',r);
cv2.imshow('frame2',crop);
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment