1. smart camera [PORT]switch to color block detection mode

Smart Camera - 图1

Switches to the color block detection mode for the smart camera connected to the specified port of mBot

How to Use

A smart camera can work in either the color block detection or line/label tracking mode.

  • In the color block detection mode, a smart camera can detect and track color blocks.
  • In the line/label tracking mode, a smart camera can track lines or barcodes.

Switch the smart camera to the corresponding working mode before using its functions.

Example

When you start mBot, the smart camera connected to port 1 of mBot is switched to the color block detection mode.
Smart Camera - 图2


2. smart camera [PORT] starts learning color block [SIG] until button pressed

Smart Camera - 图3

Makes the smart camera connected to the specified port of mBot start to learn a color block until the Learn button is pressed

How to Use

Steps for learning a color block

  1. After running this block, put the object to be learned above the camera. Observe the recognition indicator while slowly moving the object until the color of the indicator is the same as that of the learned object.
    2. Press the Learn button to record the learned object.
    After an object is successfully learned, the indicator of the smart camera is changed to be in the same color as that of the object when the camera recognizes the object.
    Smart Camera - 图4

    Color block numbers

    Numbers are provided to identify color blocks. A smart camera can learn and record a maximum of seven color blocks.
    Smart Camera - 图5

    Example

    When you start mBot, the smart camera is switched to the color block detection mode and starts to learn and record color block 1.
    Smart Camera - 图6

3. smart camera [PORT]detected color block[SIG]?

Smart Camera - 图7

Determines whether the smart camera connected to the specified port of mBot detects the specified color block

How to Use

This is a Boolean block. If the smart camera detects the specified color block, the block reports True, otherwise it reports False. This block must be used in combination with another block that requires a condition. It can’t be used independently.
Note: Before using the smart camera to detect a color block, you need to use it to learn and record the color block first.

Example

After you start mBot, all the LEDs on it are lit up in red for one second if the smart camera detects the recorded color block 1.
Smart Camera - 图8


4. smart camera [PORT] detected color block [SIG] at[LOCATION] of the image?

Smart Camera - 图9

Determines whether the smart camera detects the specified color block in the specified position of the image

How to Use

The following figure shows the coordinates and areas of an image captured by a smart camera.
Smart Camera - 图10

PixyMon software

You can use the PixyMon software to view images captured by a smart camera.
Click to download PixyMon
After installing the PixyMon software, connect a smart camera to the computer by using a Micro USB cable. Then you can view images captured by the smart camera in PixyMon.

Example

After you start mBot, it turns left if the smart camera detects color block 1 on the left of the captured image.
Smart Camera - 图11


5. smart camera [PORT] detected [CCCINFO] of color block [SIG]

Smart Camera - 图12

Reports the coordinate, width, or height of the specified color block

How to Use

The following figure shows the coordinates of the image captured by a smart camera.
Smart Camera - 图13
X-axis coordinate range: 0–320
Y-axis coordinate range: 0–240

PixyMon software

You can use the PixyMon software to view images captured by a smart camera.
Click to download PixyMon
After installing the PixyMon software, connect a smart camera to the computer by using a Micro USB cable. Then you can view images captured by the smart camera in PixyMon.

Example

After you start mBot, it moves forward for one second if the width of color block 1 detected by the smart camera is greater than 50.
Smart Camera - 图14


6. smart camera [PORT] [STATE] fill light

Smart Camera - 图15

Turns on or off the fill light of the smart camera

How to Use

A smart camera is equipped with two fill lights on the two sides of the camera.
Smart cameras can resist the interference of light to some extent. Changing light, however, may affect the detection capability of a smart camera. Objects or colors learned in an environment may fail to be recognized in another environment with different lighting conditions. Fill lights can reduce the influence of ambient lighting conditions on the accuracy of detection.
Smart Camera - 图16

Example

When you start mBot, the fill lights of the smart camera are turned on and the smart camera starts to learn and record color block 2.
Smart Camera - 图17


7. smart camera [PORT] resets white balance

Smart Camera - 图18

Resets the white balance of the smart camera

How to Use

Ambient light changing may affect the detection accuracy of smart cameras. Resetting the white balance can reduce the influence of ambient light changing on the accuracy of detection.

Example

When you start mBot, the white balance is reset. If the smart camera detects color block 1, all LEDs on mBot are lit up in red for one second.
Smart Camera - 图19


