recently I've been working on a project using the raspberry pi camera OpenCV and Python to count people passing by a specific area, live, since for my usage will be easier than processing a recorded video.
Overall the code works and all, but I've been experiencing a problem with the counting part of it, that:
1 - If an object stays in the reference line, it keeps adding to the counts;
2 - Sometimes depending on the speed of the object, it is counted multiple times;
I am not an expert on python, and may be lacking the words in english to look for the proper solution, so I thought maybe someone could tell me what would be better here to solve this problem. To illustrate, here it is a gif sample:
Even tough it looks like there are more than one reference box crossing the line, it happens when only one box crosses it, as well as when the object stays on the line.
This is the code that checks if the object is crossing the line:
if (TestaInterseccaoEntrada(CoordenadaYCentroContorno,CoordenadaYLinhaEntrada,CoordenadaYLinhaSaida)):
ContadorEntradas += 1
if (TestaInterseccaoSaida(CoordenadaYCentroContorno,CoordenadaYLinhaEntrada,CoordenadaYLinhaSaida)):
ContadorSaidas += 1
I thought of using some kind of delay with time.sleep(x) on the loop, but that does not solve it obviously, and also looks bad =D.
If needed, I may post the rest of the code here, but it's here, to keep things here tidy: Code Paste
Don't mind any bad syntax or errors, part of it is not mine and the part that is, looks terrible! XD
Thanks in advance.
