Skip to content

How to add callback to LineZone? #321

Answered by SkalskiP
AlainPilon asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @AlainPilon 👋🏻 Sorry for the late response. I was AFK for the past few days. We have callbacks on our list of features with high priority. But it will probably take us 1-2 releases to get there.

For now, you'll need to write some custom code to enable that.

import supervision as sv

byte_tracker = sv.ByteTrack()
line_zone = sv.LineZone(start=LINE_START, end=LINE_END)

for frame in sv.get_video_frames_generator(source_path='source_video.mp4'):
    results = model(frame)[0]
    detections = sv.Detections.from_ultralytics(results)
    detections = byte_tracker.update_with_detections(detections)
    
    previous_in_count = line_zone.in_count
    previous_out_count = line_zone.out_count

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by SkalskiP
Comment options

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
Q&A
Labels
question Further information is requested api: linezone LineZone API
2 participants