Advertisement
Guest User

opencv init

a guest
Dec 10th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. import cv2
  2.  
  3. cv2.namedWindow("preview")
  4. capture = cv2.VideoCapture(0)
  5.  
  6. if capture.isOpened(): # try to get the first frame
  7. rval, frame = capture.read()
  8. else:
  9. rval = False
  10.  
  11. while rval:
  12. # update graph
  13.  
  14. cv2.imshow("preview", frame) # display image
  15. rval, frame = capture.read() # get next image
  16.  
  17. key = cv2.waitKey(20)
  18. if key == 27: # exit on ESC
  19. break
  20. cv2.destroyWindow("preview")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement