google-coral / examples-camera

Small code snippets that show how to stream camera images to a Coral device.
Apache License 2.0
357 stars 115 forks source link

[SOLVED] Raspberry PI 4 64 Bit OS Raspbian Bullseye or Bookworm, Coral USB accelerator, classify_capture.py #112

Open zoldaten opened 4 months ago

zoldaten commented 4 months ago

Description

i got it working just want to share.

Click to expand! ### Issue Type Others ### Operating System Linux ### Coral Device USB Accelerator ### Other Devices Rapsberry Pi 4 ### Programming Language Python 3.9 ### Relevant Log Output ```shell 1. usb coral need python 3.9. it doesnt support 3.11 which is native for Raspbian Bookworm. one way - install python 3.9 with pyenv. 2. install coral packages inside python 3.9 see https://github.com/google-coral/pycoral/issues/140 Download pycoral-2.0.0-cp39-cp39-linux_aarch64.whl and tflite_runtime-2.5.0.post1-cp39-cp39-linux_aarch64.whl from https://github.com/google-coral/pycoral/releases/tag/v2.0.0 pip install ./pycoral-2.0.0-cp39-cp39-linux_aarch64.whl pip install ./tflite_runtime-2.5.0.post1-cp39-cp39-linux_aarch64.whl 3. picamera2 will not work cause of lack libcamera. so the fast way - use gstreamer and build libcamera. https://wiki.veye.cc/index.php/V4L2_mode_for_Raspberry_Pi#Source_code_cross_compilation - gstreamer https://libcamera.org/getting-started.html 4. install mediamtx or other rtsp-server. https://github.com/bluenviron/mediamtx?tab=readme-ov-file#standalone-binary - just download binary for raspberry. and change it settings (this video shows how). 5. start rtsp stream: gst-launch-1.0 libcamerasrc ! "video/x-raw, format=(string)UYVY, width=(int)640, height=(int)480,framerate=30/1" ! videoscale ! videoconvert ! x264enc tune=zerolatency bitrate=500 speed-preset=superfast ! rtspclientsink location=rtsp://localhost:8554/mystream start mediamtx: ./mediamtx start classify from coral examples (python 3.9): python classify.py video - https://youtu.be/EA7_2qL3Iho ```
zoldaten commented 4 months ago

also see with picamera2 - https://github.com/zoldaten/google_coral_usb_picamera2