|
1 |
pip install opencv-python==4.6.0.66 |
Then the following code will allow you to grab a frame and show a frame in a window. Looking this sequence creates a live video preview on your Raspberry Pi Screen.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# ==================================================================== # DISCLAIMER: # This code is provided as-is for educational and experimental # purposes only. The author makes no representations or warranties of # any kind concerning the safety, suitability, or accuracy of this # code. Use at your own risk. The author assumes no liability for any # damages, system failures, security breaches, or network issues # resulting from the use or implementation of this script. # ==================================================================== import cv2 from picamera2 import Picamera2 picam2 = Picamera2() picam2.preview_configuration.main.size = (1280,720) picam2.preview_configuration.main.format = "RGB888" picam2.preview_configuration.align() picam2.configure("preview") picam2.start() while True: im= picam2.capture_array() cv2.imshow("Camera", im) if cv2.waitKey(1)==ord('q'): break cv2.destroyAllWindows() |