insect-detect
insect-detect copied to clipboard
OAK camera preview script not working
Hello!
I'm trying to run the OAK camera preview script : https://maxsitt.github.io/insect-detect-docs/software/programming/
and I'm running into an issue :
pi@camtrap1:~/insect-detect $ python3 cam_preview.py
Unable to init server: Could not connect: Connection refused
Traceback (most recent call last):
File "/home/pi/insect-detect/cam_preview.py", line 98, in
Does anyone have an idea on how to make this work ? Thanks :)
Hi @Trematod !
The Can't initialize GTK backend in function 'cvInitSystem' is most often caused by a missing step in the X11 forwarding setup. It indicates that OpenCV is not able to create a window to show the frames with cv2.imshow().
Please make sure that you have followed all steps under SSH connection and X11 forwarding, especially setting the DISPLAY environment variable and rebooting your PC afterwards. You also need an active VcXsrv X server by starting the XLaunch.exe application. Please make sure to use the -Y flag when connecting to your Raspberry Pi via ssh to enable trusted X11 forwarding.
I hope this helps, let me know if you have any further questions!
It's working thanks!
Hi I have this error:
pi@insdet-cam01:~ $ python3 insect-detect/yolo_preview.py
Traceback (most recent call last):
File "/home/pi/insect-detect/yolo_preview.py", line 34, in
Hi @NicolaF899 ,
with the updated instructions that now use RPi OS Bookworm, you installed all required packages in a virtual environment. You will have to use the Python interpreter from this virtual environment to run the scripts, e.g. with:
env_insdet/bin/python3 insect-detect/cam_preview.py
This was not updated yet in the Programming section. There are more major updates coming soon, after that I will update the whole Programming section on the documentation website as well.
However, I would recommend to use the new webapp.py script for optimized frame streaming and showing of the detection model + object tracker output. The opencv-based preview scripts will be deprecated soon.
Start the web app by running:
env_insdet/bin/python3 insect-detect/webapp.py
And open the link that is printed in the terminal (should be http://insdet-cam01:5000/).
Best, Max
Hi, "It works with the web app, but now I've changed the camera (still the same one), and I'm getting this error — do you have any suggestions?"
Hi @NicolaF899,
it seems like you are using the latest web app version but still an older config version without the https setting. Can you check if the https setting is included in your config file and use the latest version if not?