Volume measurement

Before starting this function, you need to close the process of the big program and APP. Enter the following program in the terminal to close the process of the big program and APP.

If you need to start the big program and APP again later, start the terminal.

 

1. Function description

After the program runs, the program will identify the shape of the selected color block, obtain the relevant data of the color block, and calculate the volume of the color block.

 

2. Start and operation

2.1. Start command

Enter the following command in the terminal to start,

 

2.2, Operation

After the program starts, put the color block into the image. Use the mouse to select an area in the color block and obtain the HSV value. If the HSV value of the selected color cannot correctly identify the shape of the color block, you may need to fine-tune the HSV value. Enter the following command in the terminal to start the dynamic parameter regulator,

You can modify the HSV value through the slider,

image-20241023114015502

The program uses the HSV value to filter out other colors and only retains colors that meet the HSV value range. The program will identify the shape of the color block, and calculate the data of the color block based on the center point of the color block, and calculate the volume of the color block based on the identified color block shape.

image-20241012194840943

 

3. Program flow chart

calculate_volume.py

 

4. Core code analysis

Code path: /home/jetson/dofbot_pro_ws/src/dofbot_pro_RGBDCam/scripts/calculate_volume.py

Import necessary libraries,

Program initialization, creation of publishers, subscribers, etc.

Image processing function ComputeVolume,

Get the position function in the world coordinate system get_pos,