I want to replicate the supervision region counting in roboflow workflows. I see that there is a line counting block but I dont see one for region counting. Would love to know if its possible.
Hey there
Indeed you can do region counting using roboflow i would suggest you read this blog
How to Count Objects in a Zone. This should have everything you are looking for!
@Subhranshu_Mohanty is their a way to do it via roboflow workflows?
@twhitehurst3 In the workflows you could add the Polygon Zone Visualization block
this would map out the area which you want. Then you could add various object detection models in the workflow, this should let you do region counting within roboflow workflows.
lemme know if you need anything else!
Thank you for this! Another questions if you dont mind. If I want to count object that come in and out of the zone in a video how would I implement that logic using that block in workflows?
Now for doing that you would have to create a custom python block in the workflows
First use the Polygon Zone Visualization to mark out the area. Then use any object detection and tracker models which are provided in the workflows, after this you would have to create your own custom python block where you would assign a unique id to each object. This would later on detect objects which are entering and which are exiting for which you can maintain a counter based on exits and entrys
here is a small example snippet for your custom python block
Define Polygon Zone (ROI) as a list of (x, y) coordinates
polygon_points = [(200, 300), (500, 300), (500, 600), (200, 600)] # Adjust as needed
polygon = Polygon(polygon_points)
Initialize tracking
object_ids = {} # Store object entry frames
entry_count = 0
exit_count = 0
Function to check if a point is inside the polygon
def is_inside_polygon(x, y):
return polygon.contains(Point(x, y))
Let me know if this helps and if you need anything else!!