8. smart camera[PORT] switch to line/label tracking mode

Smart Camera - 图20

Switches to the line/label tracking mode for the smart camera connected to the specified port of mBot

How to Use

A smart camera can work in either the color block detection or line/label tracking mode.

  • In the color block detection mode, a smart camera can detect and track color blocks.
  • In the line/label tracking mode, a smart camera can track lines or barcodes.

Switch the smart camera to the corresponding working mode before using its functions.

Example

When you start mBot, the smart camera connected to port 1 of mBot is switched to the line/label tracking mode.
Smart Camera - 图21


9. smart camera [PORT]detected label [BARCODE]?

Smart Camera - 图22

Determines whether the smart camera detects the specified barcode

How to Use

Barcode cards and stickers are included in the package of a smart camera. You can also download the source files of the barcodes to print them.
Click to download barcodes
The barcodes are numbered, and you need to select the corresponding number of a barcode from the drop-down list when using it.
Smart Camera - 图23
You can also place the cards on the line following map, as shown in the following.
Smart Camera - 图24

Example

After you start mBot, it moves forward, and when the smart camera detects barcode 2, it moves backward for one second.
Smart Camera - 图25


10. smart camera [PORT] detected label [BARCODE]’s [BARCODEINFO] coordinate

Smart Camera - 图26

Reports the x- or y-coordinate of the specified barcode

How to Use

The following figure shows the coordinates of the image captured by a smart camera.
Smart Camera - 图27
X-axis coordinate range: 0–320
Y-axis coordinate range: 0–240

PixyMon software

You can use the PixyMon software to view images captured by a smart camera.
Click to download PixyMon
After installing the PixyMon software, connect a smart camera to the computer by using a Micro USB cable. Then you can view images captured by the smart camera in PixyMon.

Example

After you start mBot, it moves forward, and all LEDs on it are lit up in red for one second if the smart camera detects that the x-coordinate of barcode 1 is greater than 50.
Smart Camera - 图28


11. smart camera[PORT] current line’s [LINEINFO]

Smart Camera - 图29

Reports the x- or y-coordinate of the start or end point of the captured line where the smart camera is located

How to Use

The following figure shows the coordinates of the image captured by a smart camera.

Smart Camera - 图30
X-axis coordinate range: 0–320
Y-axis coordinate range: 0–240

You can view the direction, start point, and end point of a captured line where a smart camera is located in the PixyMon software.

Smart Camera - 图31
Note: A smart camera filters out thin lines by default. If you need the smart camera to detect thin lines, modify the related parameters in PixyMon.

Example

After you start mBot, it moves forward, and all LEDs on it are lit up in red for one second if the smart camera detects that the start x-coordinate of the line is greater than 50.
Smart Camera - 图32


12. smart camera[PORT]detected cross-point?

Smart Camera - 图33

Determines whether the smart camera detects a cross point

How to Use

A smart camera can track lines and determine the number of branch roads. If the smart camera detects a cross point, this block reports True, otherwise it reports False. This block must be used in combination with another block that requires a condition. It can’t be used independently.

Smart Camera - 图34

Example

After you start mBot, it moves forward, and it turns right if the smart camera detects a cross point.
Smart Camera - 图35


13. smart camera[PORT]detected cross point’s [COORDINATES] coordinate

Smart Camera - 图36

Reports the x- or y-coordinate of the cross point detected by the smart camera

How to Use

The following figure shows the coordinates of the image captured by a smart camera.

Smart Camera - 图37
X-axis coordinate range: 0–320
Y-axis coordinate range: 0–240

Example

After you start mBot, it moves forward if the x-coordinate of the cross point detected by the smart camera is greater than 50.
Smart Camera - 图38


14. smart camera [PORT]number of branch roads detected

Smart Camera - 图39

Reports the number of branch roads detected by the smart camera

Example

After you start mBot, it turns right if the number of branch roads detected by the smart camera is greater than two.
Smart Camera - 图40


15. smart camera [PORT] [NUMBER]-numbered branch road’s angle

Smart Camera - 图41

Reports the angle of the specified branch road detected by the smart camera

How to Use

The angle in this block refers to the one between the specified branch road and vector. The vector is the line on which the smart camera is located, for example, as shown in the following figure, the red line in the image displayed in PixyMon.

