(This was asked as a reply to a similar topic but figured I shouldn’t hijack that post.)
I am having a hard time figuring out the math involved in counting moving objects. Obviously X = X + 1. I know how to get the number of objects (blocks) that the Pixy2 sees but I just do not know how to use the block’s tracking index to add to my count of moving golf balls down a track. Many might be in view, (in the frame) at any one time.
As I understand things, as soon as the Pixy sees a new block, (object) it gives it a tracking index number, 0 - 255, that stays with that block (object) until it disappears, m_index. As a new block enters it gets another unique tracking index number which remains until it disappears.
This seems like the way to count multiple moving objects of which several will be in the frame assigned in numBlocks. numBlocks can certainly change and can’t be used to count individual moving objects as far as I can figure.
Not a math wiz here but maybe this is something somewhat easy. Can anyone let me know how to actually do the math to count a moving object in and out of the field of view (frame). I am not asking anyone to do my programming for me, I just need to know how to add new frames (objects) via m_index to get a total count. I’m just not sure what to do. It seems simple and rudimentary but I’m missing something.
Thanks so much!
John
It’s not a simple problem. At any given time you can count the number of objects that fit your description. You will need to create a table of some sort and look at each frame, and for each object that fits the description, you need to look in the table. If the object’s index is already in the table don’t do anything. If the object’s index is not in the table, add it to the table and increment the count. When the count reaches 100 (for example) you’ve seen 100 objects. That’s the basic idea.