Guest User

Untitled

a guest
Aug 26th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. '''
  2. Simply display the contents of the webcam with optional mirroring using OpenCV
  3. via the new Pythonic cv2 interface. Press <esc> to quit.
  4. '''
  5.  
  6. import cv2
  7.  
  8. def show_webcam(mirror=False):
  9. cam = cv2.VideoCapture(0)
  10. while True:
  11. ret_val, img = cam.read()
  12. if mirror:
  13. img = cv2.flip(img, 1)
  14. cv2.imshow('my webcam', img)
  15. if cv2.waitKey(1) == 27:
  16. break # esc to quit
  17. cv2.destroyAllWindows()
  18.  
  19. def main():
  20. show_webcam(mirror=True)
  21.  
  22. if __name__ == '__main__':
  23. main()
Add Comment
Please, Sign In to add comment