Smart Camera - 图42

Example

After you start mBot, it moves forward, and it turns right if the angle of the first branch road detected by the smart camera is greater than 45 degrees.
Smart Camera - 图43


16. smart camera[PORT] sets line tracking mode to[LINEMODE]

Smart Camera - 图44

Sets the line tracking mode of the smart camera to dark line on light to light line on dark

Example

After you start mBot, it moves forward and the line tracking mode of the smart camera is set to dark line on light. If the smart camera detects a cross point, all LEDs on mBot are lit up in red for one second.
Smart Camera - 图45


17. smart camera [PORT] sets Kp in motor differential speed calculation to [KP]

Smart Camera - 图46

Sets Kp for the smart camera to calculate the motor differential speed

How to Use

Kp is the coefficient for calculating motor differential speed. It determines the turning speed of a robot when it performs automatic line/color block following.
Value range of Kp: 0–1, a greater value indicates faster turning
This block is used to initialize Kp and is usually placed in the beginning of a program. It needs to be executed for only once, and therefore it is not recommended that you put it into loop statements.

Example

When you start mBot, the coefficient Kp for calculating the motor differential speed is set to 0.5.
Smart Camera - 图47


18. smart camera [PORT] calculates motor differential speed (auto follows color block[SIG] to [LOCATION] axis [NUMBER] )

Smart Camera - 图48

Reports the motor differential speed required for making mBot follow the specified color block while keeping the color block in the specified x- or y-coordinate of the captured image

How to Use

The motor differential speed is positively related to Kp. A greater Kp value indicates a greater motor differential speed.
Value range of the motor differential speed: 0–100

The following figure shows the coordinates of an image captured by a smart camera.
Smart Camera - 图49
X-axis coordinate range: 0–320
Y-axis coordinate range: 0–240

Example

After you start mBot, it follows color block 1.
Smart Camera - 图50


19. smart camera [PORT] calculates motor differential speed (auto follows label [BARCODE] to [LOCATION] axis [NUMBER])

Smart Camera - 图51

Reports the motor differential speed required for making mBot follow the specified barcode while keeping the barcode in the specified x- or y-coordinate of the captured image

How to Use

The motor differential speed is positively related to Kp. A greater Kp value indicates a greater motor differential speed.
Value range of the motor differential speed: 0–100

Barcode cards and stickers are included in the package of a smart camera. You can also download the source files of the barcodes to print them. The barcodes are numbered, and you need to select the corresponding number of a barcode from the drop-down list when using it.
Click to download barcodes

The following figure shows the coordinates of the image captured by a smart camera.
Smart Camera - 图52
X-axis coordinate range: 0–320
Y-axis coordinate range: 0–240

Example

After you start mBot, it follows barcode 1.
Smart Camera - 图53


20. smart camera [PORT] calculates motor differential speed(targets the line-following section)

Smart Camera - 图54

Reports the motor differential speed required for keeping the line to be followed by mBot in the center of the captured image

How to Use

The motor differential speed is positively related to Kp. A greater Kp value indicates a greater motor differential speed.
Value range of the motor differential speed: 0–100

Example

After you start mBot, it moves following the line.
Smart Camera - 图55


21. smart camera[PORT]targets area near color block [SIG] to[LOCATION] axis [NUMBER] ?

Smart Camera - 图56

Determines whether the specified color block is located near the specified x- or y-coordinate of the captured image

How to Use

The following figure shows the coordinates of the image captured by a smart camera.
Smart Camera - 图57
X-axis coordinate range: 0–320
Y-axis coordinate range: 0–240

Example

After you start mBot, if the smart camera detects that color block 1 is near the x-coordinate of 150, all LEDs on mBot are lit up in red for one second.
Smart Camera - 图58


22. smart camera[PORT] targets area near label[BARCODE] to [LOCATION] axis [NUMBER] ?

Smart Camera - 图59

Determines whether the specified barcode is located near the specified x- or y-coordinate of the captured image

How to Use

The following figure shows the coordinates of the image captured by a smart camera.
Smart Camera - 图60
X-axis coordinate range: 0–320
Y-axis coordinate range: 0–240

Example

After you start mBot, if the smart camera detects that barcode 1 is near the x-coordinate of 150, all LEDs on mBot are lit up in red for one second.
Smart Camera - 图61