You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

test.py 752B

1234567891011121314151617181920212223242526272829303132
  1. """
  2. This File tests if a camera is connected and working
  3. It should display a live stream in grayscale
  4. """
  5. print("Hallo, Welt!")
  6. import numpy as np
  7. import cv2 as cv
  8. cap = cv.VideoCapture(0)
  9. if not cap.isOpened():
  10. print("Cannot open camera")
  11. exit()
  12. while True:
  13. # Capture frame-by-frame
  14. ret, frame = cap.read()
  15. # if frame is read correctly ret is True
  16. if not ret:
  17. print("Can't receive frame (stream end?). Exiting ...")
  18. break
  19. # Our operations on the frame come here
  20. gray = cv.cvtColor(frame, cv.COLOR_BGR2GRAY)
  21. # Display the resulting frame
  22. cv.imshow('frame', gray)
  23. if cv.waitKey(1) == ord('q'):
  24. break
  25. # When everything done, release the capture
  26. cap.release()
  27. cv.destroyAllWindows()