Filtering for "Person" Class in detection.py Script

Hello,

I am using the detection.py script from Hailo’s GStreamer-based Python examples. Currently, when the script runs, it detects all objects recognized by the model (car, bicycle, person, etc.) and draws a bounding box around each of them.

My goal is to modify this script to detect only the ‘person’ class and to draw bounding boxes exclusively for people in the video output. How can I make this modification in the app_callback function within the detection.py file? What is the best practice for filtering the detections to draw bounding boxes only for the ‘person’ class after receiving all of them?

Thank you in advance for any guidance or code examples you can provide.

Hey mate I had the same headache…

if you run the script with --use-frame option another screen with only the ‘person’ being boxed will appear

Hi,

Thanks for the suggestion. I tried your method using the --use-frame argument and calling cv2.imshow() from the callback.

Unfortunately, when I ran it, the application froze completely and didn’t display any video. It seems that approach isn’t stable on my system.

Do you happen to have any other ideas?

Hi @Dogan_Onder

I can suggest an alternative that may help in your use case. At DeGirum (a SW partner of Hailo), we built PySDK, a python package to make development easy with Hailo devices. You can find the code to achieve what you want here: hailo_examples/examples/008_object_detection_class_filtering.ipynb at main · DeGirum/hailo_examples

1 Like