<< return to Pixycam.com

Using as a mouse

Good morning, I am in the beginning stages of researching pixy 2. It was suggested I look into this for a project where I want the camera to track an object and use that as a mouse pointer on the screen.

Essentially, I need a device very similar to a mouse (without the click function). For example, use a red ball to roll around the desk and have the mouse cursor move with it.

I can use a wireless mouse because rotation of the mouse obviously messes with the movement on screen.

Am I looking at the right device in using the pixy 2? Any input would be appreciated

Thanks

Hi, Pixy2 would probably be a good candidate for what you’re describing. It’s designed to track colored objects that you teach it, and report the X-Y coordinates and area (size) of the objects. The resolution is only 320x240 so take that into account — if you’re needing finer movements, then you may want to look elsewhere.

Hope this helps!

Cheers,
Jesse

The remaining piece to solve would be how to translate data (numbers) into mouse movements using the Arduino IDE. It looks like there is an existing library to help with this: https://www.arduino.cc/reference/en/language/functions/usb/mouse/

Getting there, in arduino, how do I assign “(pixy.ccc.blocks[i].m_x)” as a variable?

I’d like to seperate x and y

Ok, did some reading, separated x and y in the arduino software, its coming along,

Using a mouse is still proving difficult as most libraries for arduino are not absolute, they are relative to its current position

Not sure if this library still works, but you might have a go with MouseTo: https://github.com/per1234/MouseTo

Hope this helps!

Cheers,
Jesse

Thanks, that does help. I did find that when the light source varies or the camera is not 90 degrees to the object that things have inconsistent results.

Would illuminating the object with a diffused LED light work? Making it more visual in all conditions?

Hello,
Lighting is often challenging. If the object is somewhat reflective, the angle of the object can really affect its measured hue. Additionally, point-source lighting can be a headache. The more diffuse the light – that is, light coming from more directions, which can also mean lights that are larger (physically) can help.

Edward