YOLOv8 Object Counting Class by Class in Real-Time

Hello all, I ran the sample program that counts objects in real-time with YOLOv8 successfully thanks to the video with the thumbnail below, and I applied it to my vehicles detection project, but I want to count objects class by class, which means the result displayed includes the amount of each vehicle type such as 8 cars, 10 motorbikes, 5 trucks, 2 buses… . Could anyone help me, please?
image

Hi @Nhân_Dương_Sĩ

That would involve processing the inference results by writing code, which we don’t help with on the Roboflow forum. I recommend searching online for other coding resources.

Hi @leo ,
Thank you for your reply, I’d like to know whether Supervision can help me in this case. Thank you!

Hi @Nhân_Dương_Sĩ

I don’t believe Supervision has a feature to count the number of times a class appears in a single detection. We have resources on counting in zones, like polygon zones or crossing lines, but I think counting classes might be a more straightforward process.

Hi @leo , I’m sorry for my late reply. When I analyzed the code in the counting object program, I noticed the 2 methods contributing to the result are ‘trigger’ from the PolygonZone class and ‘annotate’ from the PolygonZoneAnnotator class, and I realized that the definition of the ‘trigger’ method includes the Detections class that we can get class ids from to process each object class. In conclusion, I think that Supervision has no methods that can directly help me in this case, but I probably can add some code lines to do it. What do you think about this? Thank you.

Hi @Nhân_Dương_Sĩ

Yes, that would work. Alternatively, if you wanted to filter the classes themselves, you could also do that in supervision.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.