AlexeyAB / darknet

YOLOv4 / Scaled-YOLOv4 / YOLO - Neural Networks for Object Detection (Windows and Linux version of Darknet )
http://pjreddie.com/darknet/
Other
21.6k stars 7.95k forks source link

Tracking and counting individual objects #1849

Open samuel-cox opened 5 years ago

samuel-cox commented 5 years ago

I'm aiming to document a live stream feed from my webcam, using Darknet to detect objects then output using -ext_output. All works great.

However, i'm looking to count the amount of times an object is in the scene. I.E - if i'm showing a busy road, I want to know how many times a bus, a car, a person etc enters the image.

As it stands, -ext_output constantly streams what's in each frame, not a count. Is there any functionality that enables such logging?

Thanks in advance

PeterQuinn925 commented 5 years ago

No, but you can call it from another program that does the counting.

samuel-cox commented 5 years ago

@PeterQuinn925 yes, that's my fall-back. Only issue with this method is that one bus might be in frame for 5 seconds (running at 25fps thats 125 counts of one bus), where I need to print out as one until it's existed the frame.

So my question then falls to... is there any way of using -ext_output to only trigger once per object detected, until that object has left the frame? Bearing in mind that there could be several other objects also in the scene at any one moment in time, that also need logging.

PeterQuinn925 commented 5 years ago

How is it supposed to know it's the same bus? Each frame is detected independently. You'll need your program too figure out if it's the same object or not and to count it as a new one or not. There's probably some OpenCV functions that can help. Or, something as simple as if consecutive frames have the same class of object, it's probably the same object might work well enough.