<< return to Pixycam.com

User Tools

Site Tools


wiki:v1:teach_pixy_an_object

Teach Pixy an Object

Teaching Pixy an object is super easy, but first let's talk about which objects will work well with Pixy. Pixy uses a hue-based color filtering algorithm to detect objects. Since Pixy uses hue (color), the object needs to have a distinct hue. Here are some objects that are good because they have good, distinct hues.

d716651b2ab6faadfca267056faddc41ead7d737.jpg
1315dcbf42b4eeb10b885c9b02fc9aa92a16af8f.jpg

Here are some bad objects because either there is no hue (black, white or gray) or the hue is not distinct.

034feffaba6c51c02f9f00059b0f76115bcba317.jpg

Keeping these guidelines in mind, choose an object to teach Pixy. (Apply power to Pixy via battery or USB cable if you haven't already. When you power up Pixy, it will go through a series of LED flashes. Wait for the led to turn off before teaching Pixy.) Hold down the button on top of Pixy. After about 1 second, the LED will turn on, first white, then red, then other colors, but when it turns red, release the button.

When you release the button, Pixy will enter what's called “light pipe” mode, where the LED color is the color of the center pixels of Pixy's image frame.

Use the LED color as feedback to determine if your object is in the center of Pixy's image frame. When you are satisfied that the LED color matches your object color press and release the button, like you'd click your mouse. If Pixy determines that the hue of your object is “good enough” (has enough color saturation), the LED will flash and you're done. Pixy has now “learned” your object and will start tracking objects of the same color. If the hue is not good enough, the LED will simply turn off (no flashing) and Pixy will not have learned your object. If the LED doesn't flash, you might choose another object that has a better color saturation, or consult the Pixy troubleshooting section **.

Multiple Signatures

Pixy can learn up to seven color signatures. In the previous section, we taught Pixy the 1st color signature by releasing the button when the LED turned red. If we had continued to hold down the button, the led would have turned, orange, yellow, etc., indicating the remaining color signatures. Here are the signatures in order:

  • Red
  • Orange
  • Yellow
  • Green
  • Cyan (light blue)
  • Blue
  • Violet

The color signature number is determined by when you release the button. Release the button when the LED is yellow and you're teaching signature 3. Release the button when the LED is blue and you're teaching signature 6. These colors are not at all related to the hue of the object. The colors are used only to indicate the signature number. So, for example, signature 1 can be a yellow object, even though signature 1 is indicated by a red LED, and signature 2 could be a pink object even though signature 2 is
indicated by an orange LED.

Other Notes on Teaching

When you press and release the button to indicate that you're satisfied that the LED color matches your object color, Pixy will flash the LED, and the brightness of the flashing indicates the “goodness” of the hue of the object (how saturated). So bright flashing is good! Try teaching Pixy a fluorescent colored object – Pixy will indicate his (her?) happiness by flashing the LED brightly.

If you accidentally find yourself teaching signature 2 when you meant to teach signature 3, for example, just hold down the button until the LED turns off. This is how you tell Pixy to cancel teach mode. You can then start over by holding the button down again.

White Balance

Some types of lighting (such as incandescent) have a reddish hue and others (such as fluorescent) have a bluish hue. The lighting can affect your color signatures. For example, if you teach an object under incandescent lighting and move into a room with fluorescent lighting, the color signatures will likely no longer work as well. You can either re-teach all signatures or you can adjust the white balance.

When you first apply power to Pixy, it will spend the first 5 or so seconds determining the correct white balance to use. It will then disable automatic white balance. If you wish to readjust the white balance, hold down the button until the LED turns white and release. It happens quickly, so be prepared! Pixy is now in automatic white balance mode. You can hold a white sheet of paper in front of Pixy so Pixy can adjust the white balance. It only takes 2 or 3 seconds to adjust the white balance, after which you can press and release the button (like a mouse click). The LED will flash, indicating success, and you're done.

Teach Through PixyMon

You can also teach Pixy object through PixyMon. This may be useful if the object you want to teach is small or if you want more control over which pixels are used for teaching. Begin by plugging in the USB cable between Pixy and your computer and running PixyMon. When PixyMon comes up click on the raw icon.

3f150b80fec666f9d60ad2a6ca0dd55b7955d510.jpg

Now hold the object you want to teach in front of Pixy and select Action➜Set signature 1 from the pulldown menu.

880f8b36cb5e97207d9b30091a635bcb6ff1b661.jpg

Now select you region you want Pixy to use to learn the object.

c003d75cacd18061b7cc41b96466bc50e721bbda.jpg

If successful, you should see “Success!” message in the command window, followed by a response number between 0 and 100, which is the “goodness” number. Hues with higher saturation will have higher goodness numbers.

That's it! You can verify how well your color signature is working by clicking on the chef icon or selecting Action➜Cooked Video. Cooked video will show which pixels match color signatures and how they form detected objects:

ecd6efef76b4bbdc48191b67ae93c069c61d9e07.jpg

Where to go from here

You can teach Pixy other objects in this way, up to seven total color signatures are possible. Note that Pixy always saves color signatures in flash, so they will be available the next time you apply power to Pixy.

If you haven't already, from here you might be interested in hooking Pixy up to a microcontroller.

wiki/v1/teach_pixy_an_object.txt · Last modified: 2017/12/19 21:33 by jfrench