<< return to Pixycam.com

User Tools

Site Tools


wiki:v2:pixy_lego_block

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
wiki:v2:pixy_lego_block [2019/01/29 18:05]
pixycam
wiki:v2:pixy_lego_block [2020/04/30 22:25] (current)
pixycam
Line 1: Line 1:
- 
- 
- 
- 
 ====== Pixy2 LEGO Block ====== ====== Pixy2 LEGO Block ======
  
Line 15: Line 11:
  
 You can bring up the Pixy2 block from the **Sensor** palette in the EV3 Mindstorms environment:​ You can bring up the Pixy2 block from the **Sensor** palette in the EV3 Mindstorms environment:​
-TODO pic+ 
 +{{wiki:​v1:​image_727.png}} 
  
 ===== Color Connected Components Mode ===== ===== Color Connected Components Mode =====
  
-Selecting ​color connected components ​(CCC) mode is done by clicking on Pixy2'​s mode selector and then selecting **Measure➜Color connected components**. ​  +Pixy2 uses a color-based filtering algorithm to detect objects called the Color Connected Components ​(CCC) algorithm. Color-based filtering methods are popular because they are fast, efficient, and relatively robust. Most of us are familiar with RGB (red, green, and blue) to represent colors. Pixy2 calculates the color (hue) and saturation of each RGB pixel from the image sensor and uses these as the primary filtering parameters. The hue of an object remains largely unchanged with changes in lighting and exposure. Changes in lighting and exposure can have a frustrating effect on color filtering algorithms, causing them to break. Pixy2’s filtering algorithm is robust when it comes to lighting and exposure changes. ​ Additionally,​ Pixy2 uses a connected components algorithm to determine where one object begins and another ends. Pixy2 then compiles the sizes and locations of each object and reports the largest object to your LEGO program. 
-TODO pic+ 
 + 
 +Selecting color connected components ​mode is done by clicking on Pixy2'​s mode selector and then selecting **Measure➜Color connected components**. ​  
 + 
 +{{wiki:​v1:​image_718.png}}
  
  
Line 26: Line 28:
  
  
-The Pixy2 CCC block is shown below, with labels showing the different inputs and outputs:+The Pixy2 CCC block is shown below, with labels showing the different inputs and outputs.
  
-{{wiki:img:2fc7b12b44404f368acc2fb54d38f4d54752b3eb.png}}+{{wiki:v1:image_724.png}}
  
  
 ==== Parameters ==== ==== Parameters ====
  
