<< return to Pixycam.com

Counting Moving Objects Revisited

(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

Hello,
I’m not sure what you are asking. Counting objects is easy – you could just return the count that Pixy provides. But the objects you want to count must be moving? Are there other constraints – should they be moving in a straight line? Should they be moving within a certain velocity?

Edward

Edge,

Thank-you so much for the reply. I know that I can get the number that Pixie returns but that is the number of objects it sees at any given moment in time within its view or within its frame as far as I understand thing. That is easy. And I know how to do that.

But, I have the same type/color/shape item coming down a shoot, a lot of them, spaced a bit, not moving real fast, that I need to count. Like a golf ball rolling down a chute and dropping into a bag and I need to count, say100 golf balls then do something when my count gets to 100. (100 is an arbitrary number. We might have 25 golf balls to count then do something, or 50 and etc. I hope you get the point.

Pixy is just not looking at 25 or 100 golf balls and returning the number it sees. These are moving into and out of Pixy’s field of view and we have to count them when they come in and not forget about them when they leave.

I hope this is clearer. And again, thank-you!

John

Hi John,
I understand now. :slight_smile: 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.

Hope this helps!

Edward