mobimeo / node-yolo

Node bindings for YOLO/Darknet image recognition library
https://lab.moovel.com/blog/what-you-get-is-what-you-see-nodejs-yolo
MIT License
372 stars 51 forks source link

Adding frame skip to configuration #10

Closed matansag closed 7 years ago

matansag commented 7 years ago

YOLO have the ability to skip frames, "-s" flag, it will be very hopeful if it will be added to node-yolo as well

b-g commented 7 years ago

Hi @matan-insoundz, Interesting! But can you elaborate 2 sentences on what it does exactly / give an usecase example? Cheers!

matansag commented 7 years ago

Sure, in order to getting close to real time streaming i dont want to do the object detection calculation on each frame but only on some percentage of it, that way i can decide on how much of the frame calculation will be executed.

darknet support some kind of this feature ./darknet detector demo cfg/coco.data cfg/yolo.cfg yolo.weights -s 2 from what i understand -s flags controls the number of “skip_frames”, which is the number of consecutive frames that yolo won’t process

b-g commented 7 years ago

Thanks @matan-insoundz ! Sounds very useful! @OrKoN What do you think?

OrKoN commented 7 years ago

@matan-insoundz What will be the best behavior when the -s flag is used: should node-yolo invoke a callback with the raw frame w/o detections or omit skipped frames?

matansag commented 7 years ago

Thanks @b-g ,@OrKoN i think i will love that node-yolo will invoke the callback with the raw frame ( no detection drawn ) this way one could keep use the output stream as complete video

b-g commented 7 years ago

+1

Would then modified and detections be null? (Would be good to be able to easily distinguish between callbacks with and w/o detection results) ...

matansag commented 7 years ago

sound great! detections can be also empty array

OrKoN commented 7 years ago

Hey @matan-insoundz I took a look how it's done in darknet's demo.c and I have done the same thing here: https://github.com/moovel/node-yolo/commit/25784a00b6e039631074f169b99f5c04ffa3bdeb Basically, it defines after how many frames the callback will be invoked. It seems that it actually does not reduce the amount of processed frames - see https://github.com/pjreddie/darknet/blob/master/src/demo.c#L185. Hope this helps.

matansag commented 7 years ago

Hi @OrKoN , i tested it and it work exactly as it work in the darknet's demo.c as you wrote. I agree with you that it didn't reduce the amount of processed frames. that is why my first thought was calling the callback every frame and calling the image-recognition only once a frame. Also thank you for the development of this feature!