-  ​**Port Selector**: use this to select the sensor port 1 through 4 that Pixy2 is plugged into on your controller brick. +  ​1. **Port Selector**: use this to select the sensor port 1 through 4 that Pixy2 is plugged into on your controller brick. 
-  ​**Mode Selector**: selects between measure and compare modes. +  ​2. **Mode Selector**: selects between measure and compare modes. 
-  ​- **Lamp**: turns the lamp on or off. +  ​3. **Signature**:​ selects the signature or [[wiki:​v2:​Using_Color_Codes|color code]] you'd like Pixy2 to search for. 
-  - **Signature**:​ selects the signature or [[wiki:​v2:​Using_Color_Codes|color code]] you'd like Pixy2 to search for. +  ​4. **Lamp**: turns the lamp on or off. 
-  ​**Signature Output**: outputs the number of blocks that match the signature or [[wiki:​v2:​Using_Color_Codes|color code]] you specified in the Signature input. Or it outputs the signature number of the detected object if in General Mode (see the description of modes below). +  5. **Signature Output**: outputs the number of blocks that match the signature or [[wiki:​v2:​Using_Color_Codes|color code]] you specified in the Signature input. Or it outputs the signature number of the detected object if in General Mode (see the description of modes below). 
-  ​**X centroid**: outputs the X location of the center of the largest object that Pixy2 has found. The number returned ranges from 0 to 255, with 0 being the rightmost pixel if facing the camera lens. +  ​6. **X centroid**: outputs the X location of the center of the largest object that Pixy2 has found. The number returned ranges from 0 to 255, with 0 being the rightmost pixel if facing the camera lens. 
-  ​**Y centroid**: outputs the Y location of the center of the largest object that Pixy2 found. The number returned is from 0 to 199, with 0 being the topmost pixel. +  ​7. **Y centroid**: outputs the Y location of the center of the largest object that Pixy2 found. The number returned is from 0 to 199, with 0 being the topmost pixel. 
-  ​**Width**: outputs the width of the largest block that Pixy2 has found. The number returned is from 1 to 256. +  ​8. **Width**: outputs the width of the largest block that Pixy2 has found. The number returned is from 1 to 256. 
-  ​**Height**: outputs the height of the largest block that Pixy2 has found. The number returned is from 1 to 256. +  ​9. **Height**: outputs the height of the largest block that Pixy2 has found. The number returned is from 1 to 256. 
-  ​**Angle**: is the angle (in degrees) of the largest object that Pixy2 has found. Angle information is only available for [[wiki:​v2:​Using_Color_Codes|color codes]], otherwise the value is 0.+  ​10. **Angle**: is the angle (in degrees) of the largest object that Pixy2 has found. Angle information is only available for [[wiki:​v2:​Using_Color_Codes|color codes]], otherwise the value is 0.
  
  
Line 67: Line 69:
  
 ===== Line Tracking Mode ===== ===== Line Tracking Mode =====
 +
 +Pixy2 has the ability to detect and track lines. Line-following is a popular robotics demo/​application because it is relatively simple to implement and gives a robot simple navigation abilities. Most line-following robots use discrete photosensors to distinguish between the line and the background. This method can be effective, but it tends to work best with only thick lines, and the sensing is localized making it difficult for the robot to predict the direction of the line or deal with intersections.
 +
 +
 +Pixy2 attempts to solve the more general problem of line-following by using its image (array) sensor. When driving a car, your eyes take in lots of information about the road, the direction of the road (is there a sharp curve coming up?) and if there is an intersection ahead. This information is important! Similarly, each of Pixy2'​s camera frames takes in information about the line being followed, its direction, other lines, and any intersections that these lines may form. Pixy2'​s algorithms take care of the rest. Pixy2 can also read simple barcodes, which can inform your robot what it should do – turn left, turn right, slow down, etc. Pixy2 does all of this at 60 frames-per-second.
 +
  
 Selecting Line Tracking mode is done by clicking on Pixy2'​s mode selector and then selecting **Measure➜Line Tracking**.  ​ Selecting Line Tracking mode is done by clicking on Pixy2'​s mode selector and then selecting **Measure➜Line Tracking**.  ​
-TODO pic+ 
 +{{wiki:​v1:​image_719.png}}
  
  
Line 75: Line 84:
  
  
-The Pixy2 Line Tracking block is shown below, with labels showing the different inputs and outputs. ​ Please refer to the [[wiki:​v2:​line_tracking|Line Tracking Overview]] for a description of the terms used below like _Vector_, _barcode_ and _intersection_:+The Pixy2 Line Tracking block is shown below, with labels showing the different inputs and outputs. ​ Please refer to the [[wiki:​v2:​line_tracking|Line Tracking Overview]] for a description of the terms used below like _Vector_, _barcode_ and _intersection_.
  
