Teach Pixy an object

Version 5 (Rich LeGrand, 02/18/2014 10:20 am)

1 5 Rich LeGrand
h1. Teach Pixy an Object
2 2 Rich LeGrand
3 2 Rich LeGrand
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 
4 3 Rich LeGrand
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
5 2 Rich LeGrand
they have good, distrinct hues.
6 2 Rich LeGrand
7 2 Rich LeGrand
8 2 Rich LeGrand
9 2 Rich LeGrand
10 2 Rich LeGrand
Here are some bad objects because either there is no hue (black, white or gray) or the hue is not distinct.  
11 2 Rich LeGrand
12 2 Rich LeGrand
13 2 Rich LeGrand
14 2 Rich LeGrand
15 2 Rich LeGrand
16 4 Rich LeGrand
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 
17 4 Rich LeGrand
button on top of Pixy.  After about 1.5 seconds, the LED will turn on, first white, then red, 
18 4 Rich LeGrand
(then other colors), but when it turns red, release the button.  
19 4 Rich LeGrand
20 4 Rich LeGrand
When you release the button, Pixy will enter what's called 
21 4 Rich LeGrand
"light pipe" mode, where the LED color is the color of the center pixels of Pixy's image frame.  
22 4 Rich LeGrand
23 4 Rich LeGrand
** quick video
24 4 Rich LeGrand
25 1 Rich LeGrand
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 
26 5 Rich LeGrand
matches your object color) press and release the button, like you'd click your mouse.  If Pixy determines that the hue of      
27 5 Rich LeGrand
your object is "good enough" (has enough color saturation), the LED will flash and you're done.  Pixy has now "learned" your object
28 5 Rich LeGrand
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 **.
29 5 Rich LeGrand
30 5 Rich LeGrand
h2. Multiple Signatures
31 5 Rich LeGrand
32 5 Rich LeGrand
Pixy can learn up to seven color signatures. In the section above, 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:
33 5 Rich LeGrand
34 5 Rich LeGrand
# Red
35 5 Rich LeGrand
# Orange
36 5 Rich LeGrand
# Yellow
37 5 Rich LeGrand
# Green
38 5 Rich LeGrand
# Cyan (light blue)
39 5 Rich LeGrand
# Blue
40 5 Rich LeGrand
# Violet
41 5 Rich LeGrand
42 5 Rich LeGrand
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 
43 5 Rich LeGrand
indicated by an orange LED.  
44 5 Rich LeGrand
45 5 Rich LeGrand
46 5 Rich LeGrand
h2. Other Notes on Teaching
47 5 Rich LeGrand
48 5 Rich LeGrand
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! 
49 5 Rich LeGrand
50 5 Rich LeGrand
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. 
51 5 Rich LeGrand
52 5 Rich LeGrand
h2. White Balance
53 5 Rich LeGrand
54 5 Rich LeGrand
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 signature will likely no longer work as well.  You can either re-teach all signatures or you can adjust the white balance.
55 5 Rich LeGrand
56 5 Rich LeGrand
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) and you're done.   
57 5 Rich LeGrand
58 5 Rich LeGrand
59 5 Rich LeGrand
60 5 Rich LeGrand