<< return to Pixycam.com

Device to determine whether a colored object is moving

Hi all. I’m trying to build a widget out of a Pixy and an Arduino Uno that will look at a group of colored objects and determine whether any one of them is moving in the Pixy field of view, and switch a digital output on the Arduino based on the result. I’m not much of a coder, so I’d appreciate your good advice. I imagine the program will do the following:

  1. Track objects of one color, with let’s say two to five objects being tracked at a given time. 2. At some time interval, write the x,y of object1. 3. At the next interval get the new object1 x,y. 4. Do math on the new and old coordinates to see if object1 is moving in the Pixy image frame. 5. Change the digital output based on the recent results; for example if the last three coordinate differences are below some minimum, the controller switches the outputs, and switches back when the differences grow above the minimum.

It looks like all this is possible; I’ll get to work now, and post up what I come up with.

Cheers

Hello Brock,
Sounds like a cool idea. Your logic sounds good. One problem you might run into is the “correspondence” problem". (It’s what we call it at least.) Pixy returns the objects it detects in each frame. It doesn’t tell you that object A in the previous frame is the same object as one of the objects in the current frame. If there is one detected object in the current and previous frames, the problem is trivial, but with more than 1 object in either frame, determining which detected object in one frame corresponds to the same detected object in the next frame is sometimes difficult, depending on how fast the objects are moving. If the objects are moving slowly, it’s fairly easy to solve the problem though by writing some simple logic in your code. (I’m just guessing though. I’ve never tried this!)

Hope this helps!

Edward

Thanks for your encouraging words, Edward. I have been thinking about the ‘correspondence’ problem in my application; we’re trying to determine whether a large Alexander Calder mobile is moving or not. I’m not sure if you saw the picture, but there’s a set of red plates at the lower level of the sculpture, and the largest is somewhat constrained in its arc and rate of motion. We would like to keep the thing spinning merrily at let’s say 5-10 revolutions per hour. I think, based on playing around with our Pixy, that there will be some persistence of identity for the objects reported by the software, and I’m hoping if we adjust the frame carefully, we’ll be OK just tracking ‘object1’. It would be OK if we made a mistake from time to time, as long as the rate of error was low enough to produce a generally useful result.

Hi Brock,
Cool – I think the fact that the object isn’t moving too fast will make the correspondence problem much easier.

Edward