This tutorial is suitable for M5StickV/UnitV
V-Function is a set of multiple visual recognition firmware developed by the M5Stack team for V-series devices. Based on different firmware functions (object tracking, motion detection, etc.), users can quickly build visual recognition functions. This tutorial will introduce you to how to burn firmware to your device and call it through UIFlow graphical programming.
The firmware serial output baud rate is fixed at 115200
M5Stack
or USB Serial
. Windows recommends using the driver file directly in Device Manager for installation (custom update). The executable file installation method may not work properly).
Click here to download the FTDI driver
System Preferences
-> Security & Privacy
-> General
-> Allow apps downloaded from:
-> App Store and identified developers
.Please download the corresponding M5Burner firmware burning tool according to the operating system you are using, and unzip and open the application.
Software Version | Download Link |
---|---|
M5Burner_Windows | Download |
M5Burner_MacOS | Download |
M5Burner_Linux | Download |
MacOS
users, after installation, please put the application into the Application
folder as shown below.Linux
users, switch to the decompressed file path, and run ./M5Burner
in the terminal to run the application.Select the device as M5StickV/UnitV from the left device bar, choose the corresponding functional firmware according to your needs, and download it. Connect the M5StickV/UnitV to the computer via a data cable, select its corresponding port, and click Burn to start burning.
When the burning log prompts Burn Successfully
, it means that the firmware has been burned successfully.
After burning the functional firmware, the M5StickV/UnitV will be used as a slave device in the form of Unit. Therefore, users need to use other M5 host devices to interact with it. For basic usage and operation of UIFlow on other main control products, please visit the corresponding product documentation page for reference.
Visit https://flow.m5stack.com/ to enter UIFlow. Click the Unit add button on the right function panel, select the UnitV extension to add. When adding, please configure according to the actual port used. Click OK to add.
After adding, you can find the functional blocks containing in the Unit option in the function block menu. Drag it to the right programming area to use it. For more details, please refer to the example program below.
If there is abnormal data acquisition on the main control end after connecting the slave device (M5StickV/UnitV), please restart the M5StickV/UnitV. Wait for the firmware to start successfully and try to reconnect.
Detect changes in the current frame to determine whether there is motion in the detected area.
Program Block Introduction
Initialize
Set Change Rate Threshold
Set Detection Mode
Get Frame Change Rate
Get Maximum Change Rate
Set Scan Interval X Axis Y Axis
Get Boundary Box Number
Get X Number Boundary Box Information
of the boundary box, the y-axis coordinate of the boundary box, the width of the boundary box, and the height of the boundary box.
Program Example: Enable dynamic detection mode, judge the presence of motion in the frame based on the size of the maximum change rate value read from the frame. Display "Moved" when the change rate value is greater than the expected value, otherwise display "Not Move". The screen displays the current maximum change rate value.
{
"FUNC": "MOTION DETECT V1.0",
"DIFF TOTAL": 10000, // Frame change rate
"DIFF MAX": 75, // Maximum change rate
"TOTAL": 3, // Number of boundary boxes
"0": {
"x": 45,
"y": 18,
"w": 126,
"h": 72,
"area": 342 // Number of changed pixels in this boundary box
},
"1": {
"x": 0,
"y": 169,
"w": 130,
"h": 24,
"area": 173
},
"2": {
"x": 39,
"y": 204,
"w": 276,
"h": 34,
"area": 141
}
}
{
"MOTION DETECT": 1.0, // Function flag, cannot be omitted
"mode": "COMPUTE_MODE_STATIC", // Optional "COMPUTE_MODE_STATIC" static detection mode or "COMPUTE_MODE_DYNAMIC" dynamic detection mode
"thr_w": 20, // Optional Width threshold of the boundary box,[3,200]
"thr_h": 20, // Optional Height threshold of the boundary box,[3,200]
"stepx": 1, // Optional X-axis scan interval,[0, 40], set to 0 to disable boundary box detection
"stepy": 2, // Optional Y-axis scan interval,[0, 40], set to 0 to disable boundary box detection
"delta": 20, // Optional Change rate threshold,[0, 99]
"merge": 10 // Optional Boundary box merge threshold,[0, 40]
}
Set the tracking target and obtain the real-time position information of the target object in the frame.
Program Block Introduction
Initialize
Set Tracking Box Coordinates x y Tracking Box Width Height
Get Tracking Box Trajectory Details
Program Example: Set the target selection box by pressing button A, read the target coordinates, and use them to control the movement of rectangular elements on the screen to simulate the motion trajectory of objects.
{
"FUNC": "TARGET TRACKER V1.0",
"x": 282,
"y": 165,
"w": 13,
"h": 15
}
{
"TARGET TRACKER": " V1.0",
"x": 282, //xywh cannot be omitted
"y": 165,
"w": 13,
"h": 15
}
Set LAB color thresholds to track targets in the image that meet the threshold, and obtain real-time position information of the target object in the image.
Program Block Introduction
Initialize
Set Target Color L Threshold Min 0 L Threshold Max 0 A Threshold Min A Threshold Max B Threshold Min B Threshold Max
Set Scan Interval X Axis Y Axis
Set Boundary Box Merge Threshold
Set Boundary Box Width Threshold 0 Height Threshold 0
Get Boundary Box Number
Get Boundary Box Details
Click the button below to download the LAB color picking tool. (Currently only supports Windows systems)
Download LAB Color Picking Tool
Use a phone or other device to take a sample picture, double-click to open the application, click open
--> image
to import the picture.
Click on the object you want to use for color recognition, record the LAB values generated below, and configure them for use in UIFlow. Note: Dragging the range bar of LAB values can be used to customize the LAB values.
Program Example: Set the recognized LAB threshold, achieve color tracking effect, and obtain the coordinate data of the tracked object in the image, and the number of pixels that meet the threshold.
{
"FUNC": "COLOR TRACKER V1.0",
"TOTAL": 3, // Number of boundary boxes
"0": {
"x": 45,
"y": 18,
"w": 126,
"h": 72,
"area": 342 // Number of changed pixels in this boundary box
},
"1": {
"x": 0,
"y": 169,
"w": 130,
"h": 24,
"area": 173
},
"2": {
"x": 39,
"y": 204,
"w": 276,
"h": 34,
"area": 141
}
}
{
"COLOR TRACKER": 1.0, // Function flag, cannot be omitted
"thr_w": 20, // Optional Width threshold of the boundary box,[3,200]
"thr_h": 20, // Optional Height threshold of the boundary box,[3,200]
"stepx": 1, // Optional X-axis scan interval,[0, 40], set to 0 to disable boundary box detection
"stepy": 2, // Optional Y-axis scan interval,[0, 40], set to 0 to disable boundary box detection
"merge": 10, // Optional Boundary box merge threshold,[0, 40]
"Lmin": 0, // Optional L threshold lower limit [0, 100]
"Lmax": 0, // Optional L threshold upper limit [0, 100]
"Amin": 0, // Optional A threshold lower limit [0, 255]
"Amax": 0, // Optional A threshold upper limit [0, 255]
"Bmin": 0, // Optional B threshold lower limit [0, 255]
"Bmax": 0, // Optional B threshold upper limit [0, 255]
}
Recognize faces in the image and return the number of recognitions, object coordinates, and confidence level.
Program Block Introduction
Initialize
Get Number of Faces
Get Details of the xth Face
Program Example: Read the face recognition results in the image and the confidence level.
{
"FUNC": "FACE DETECT", // 功能说明
"count": 3, // 识别到的人脸数量
"2": { // 人脸编号
"x": 97, // ROI
"y": 26,
"w": 64,
"h": 86,
"value": 0.859508, // 置信率
"classid": 0,
"index": 2,
"objnum": 3
},
"1": {
"x": 70,
"y": 157,
"w": 38,
"h": 63,
"value": 0.712100,
"classid": 0,
"index": 1,
"objnum": 3
},
"0": {
"x": 199,
"y": 145,
"w": 31,
"h": 40,
"value": 0.859508,
"classid": 0,
"index": 0,
"objnum": 3
}
}
{
"FUNC": "FACE DETECT",
"count": 3,
"2": {
"x": 97,
"y": 26,
"w": 64,
"h": 86,
"value": 0.859508,
"classid": 0,
"index": 2,
"objnum": 3
},
"1": {
"x": 70,
"y": 157,
"w": 38,
"h": 63,
"value": 0.712100,
"classid": 0,
"index": 1,
"objnum": 3
},
"0": {
"x": 199,
"y": 145,
"w": 31,
"h": 40,
"value": 0.859508,
"classid": 0,
"index": 0,
"objnum": 3
}
}
Recognize QR codes in the image and return the recognition results along with the version. Using firmware Find code
.
Program Blocks Overview
Initialize
Get QR Code Information
Get QR Code Version
Program Example: Read QR code information and version number.
{
"count": 1,
"FUNC": "FIND QRCODE",
"0": {
"x": 57,
"y": 16,
"w": 197,
"h": 198,
"payload": "m5stack",
"version": 1,
"ecc_level": 1,
"mask": 2,
"data_type": 4,
"eci": 0
}
}
Recognize barcodes in the image and return the recognition results along with the version. Using firmware Find code
.
Program Blocks Overview
Initialize
Get Recognized Barcode Content
Get Recognized Barcode Rotation Angle
Get Recognized Barcode Type
Get Recognized Barcode Position Information
Program Example: The example reflects barcode information, barcode type, barcode rotation angle, and detailed position information of the barcode.
{
"0": {
"x": 62,
"y": 90,
"w": 100,
"h": 45,
"payload": "123",
"type": 15,
"rotation": 0.000000,
"quality": 28
},
"count": 1,
"FUNC": "FIND BARCODE"
}
Recognize DataMatrix codes in the image and return the recognition results along with rotation angle, and coordinate data. Using firmware Find code
.
Program Blocks Overview
Initialize
Get Data Matrix Code Information
Get Data Matrix Code Rotation Angle
Get Data Matrix Code Position Information
Program Example: The example reflects DataMatrix code information, rotation angle, and detailed position information.
{
"0": {
"x": 20,
"y": 116,
"w": 96,
"h": 96,
"payload": "m5stack",
"rotation": 1.588250,
"rows": 16,
"columns": 16,
"capacity": 12,
"padding": 1
},
"count": 1,
"FUNC": "FIND DATAMATRIX"
}
Recognize AprilTag codes (supports only Tag36H11 type) in the image, and obtain their positional offsets. Use firmware Find Code
.
Program Blocks Introduction
Initialize
Get Rotation Angle of AprilTag Code
Get Coordinates of AprilTag Code
Get Movement Units of AprilTag Code
Program Example: The example reflects the rotation angle, movement units, and detailed positional information of the AprilTag code.
{
"0": {
"x": 71,
"y": 5,
"w": 85,
"h": 88,
"id": 1,
"family": 16,// AprilTag category
"cx": 115,
"cy": 49,
"rotation": 6.219228,// Rotation angle of AprilTag in radians (int).
"decision_margin": 0.451959,// Color saturation of AprilTag matching (values from 0.0 to 1.0), where 1.0 is optimal.
"hamming": 0,// Acceptable number of bit errors for AprilTag
"goodness": 0.000000, // Color saturation of AprilTag image
"x_translation": 0.868200, // Number of units to move the image left or right after rotation
"y_translation": 0.245313,// Number of units to move the image up or down after rotation
"z_translation": -2.725188,// Amount scaled by the image. Default is 1.0
"x_rotation": 3.093776,// Degrees to rotate the image around the x-axis in the frame buffer
"y_rotation": 0.065489,// Degrees to rotate the image around the y-axis in the frame buffer
"z_rotation": 6.219228 // Degrees to rotate the image around the z-axis in the frame buffer
},
"count": 1,
"FUNC": "FIND APRILTAG"
}
The various recognition code functionalities above are all implemented using the same firmware Find Code
. Users can switch modes by sending the following JSON data.
{
"FIND CODE": 1.0,
"mode":"DATAMATRIX" // Recognition mode, options: QRCODE, APRILTAG, DATAMATRIX, BARCODE
}
Detect tag cards in the image and return binary sequences. Note: Only fixed tag card formats are recognized, please refer to the image below.
Program Blocks Introduction
Initialize
Get Current Number of Recognized Tag Cards
Get Binary String of Recognition Result
Get uint64_t Type Code Content
Get Positional Information of Tags
00000000 00000000
00111100 00@@@@00 @@@@
01000010 0@0000@0 @ @
01000010 -> 0@0000@0 -> @ @
01011010 0@0@@0@0 @ @@ @
01000010 0@0000@0 @ @
01000010 0@0000@0 @ @
00000000 00000000
{
"FUNC": "TAG READER V2.0",
"TOTAL": 1,
"0": {
"x": 113,
"y": 65,
"w": 117,
"h": 105,
"p0x": 113, // Coordinates of the 4 vertices of the TAG
"p0y": 77,
"p1x": 211,
"p1y": 65,
"p2x": 230,
"p2y": 156,
"p3x": 127,
"p3y": 170,
"rotation": 8, // Relative rotation angle of the TAG
"rows": 8, // Number of rows of the TAG (excluding the locator frame)
"columns": 8, // Number of columns of the TAG (excluding the locator frame)
"size": 64, // Length of the actual content of the TAG, this value = number of rows * number of columns = (rows) * (columns)
"code": "0x003C42425A424200", // uint64_t type content binary code, maximum encoding of 64 bits (8 x 8) TAG
"binstr": "0000000000111100010000100100001001011010010000100100001000000000" // Binary data string, this value can encode TAGs of any length and width
}
}
Detect specified color lines in the image and return the angle of offset.
Program Blocks Introduction
Initialize
Get Line Offset Angle
Set Tracking Target Color L Threshold Min L Threshold Max A Threshold Min A Threshold Max B Threshold Min B Threshold Max
Set Line Weight 0 Region Weight, Line Weight 1 Region Weight, Line Weight 2 Region Weight
Refer to the LAB color picker tool usage in the Color Tracking
function above, shoot the line and scene to be tracked, and record the LAB values generated below, and configure them in UIFlow.
Program Example: Get the line offset angle and display it on the screen
{
"FUNC": "LINE TRACKER V1.0",
"angle": 3.8593475818634033 // Angle of turning the car
}
{
"LINE TRACKER": 1.0, // Function flag, cannot be omitted
"thr_w": 20, // Optional, width threshold of the boundary box, [3,200]
"thr_h": 20, // Optional, length threshold of the boundary box, [3,200]
"stepx": 1, // Optional, X scan interval, [0, 40], set to 0 to disable boundary box detection
"stepy": 2, // Optional, Y scan interval, [0, 40], set to 0 to disable boundary box detection
"merge": 10, // Optional, boundary box merge threshold, [0, 40]
"Lmin": 0, // Optional, L threshold lower limit [0, 100]
"Lmax": 0, // Optional, L threshold upper limit [0, 100]
"Amin": 0, // Optional, A threshold lower limit [0, 255]
"Amax": 0, // Optional, A threshold upper limit [0, 255]
"Bmin": 0, // Optional, B threshold lower limit [0, 255]
"Bmax": 0, // Optional, B threshold upper limit [0, 255]
"weight_0": 0.1, // Optional, weight
"weight_1": 0.3, // Optional, weight
"weight_2": 0.7 // Optional, weight
}