Using the Pixy2 you can easily detect objects, track lines, colour codes and barcodes in your Arduino or Raspberry Pi projects. It also works with other microcontrollers, thanks to its SPI, I2C, UART, USB, digital and analogue data outputs.
Pixy2’s integrated processor does all the hard work, and then sends only the important data to your device, such as “Object 1 detected at X: 50, Y: 200”. This frees up your microcontroller’s CPU for other tasks, such as what to actually do with that information. FOLLOW THAT BALL!
Let's explore some of the things you can do with the Pixy2...
Pixy2 uses a hue-based colour filtering algorithm. We had success with objects that were distinctly block-coloured, as they were easy to detect.
Due to the way Pixy operates, it may not work as well with objects with no hue - such as black, white or grey - or if the hue is not very distinct. We also ran into some conflicts with objects similar in colour, although you can adjust the hue’s detection range to be less/more sensitive, which can help avoid some issues. The Pixy2 also has onboard LEDs to help balance lighting in certain situations; a feature that you can opt to switch on or off.
The Pixy2 can learn and remember up to seven colour signatures, which means you can teach it seven objects that have a unique colour. Teaching your Pixy2 an object is a relatively easy and enjoyable task. It is recommended that you first teach your Pixy objects using the software provided, so that you can understand what the Pixy sees, and get a visual sense of how it learns. Software is provided in your OS of choice.
Once you get the hang of teaching your Pixy objects however, it’s very easy to teach your Pixy new objects just by pressing a button on the device, holding an object up to the Pixy, and using the colour LED as feedback - neat! We really liked this feature.
Once you’ve taught your Pixy some objects, you can connect to your favourite microcontroller.
Out of the box, Pixy2 is ready to talk to an Arduino, so we plugged our Pixy into an Arduino UNO using the cable provided, installed the Pixy2 library, and in no time, we were receiving data from our detected objects using the built-in demo.
The creators of Pixy say that it can find hundreds of objects at a time using its connected components algorithm to determine where one object begins and another ends.
Line and Barcode Detection
A new feature is its ability to detect and track lines, which is great for projects where you’d like your robot to follow line paths. You may be thinking “we don’t need a camera for that”, but it’s much more than standard line following.
Sample code and an API is provided, so you can get started right away. The line tracking API can also detect intersecting lines and report back to your device, so that you can program your robot to take specific actions.
Another fun feature is that Pixy2 can also detect and read small barcodes. A potential use could be to place these barcodes alongside the line track, to give instructions to your robot such as “wait 3 seconds” or “turn left”. You can program up to 16 different codes.
Pixy2 also has integrated lights, which can help when following lines, and ensures less consequences in situations of uneven lightning.
NXP LPC4330, 204 MHz, dual core
Aptina MT9M114, 1296×976 resolution with integrated image flow processor
60° horizontal, 40° vertical
Integrated, approximately 20 lumens
The Pixy2 can also detect colour sets (two or more colours next to each other, such as pink and green). This enables you to have your robot manoeuvre around objects with a certain colour code attached, or turn right when you reach a particular code. This provides an opportunity to create more complex “goal-based” navigation behaviour, and can potentially set boundaries such as “do not go here”.
Got World Cup fever? How about building a soccer bot? This is achievable by attaching a unique colour code to each goal post. So now you have everything you need to program your bot to push a ball between the posts - SCORE!
It is also possible to track angles of an object with a colour code attached, which could be interpreted for alignment or positioning functions.
Pixy2 Pan-Tilt Kit
We also had a chance to play with the dedicated pan-tilt kit for Pixy2. With this kit you can easily have your Pixy follow an object so that it doesn’t go out of view.
Assembly was fairly fast and painless. Instructions were clear and easy to follow, with plenty of images to guide you along the way.
Once assembled there are a couple of ways to quickly test this accessory in action. Simply load up the provided software and change to pan-tilt mode. We also found an Arduino pan-tilt demo sketch, so once that was uploaded the camera started to follow the object we had taught the Pixy2 earlier.
The functionality is fast and accurate. Though as noted previously, uneven lighting conditions (such as strong backlighting), can impair the operation of Pixy2 to a degree. If it’s sitting on a desk and a ceiling light is in view, it can cause a little confusion if the integrated Pixy2 LEDs are unable to compensate.
Pixy2 provides many great features to help you create. Here are a few examples but really, you’re only limited as to what you can do, by your own imagination:
- Sorting bots
- Modify our biped robot project from this issue, so the robot will follow a ball rolled across the floor
- Air hockey robot - yes, someone has built one using the Pixy2!
All in all, Pixy2 is a fantastic unit, and opens up another generation of behaviour for autonomous and semi-autonomous vehicles. We’re also giving away a stack of Pixy2 and pan-tilt modules in this issue, so if you want to get your hands on one, be sure to enter!
Teaching your Pixy2 an object is a relatively easy and enjoyable task.
Pixy2 available at Tribotix: http://tribotix.com