1 | initial version |
In order to achieve this in more efficent way, you need to have some kind of tracking enabled in you code. Once you have tracker, tracker will assign id to the detected person and then you can pretty much start a timer and keep counting against that person id. This way you also dont need to call your detection in each frame and you can improve some FPS.
Here, have a look at this, although its in C++ but you might get some basic idea: https://www.youtube.com/watch?v=VZjay4fVgCo