-  - **Port Selector**use this to select the sensor port 1 through 4 that Pixy2 is plugged into on your controller brick. +{{wiki:v1:image_711.png}}
-  - **Mode Selector**selects between measure and compare modes. +
-  - **Turn Angle**: sets the turn angle for when intersections are encountered. +
-  - **Reverse**:​ setting this to false to true or true to false will cause Pixy2 to reverse the current Vector. +
-  - **Lamp**: turns the lamp on or off.  +
-  - **Vector**: outputs the X coordinate of the head of the Vector. ​ The value ranges between 0 (far left of the image) to 128 (far right of the image). ​ If no Vector is detected, the value will be -1. +
-  - **Vector Reversed**: outputs true if the Vector is pointing down instead of up.  This usually indicates that your robot needs to reverse its direction to follow the Vector. ​  +
-  - **Barcode**:​ outputs the numerical value of a detected barcode (0 through 15).  If no barcodes are detected, the value will be -1.  If more than one barcode is detected in the image, the value of the barcode closest to the bottom of the image will be returned. ​   +
-  - **Intersection**:​ outputs the number branches in a detected intersection (3 through 6) -- note, a "​T"​ intersection is the minimum number of branches an intersection can have (3).  If no intersection is detected, the value will be -1.+
  
 +
 +==== Parameters ====
 +
 +  1. **Port Selector**: use this to select the sensor port 1 through 4 that Pixy2 is plugged into on your controller brick.
 +  2. **Mode Selector**: selects between measure and compare modes.
 +  3. **Turn Angle**: sets the turn angle (in degrees) for when intersections are encountered. ​ Turn angle values can range between -180 and 180.  See the section on turn angles below.
 +  4. **Reverse**:​ setting this to false to true or true to false will cause Pixy2 to reverse the current Vector.
 +  5. **Lamp**: turns the lamp on or off.
 +  6. **Vector**: outputs the X coordinate of the head of the Vector. ​ The value ranges between 0 (far left of the image) to 128 (far right of 
 +the image). ​ If no Vector is detected, the value will be -1.  Refer [[wiki:​v2:​line_tracking#​detecting-and-tracking-lines|here]] for a description of the Vector.
 +  7. **Vector Reversed**: outputs true if the Vector is pointing down instead of up.  This usually indicates that your robot needs to reverse its direction in order to follow the Vector.
 +  8. **Barcode**:​ outputs the numerical value of a detected barcode (0 through 15).  If no barcodes are detected, the value will be -1.  If more than one barcode is detected in the image, the value of the barcode closest to the bottom of the image will be returned. ​ Refer [[wiki:​v2:​line_tracking#​barcodes|here]] for examples of barcodes, and [[https://​pixycam.com/​downloads-pixy2/​|here]] to download barcode images.
 +  9. **Intersection**:​ outputs the number branches in a detected intersection (3 through 6) -- note, a "​T"​ intersection is the minimum number of branches an intersection can have (3).  If no intersection is detected, the value will be -1.  Refer [[wiki:​v2:​line_tracking#​detecting-intersections-and-branching|here]] for examples of barcodes.
 +
 +
 +==== Turn Angles ====
 +
 +Upon encountering an intersection,​ Pixy2 will find the path (branch) in the intersection that matches the turn angle *most closely* and the Vector will then become that branch. Turn angles are specified in degrees, with 0 being straight ahead, left being 90 and right being -90 (for example), although any valid angle value can be used.  Valid angles are between -180 and 180.  ​
 +
 +
 +For example, if you wanted your robot to always turn left at intersections,​ you could set the Turn Angle to 90.  Or you could set the Turn Angle programmatically,​ based on what your program decides. ​ The Turn Angle is 0 by default, which corresponds to the straightest path upon encountering an intersection. ​
 +
 +
 +[{{wiki:​v2:​image_364.png?​500|Angle coordinates from Pixy2'​s perspective.}}]
  
  
 ===== RGB Sensing Mode ===== ===== RGB Sensing Mode =====
 +
 +
 +We noticed that several Pixy1 users were using Pixy to just sense color values, but using the color connected components algorithm to do so. To make these kinds of color sensing applications easier (we're talking to you, Rubik'​s cube solvers!), we've added the "RGB sensing"​ functionality,​ which allows your LEGO program to retrieve the RGB values of any pixel in Pixy2'​s image.
 +
 +
 +Selecting RGB sensing mode is done by clicking on Pixy2'​s mode selector and then selecting **Measure➜RGB Sensing**.  ​
 +
 +{{wiki:​v1:​image_722.png}}
 +
 +
 +Refer to the [[wiki:​v2:​LEGO_RGB_sensing_test|LEGO RGB Sensing Test]], which describes how to run a simple RGB sensing demo.
 +
 +
 +The Pixy2 RGB sensing is shown below, with labels showing the different inputs and outputs.
 +
 +{{wiki:​v2:​image_894.png}}
 +
 +
 +==== Parameters ====
 +
 +  1. **Port Selector**: use this to select the sensor port 1 through 4 that Pixy2 is plugged into on your controller brick.
 +  2. **Mode Selector**: selects between measure and compare modes.
 +  3. **X**: X location input, can range between 0 and 255 (see coordinate diagram below).
 +  4. **Y**: Y location input, can range between 0 and 255 (see coordinate diagram below).
 +  5. **Lamp**: turns the lamp on or off.
 +  6. **Saturation**:​ if true, Pixy will "​saturate"​ the colors so they are easier to distinguish (reds are redder, blues are bluer, etc.)  If false, the raw RGB values will returned.
 +  7. **Red**: outputs the red value of the pixel at the specified image location. ​ Value can range between 0 to 255.
 +  8. **Green**: outputs the green value of the pixel at the specified image location. ​ Value can range between 0 to 255.
 +  9. **Blue**: outputs the blue value of the pixel at the specified image location. ​ Value can range between 0 to 255.
 +
 +
 +[{{wiki:​v1:​image_716.png|RGB sensing coordinates}}
 +
  
  
wiki/v2/pixy_lego_block.1548785115.txt.gz · Last modified: 2019/01/29 18:05 by pixycam