Teach Pixy an object

Version 8 (Rich LeGrand, 02/18/2014 11:52 am)

1 7 Rich LeGrand
2 7 Rich LeGrand
3 5 Rich LeGrand
h1. Teach Pixy an Object
4 2 Rich LeGrand
5 8 Rich LeGrand
h3. test
6 8 Rich LeGrand
7 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 
8 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
9 2 Rich LeGrand
they have good, distrinct hues.
10 2 Rich LeGrand
11 2 Rich LeGrand
12 2 Rich LeGrand
13 2 Rich LeGrand
14 2 Rich LeGrand
Here are some bad objects because either there is no hue (black, white or gray) or the hue is not distinct.  
15 2 Rich LeGrand
16 2 Rich LeGrand
17 2 Rich LeGrand
18 2 Rich LeGrand
19 2 Rich LeGrand
20 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 
21 4 Rich LeGrand
button on top of Pixy.  After about 1.5 seconds, the LED will turn on, first white, then red, 
22 4 Rich LeGrand
(then other colors), but when it turns red, release the button.  
23 4 Rich LeGrand
24 4 Rich LeGrand
When you release the button, Pixy will enter what's called 
25 4 Rich LeGrand
"light pipe" mode, where the LED color is the color of the center pixels of Pixy's image frame.  
26 4 Rich LeGrand
27 4 Rich LeGrand
** quick video
28 4 Rich LeGrand
29 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 
30 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      
31 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
32 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 **.
33 5 Rich LeGrand
34 5 Rich LeGrand
h2. Multiple Signatures
35 5 Rich LeGrand
36 6 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.  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. Here are the signatures in order:
37 5 Rich LeGrand
38 5 Rich LeGrand
# Red
39 5 Rich LeGrand
# Orange
40 5 Rich LeGrand
# Yellow
41 5 Rich LeGrand
# Green
42 5 Rich LeGrand
# Cyan (light blue)
43 5 Rich LeGrand
# Blue
44 5 Rich LeGrand
# Violet
45 5 Rich LeGrand
46 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 
47 5 Rich LeGrand
indicated by an orange LED.  
48 5 Rich LeGrand
49 5 Rich LeGrand
50 5 Rich LeGrand
h2. Other Notes on Teaching
51 5 Rich LeGrand
52 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! 
53 5 Rich LeGrand
54 6 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.  You can then start over.  
55 5 Rich LeGrand
56 6 Rich LeGrand
57 1 Rich LeGrand
h2. White Balance
58 1 Rich LeGrand
59 6 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 signatures will likely no longer work as well.  You can either re-teach all signatures or you can adjust the white balance.
60 1 Rich LeGrand
61 6 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). The LED will flash, indicating success, and you're done.   
62 6 Rich LeGrand
63 6 Rich LeGrand
h2. Teach Through PixyMon
64 6 Rich LeGrand
65 6 Rich LeGrand
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.  
66 6 Rich LeGrand
67 6 Rich LeGrand
Begin by plugging in the USB cable between Pixy and your computer and running PixyMon.  When PixyMon comes up click on the raw icon.
68 6 Rich LeGrand
69 6 Rich LeGrand
70 6 Rich LeGrand
71 6 Rich LeGrand
Now hold the object you want to teach in front of Pixy and select Action->Set signature 1... from the pulldown menu.
72 6 Rich LeGrand
73 6 Rich LeGrand
74 6 Rich LeGrand
75 6 Rich LeGrand
Now select you region you want Pixy to use to learn the object.  
76 6 Rich LeGrand
77 6 Rich LeGrand
78 6 Rich LeGrand
79 6 Rich LeGrand
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.  
80 6 Rich LeGrand
81 6 Rich LeGrand
82 5 Rich LeGrand
83 5 Rich LeGrand
84 5 Rich LeGrand
85 5 Rich LeGrand