Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

latest/detection/tools/line_zone/ #988

giscus[bot] bot started this conversation in Docs
Mar 11, 2024 · 5 comments · 5 replies
Discussion options

latest/detection/tools/line_zone/

A set of easy-to-use utilities that will come in handy in any computer vision project.

https://supervision.roboflow.com/latest/detection/tools/line_zone/

You must be logged in to vote

Replies: 5 comments · 5 replies

Comment options

Does supervision provide a way to retrieve information from each ID that is detected? In my case where a car and a truck are two different objects crossing the line zone in supervision, can I find out the class information of the objects that have passed?

You must be logged in to vote
3 replies
@SkalskiP
Comment options

Hi @dolrie23 👋🏻 Yes! LineZone.trigger method returns a tuple consisting of two boolean numpy arrays. The first array identifies detections that have crossed the line from outside to inside, while the second array identifies detections that have moved from inside to outside.

This allows you to filter out objects that have crossed the line quickly.

crossed_in, crossed_out = line_zone.trigger(dtections=detections)
detections_in = detections[crossed_in]
detections_out = detections[crossed_out]

Then, we can obtain information about the class of the objects we are interested in.

class_id = detections_in.class_id
@dolrie23giscus
Comment options

Thank you for the very quick response, I do appreciate it. I have tried using the code you suggested but it doesn't give me the class information I need every time an object passes by.
I am curious, does the code work for classes that use Yolo-World?

@SkalskiP
Comment options

Hi @dolrie23 👋🏻 Sorry I didn't notice your answer.

I have tried using the code you suggested but it doesn't give me the class information I need every time an object passes by.

What do you mean? What happens?

I am curious, does the code work for classes that use Yolo-World?

It should work with YOLO-World as long as you use inference or ultralytics packages to run it.

Comment options

Hello @SkalskiP, as always your work is astonishing. Do you have any previews in the tutorial related to Filter Objects in zones? Thanks for your contribution to the field

You must be logged in to vote
2 replies
@onuralpszr
Comment options

Please check https://supervision.roboflow.com/latest/how_to/filter_detections/

Also check examples/how tos/cookbooks as well.

@SkalskiP
Comment options

@viniFiedler, thanks a lot! 🙏🏻 Let us know if that resource is enough. Here you can find a slightly more advanced example.

Comment options

What trigger tool is used to count the number of objects(different classes) in the whole video frame.
After I process the video, I want the processed video to have class name with the matching count as it moves through every frame to produce the final video. And I'm using detectron2 for model training.
Below is some starter code I have;

import supervision as sv
video_info = sv.VideoInfo.from_video_path('/content/commuters_in_train.mp4')

# initiate annotators
box_annotator = sv.BoundingBoxAnnotator(thickness=4)

# extract video frame
generator = sv.get_video_frames_generator('/content/commuters_in_train.mp4')
iterator = iter(generator)
frame = next(iterator)

# detect
outputs = predictor(frame)
detections = sv.Detections.from_detectron2(outputs)

# Below is where I want to create the trigger that can count the number of objects in each frame. 
# I need help
You must be logged in to vote
0 replies
Comment options

Hello, I was struggle with with LineZone because it cannot count anything even I've followed its code sample in docstring correctly.
After reading its implementation, I found that we need to specify triggering_anchors to make it works. Here is sample code to declare:

line_zone = LineZone(start=start, end=end, triggering_anchors=[sv.Position.CENTER])
You must be logged in to vote
0 replies
Comment options

Hello @SkalskiP ! Is there a way to edit the LineZoneAnnotatorMulticlass text? For example, instead of "In or Out", i'd like to have "Entering or Leaving Road", followed by the same counting structure. If not, can I create a custom sollution based on the source code in order to incorporate those changes?

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
📚
Docs
Labels
None yet
7 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.