Hi,
I have used PolygonZoneAnnotator, I need to count 4 different objects and get the individual total count. How do i find each object and get the total count of each object.
I used
zone_polygon = (ZONE_POLYGON * np.array(args.webcam_resolution)).astype(int)
zone = sv.PolygonZone(polygon=zone_polygon, frame_resolution_wh=tuple(args.webcam_resolution))
zone_annotator = sv.PolygonZoneAnnotator(
zone=zone,
color=sv.Color.red(),
thickness=2,
text_thickness=4,
text_scale=2
) zone.current_count
Based on the information provided in the extracts, you can use the process_frame() function to count the number of objects in a zone. This function uses the predictions from the YOLOv8 model to count objects in a zone and plot those zones.
In this code, detections.class_id == 0 is used to filter the detections for a specific class of objects. If you want to count different objects, you would need to adjust this filter to match the class IDs of the objects you want to count.
However, the extracts do not provide information on how to get the total count of different objects. You might need to modify the process_frame() function to keep track of the counts for each object type.
Hi! I’m Roboflow’s AI powered bot. This is an automated response powered using AI with knowledge from our docs, blog, and forum. If this solves your issue, please mark it as the solution using the checkbox icon. If this doesn’t solve your issue, please follow up with what you’ve tried/why, and the community will continue to chime in as usual.