Raspberry pi ai camera

Hello, does anyone work with Raspberry Pi AI cameras? I am working on a project and am having trouble combining the imx500_object_detection_demo.py with an LED component. I tried combining them using code generated by ChatGPT. I want the LED to turn on when the camera detects a truck. However, the code does not detect trucks.

Hey Jude, welcome to the forums!

I’m just checking, the code was working and detecting trucks before, but now it’s not after trying to implement the LED code? Could you share the code you are trying to run?

We have also made a guide on the AI camera as well and have a simple demo of using object detection with Python at the bottom of the page. We package a lot of the complexity of the camera into a library so you only have to deal with a few lines of code, and its as simple as implementing the line:

      if label == "truck" and confidence > 0.4:
          print("Truck detected")
          # Also turn on the LED.

Let us know!
-Jaryd

Hello Jaryd,
Thank you for your response!
I installed the Raspberry Pi Camera Module 2 on my Raspberry Pi and tested it. I ran the Object Detection script (imx500_object_detection_demo.py), and it works very well, and it detect a truck. Currently, I’m working on designing a system where the camera detects a truck, and an LED turns on automatically. The LED code works perfectly when I run it separately. However, the challenge I’m facing now is how to integrate the two codes and make them work together effectively.

1 Like

Hey @jude291154,

Would you be able to share the working versions of the object detection code and the LED code so we can give you a hand combining them?

If you would like you could also post the chatGPT combined code for us to have a look and see if it can be fixed without to much trouble.

1 Like