yahboom
HomeLearn
Solution
Blog
Online Store
About Us
EN/中文
DOFBOT SE📖
1.First Trial
  • 1.First Trial
  • 2.Analysis of common problems
  • 3.Calibration offset
  • 4.Precautions for DIY Robotic Arm
  • 5.Robotic arm gripping anomaly solutions
2.Assembly Course
  • 1.Installation video
  • 2.Calibrate the Robotic Arm
  • 3.Install the map
3.Remote Control Course
  • 1.Mobile APP control
  • 2.USB handle control
  • 3.PC software control
4.Preparation
  • 1.Manage APP control service
  • 2.Manage JupyterLab service
  • 3.Write STM32 firmware
  • 4.Introduction to expansion board
5.Basic Control Course
  • 1.Control RGB light
  • 2.Control buzzer
  • 3.Control single servo
  • 4.Read servo angle
  • 5.Control all servo
  • 6.DOFBOT up down left right
  • 7.DOFBOT dancing
  • 8.DOFBOT memory action
  • 9.DOFBOT grab block
  • 10.Porter
  • 11.Stack block
  • 12.USB camera display
  • 13.Synchronous action
6.AI Vision Basic Course
  • 1.Gesture Recognition
  • 2.Color threshold adjustment Color calibration
  • 3.Color recognition
  • 4.Face recognition
  • 5.Garbage recognition
  • 6.Yolo object recognition
  • 7.Real-time web view
7.2D Visual Tracking Course
  • 1.PID algorithm basics
  • 2.Color block positioning
  • 3.Color block tracking
  • 4.Face positioning
  • 5.Face tracking
  • 6.Gesture recognition fixed action
8.2D Visual Grasping Course
  • 0.Visual positioning
  • 1.Gesture recognition stack blocks
  • 2.Color recognition grab blocks
  • 3.Catch game
  • 4.Color sorting and stacking
  • 5.Garbage sorting
  • 6.Color interaction
9.2D Mediapipe Course
  • 1.Hand detection
  • 2.Posture detection
  • 3.Overall inspection
  • 4.Face detection
  • 5.Face recognition
  • 6.Face effects
  • 7.3D object recognition
  • 8.Paintbrush
  • 9.Finger control
  • 10.Gesture recognition
  • 11.Gesture control robotic arm action group
  • 12.Arm posture control robotic arm
  • 13.Palm Targeting
  • 14.Robotic arm tracks the palm
  • 15.Fingertip trajectory recognition
  • 16.Fingertip trajectory control robotic arm
  • 17.Gesture Grasp and Release Objects
  • 18.Finger Control Robot Arm
10.AI Large Model Voice Module (Must Read)
  • 1. Introduction to AI Large Model Voice Module
  • 2. Flash the firmware (Must read)
  • 3. Modify the wake-up word and command word
11.2D Voice Control Course
  • 1.Simple Voice Control
  • 2.Smart Voice Control
  • 3.Voice Action Control
  • 4.Memory Learning Mode
  • 5.Color Recognition with Voice Broadcast
  • 6.Color Recognition and Grasping with Voice Broadcast
  • 7.Color Recognition and Sorting with Voice Broadcast
  • 8.Voice Recognition Target Tracking
  • 9.Voice Control Stacking
  • 10.Voice Control Color Sorting
  • 11.Garbage Recognition with Voice Broadcast
  • 12.Garbage Sorting with Voice Broadcast
12.Robotic Arm Control and Inverse Kinematics
  • 1. Robotic arm ROS control
  • 2. Inverse solution
13.3D Sorting and Grasping Course
  • 1.AprilTag ID sorting
  • 2.MediaPipe Gesture-AprilTag ID sorting
  • 3.MediaPipe Gesture-AprilTag distance sorting
  • 4.Block color sorting
  • 5.Block different shape sorting
  • 6.Yolov11 garbage sorting
14.3D Tracking Course
  • 1.AprilTag Tracking
  • 2.Color Block Tracking
  • 3.KCF Object Tracking
15.3D Voice Control for Sorting & Tracking Course
  • 1.Voice Control AprilTag ID Sorting
  • 2.Voice Control Color Block Sorting
  • 3.Voice Control Yolov11 Garbage Recognition Sorting
  • 4.Voice Control AprilTag Tracking
  • 5.Voice Control Color Block Tracking
  • 6.Voice Control Object Tracking
16.AI Model Basics
  • 1.AI large model types and principles
  • 2.RAG retrieval enhancement and model training samples
  • 3.Embodied intelligent robot system architecture
  • 4.Embodied intelligent functions core source code
17.AI Model Development
  • 1. Register a model service provider account
  • 2. Configure API-KEY
  • 3. Introduction to Dify
  • 4. Basic Dify Features
  • 5. AI Large Model Development - chatbot
  • 6. Deploy the RAG knowledge base
  • 7. RAG knowledge base + chatbot
  • 8. AI agent workflow
18.AI Model – Text Version
  • 1.Semantic understand instruction following
  • 2.Multimodal visual understand
  • 3.Text Large Model + robotic arm control
  • 4.Multimodal Large Model+video understanding
  • 5.Multimodal Large Model+robotic arm gripping
  • 6.Multimodal Large Model+robotic arm tracking
  • 7.Multimodal Large Model+robotic arm sorting
  • 8.Multimodal Large Model+robotic arm handling
  • 9.Multimodal Large Model+Color Blocks Back In Place
  • 10.Multimodal Large Model + Intent Prediction + Robotic Arm Gripping
  • 11.Text Large Model + YOLOv11 + Intelligent Garbage Classification
19.AI Model – Voice Version
  • 1.Semantic understand instruction following
  • 2.Multimodal visual understand
  • 3.Text Large Model + robotic arm control
  • 4.Multimodal Large Model+video understanding
  • 5.Multimodal Large Model+robotic arm gripping
  • 6.Multimodal Large Model+robotic arm tracking
  • 7.Multimodal Large Model+robotic arm sorting
  • 8.Multimodal Large Model+robotic arm handling
  • 9.Multimodal Large Model+Color Blocks Back In Place
  • 10.Multimodal Large Model + Intent Prediction + Robotic Arm Gripping
  • 11.Text Large Model + YOLOv11 + Intelligent Garbage Classification
20.AI Model – Fun Applications
  • 1.AI Butler-Intent Inference
  • 2.AI Encyclopedia-Arithmetic Master
  • 3.AI Encyclopedia-You asked I Pointed
  • 4.AI Encyclopedia-Nutritional Analysis
  • 5.AI Encyclopedia-Problem Solving Expert
  • 6.AI Encyclopedia-English Spelling
  • 7.AI Butler-Garbage Sorting
  • 8.AI Top Chef
21.MoveIt2 Course
  • 1. MoveIt Configuration
  • 2. MoveIt Usage
  • 3. MoveIt Drive Real Robot
  • 4. MoveIt Random Movement
  • 5. MoveIt Forward Kinematics Design
  • 6. MoveIt Inverse Kinematics Design
  • 7. MoveIt Cartesian Path
  • 8. MoveIt Scene Design
  • 9. MoveIt Trajectory Planning
  • 10. MoveIt Collision Detection
22.YOLOv11 Development Course
  • 1. YOLO Environment Setup
  • 2. CLI Usage
  • 3. Object Detection
  • 4. Instance Segmentation
  • 5. Pose Estimation
  • 6. Image Classification
  • 7. Oriented Bounding Boxes Object Detection
  • 8. Model Conversion
  • 9. Model Prediction
23. Linux Operating System
  • 1.Introduction to Linux system
  • 2.Ubuntu file system
  • 3.Ubuntu common commands
  • 4.Ubuntu common editors
  • 5.Ubuntu software operation commands
  • 6.Virtual machine installation
  • 7.SSH remote control
  • 8.VNC remote control
  • 9.Transfer files remotely
  • 10.Driver library and communication
  • 11.Static IP and hotspot mode
  • 12.Bind device ID
  • 13.Capacity expansion and resource allocation
  • 14.Update system software sources
  • 15.Set root user password
  • 16.sudo free password
  • 17.Connect to WiFi network
  • 18.View system version
  • 19.Customized service management
  • 20.Back up system image
24.OpenCV Course
  • 1.Introduction to Open Source CV
  • 2.Image reading and display
  • 3.Picture writing
  • 4.Image Quality
  • 5.Pixel operations
  • 6.Image zoom
  • 7.Picture cut
  • 8.Picture pan
  • 9.Picture mirroring
  • 10.Affine transformation
  • 11.Picture rotation
  • 12.perspective transformation
  • 13.Grayscale processing
  • 14.Binary image
  • 15.Edge green detection
  • 16.Line segment drawing
  • 17.Rectangular circle drawing
  • 18.Text and picture drawing
25.Advanced Visuals Course
  • 1. QR Code
  • 2. Human Pose Estimation
  • 3. Object Detection
  • 4. AR Vision
  • 5. ROS + OpenCV Basics
26.ROS2 Basic Course
  • 1.Introduction to ROS2
  • 2.ROS2 install Humble
  • 3.ROS2 development environment
  • 4.ROS2 workspace
  • 5.ROS2 function package
  • 6.ROS2 node
  • 7.ROS2 topic communication
  • 8.ROS2 service communication
  • 9.ROS2 action communication
  • 10.ROS2 custom interface message
  • 11.ROS2 parameter service case
  • 12.ROS2 meta-function package
  • 13.ROS2 distributed communication
  • 14.ROS2 DDS
  • 15.ROS2 time related API
  • 16.ROS2 common command tools
  • 17.ROS2 rviz2 use
  • 18.ROS2 rqt toolbox
  • 19.ROS2 Launch startup file configuration
  • 20.ROS2 recording and playback tool
  • 21.ROS2 URDF model
  • 22.ROS2 Gazebo simulation platform
  • 23.ROS2 TF2 coordinate transformation
27.Jupyter Lab Usage Course
  • 0.Read the document before operation
  • 1.Jupyter Lab environment construction
  • 2.Basic use of Jupyter Widgets
  • 3.Launch JupyterLab
  • 4.How to Use JupyterLab
Download
  • APP(iOS/Android)
  • VM File
  • Instruction manual
  • Hardware_3DModelFile
  • PC_Software
  • Code
  • Communication Protocol-Python Library
  • Tools
Download ZIP

Welcome to DOFBOT SE repository

5.Block different shape sorting

Block Different Shape Sorting

1. Function Description

After the program runs, place blocks of the same color. After the camera captures the image, it performs color recognition based on HSV values and recognizes the shape of the block. Press the spacebar, and the robotic arm will grip the block with the target shape being square. (Note: The default gripping width for the robotic arm should be 3cm. Gripping larger objects may cause damage to the gripper servo. This is not a quality issue.) Place it at the set position. After placement is complete, return to the initial block recognition pose.

2. Startup and Operation

(1) Startup Commands

Enter the following commands in the terminal to start:

# Start camera, inverse kinematics program
ros2 launch dofbot_info camera_arm_kin.launch.py 
# Start color recognition program:
ros2 run dofbot_sorting_3d shape_sorting 
# Start robotic arm gripping program:
ros2 run dofbot_sorting_3d grasp 

image-20260307162058480.png

(2) Operation Process

After the terminal starts, place blocks of the same color. The camera captures the image. Press 【r】, 【g】, 【b】, 【y】 to select the target block color. If recognition is not successful, you can use the mouse to select an area of the block to get the HSV values of that area. Release the mouse to enter color recognition mode. In color recognition mode, if the current HSV values still cannot filter out other colors, you can use the dynamic parameter adjuster to fine-tune the HSV values. Enter the following command in the terminal to start the dynamic parameter adjuster.

When the left image (binarized) shows only one uniquely recognized color, click on the color image frame and press the spacebar. The robotic arm will lower the gripper to grip the block with the set target shape. The default gripping target shape is square.

3. Program Flowchart

N
Y
Start
Program initialization
Receive color image topic
Process received image message, convert to color image data and return shape related information
Check if self.color.shape_cx and self.color.shape_cy values are not 0
Conditions not met, do not process
Both are not 0, assign values to created topic data object, check if depth value of this center point is 0 and self.pubPos_flag is true, if both conditions are met, publish message
Publish topic message

4. Core Code Analysis

shape_sorting.py

Code path:

xxxxxxxxxx
/home/yahboom/dofbot_ws/src/dofbot_sorting_3d/dofbot_sorting_3d/shape_sorting.py

color_common code library path:

xxxxxxxxxx
/home/yahboom/dofbot_ws/src/dofbot_sorting_3d/dofbot_sorting_3d/color_common.py

Import necessary libraries,

​x
import cv2
import cv2 as cv
import os
import numpy as np
import time
from Arm_Lib import Arm_Device
​
from cv_bridge import CvBridge
from dofbot_sorting_3d.color_common import *
from dofbot_interface.msg import *
from std_msgs.msg import Bool,Int16
from rclpy.node import Node
import rclpy
import threading

Initialize program parameters, create publishers, subscribers, etc.,

xxxxxxxxxx
def __init__(self, name):
    # Initialize nodeInitialize node
    super().__init__(name)
    # Create arm device objectCreate arm device object
    self.Arm = Arm_Device()
    # Initial joint anglesInitial joint angles
    self.init_joints = [90, 120, 0, 0, 90, 0]
    # Create RGB image bridge objectCreate RGB image bridge object
    self.rgb_bridge = CvBridge()
    # Position publish flagPosition publish flag
    self.pub_pos_flag = False
​
    # Create AprilTag position info publisherCreate AprilTag position info publisher
    self.pos_info_pub = self.create_publisher(AprilTagInfo,"PosInfo",1)
    # Create joint5 angle publisherCreate joint5 angle publisher
    self.TargetJoint5_pub = self.create_publisher(Int16, "set_joint5", 10)
​
    # Create grasp completion status subscriberCreate grasp completion status subscriber
    self.sub_grasp_status = self.create_subscription(Bool,"grasp_done",self.get_graspStatusCallBack,100)
​
    # Target colorTarget color
    self.target_color = 0
    # Red HSV threshold file pathRed HSV threshold file path
    self.red_hsv_text = os.path.join(package_pwd, 'red_colorHSV.text')
    # Green HSV threshold file pathGreen HSV threshold file path
    self.green_hsv_text = os.path.join(package_pwd, 'green_colorHSV.text')
    # Blue HSV threshold file path Blue HSV threshold file path
    self.blue_hsv_text = os.path.join(package_pwd, 'blue_colorHSV.text')
    # Yellow HSV threshold file path Yellow HSV threshold file path
    self.yellow_hsv_text = os.path.join(package_pwd, 'yellow_colorHSV.text')
    # HSV color rangeHSV color range
    self.hsv_range = ()
    # Region of interest initializationRegion of interest initialization
    self.Roi_init = ()
    # HSV range of ROI regionHSV range of ROI region
    self.roi_hsv_range = ()
    # Selection flagSelection flag
    self.select_flags = False
    # Window nameWindow name
    self.windows_name = 'frame'
    # Track stateTrack state
    self.Track_state = 'init'
    # Mouse coordinatesMouse coordinates
    self.Mouse_XY = (0, 0)
    # Image columns and rowsImage columns and rows
    self.cols, self.rows = 0, 0
    # Color detection objectColor detection object
    self.color = color_detect()
    # Current colorCurrent color
    self.cur_color = None
    # Text colorText color
    self.text_color = (0,0,0)
    # Circle center X coordinateCircle center X coordinate
    self.cx = 0
    # Circle center Y coordinateCircle center Y coordinate
    self.cy = 0
    # Circle radiusCircle radius
    self.circle_r = 0
    # Joint angle messageJoint angle message
    self.joint5 = Int16()
    # Corner arrayCorner array
    self.corners = np.empty((4, 2), dtype=np.int32)
    # Current target colorCurrent target color
    self.cur_target_color = 0
    # Update flagUpdate flag
    self.updata_flag = False
    # Set arm initial joint anglesSet arm initial joint angles
    self.Arm.Arm_serial_servo_write6_array(self.init_joints,2000)
    # Target distanceTarget distance
    self.dist = 0.13
    # Create image subscriberCreate image subscriber
    self.subscription = self.create_subscription(Image,'/image_raw',self.ImageCallback,1)
    # Target shapeTarget shape
    self.target_shape = "Square"
    # Shape X and Y coordinatesShape X and Y coordinates
    self.shape_x = self.shape_y = 0
    # Grasp completion flagGrasp completion flag
    self.grasp_done = True
    # Dynamic update flagDynamic update flag
    self.dyn_update = False
​
    # Declare HSV parametersDeclare HSV parameters
    self.declare_parameter("Hmin", 0)
    self.declare_parameter("Smin", 85)
    self.declare_parameter("Vmin", 126)
    self.declare_parameter("Hmax", 9)
    self.declare_parameter("Smax", 253)
    self.declare_parameter("Vmax", 253)

Let's look at the main image processing function ImageCallback,

xxxxxxxxxx
def ImageCallback(self,color_frame):
    # Convert image to opencv format
    rgb_image = self.rgb_bridge.imgmsg_to_cv2(color_frame,'rgb8')
    rgb_image = cv2.cvtColor(rgb_image, cv2.COLOR_RGB2BGR)
    result_image = np.copy(rgb_image)
    #Space key triggers position information publishing
    key = cv2.waitKey(10)
    if key == 32:
        self.pub_pos_flag = True
    result_frame, binary = self.process(rgb_image,key)
    show_frame = threading.Thread(target=self.img_out, args=(result_frame,binary,))
    show_frame.start()
    show_frame.join()
    # Shape recognition logic
    if self.hsv_range and self.grasp_done == True:
        # Set current target shape
        self.color.target_shape = self.target_shape
        # Perform shape recognition
        result_image, binary_processed, circle_info, corner_info = self.color.ShapeRecognition(rgb_image, self.hsv_range)
​
        # Check if target shape is detected
        if self.color.shape_cx != 0 and self.color.shape_cy != 0:
            print("Find the target shape block")
            self.shape_x = self.color.shape_cx
            self.shape_y = self.color.shape_cy
            print("self.shape_x: ", self.shape_x)
            print("self.shape_y: ", self.shape_y)
            # Draw shape name on result image
            cv2.putText(result_image, self.color.shape_name, (int(self.color.shape_cx) - 20, int(self.color.shape_cy)), 
                        cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 0, 0), 2)
​
        if self.shape_x!=0 and self.shape_y!=0 and self.color.shape_name == self.target_shape:  
            print("...................................................")
            cx = int(self.shape_x)
            cy = int(self.shape_y)
            (a, b) = (round(((320 - cx)/4000), 5), round(((480 - cy)/3000) * 0.8+0.13, 5))
            pos = AprilTagInfo()
            pos.id = self.target_color
            pos.x = float(b)  
            pos.y = float(a)   
            pos.z = 0.03
            if self.pub_pos_flag == True:
                print("--------------------")
                self.pub_pos_flag = False
                self.pos_info_pub.publish(pos)    
                print(f"Published position info: ID={pos.id}, x={pos.x}, y={pos.y}, z={pos.z}")
                print("*******************")
                self.shape_x = 0
                self.shape_y = 0    
                self.grasp_done = False
    cv.imshow("detect_shape", result_image)

Image processing function self.process,

xxxxxxxxxx
def process(self,rgb_img,key):
    # Resize image to 640x480 Resize image to 640x480
    rgb_img = cv.resize(rgb_img, (640, 480))
    # Initialize binary image list Initialize binary image list
    binary = []
    # Press C key: clear target color and reset Press C key: clear target color and reset
    if key == ord('c') or key == ord('C'):
        self.target_color = 0
        self.Reset()  
        self.updata_flag = True
    # Press R key: set target color to red Press R key: set target color to red
    elif key == ord('r') or key == ord('R'): 
        self.target_color = 3
        self.cur_target_color = self.target_color
    # Press G key: set target color to green Press G key: set target color to green
    elif key == ord('g') or key == ord('G'): 
        self.target_color = 2
        self.cur_target_color = self.target_color
    # Press B key: set target color to blue Press B key: set target color to blue
    elif key == ord('b') or key == ord('B'): 
        self.target_color = 1
        self.cur_target_color = self.target_color
    # Press Y key: set target color to yellow Press Y key: set target color to yellow
    elif key == ord('y') or key == ord('Y'): 
        self.target_color = 4
        self.cur_target_color = self.target_color
    # Press I key or target color exists: enter identify mode Press I key or target color exists: enter identify mode
    elif key == ord('i') or key == ord('I') or self.target_color!=0: self.Track_state = "identify"
    # Print track state for debugging Print track state for debugging
    #print("self.Track_state: ",self.Track_state)
    # Init state: create window and set mouse callback Init state: create window and set mouse callback
    if self.Track_state == 'init':
        cv.namedWindow(self.windows_name, cv.WINDOW_AUTOSIZE)
        cv.setMouseCallback(self.windows_name, self.onMouse, 0)
        # If region is selected, draw selection box If region is selected, draw selection box
        if self.select_flags == True:
            cv.line(rgb_img, self.cols, self.rows, (255, 0, 0), 2)
            cv.rectangle(rgb_img, self.cols, self.rows, (0, 255, 0), 2)
            # If selection region is valid, calculate HSV range If selection region is valid, calculate HSV range
            if self.Roi_init[0] != self.Roi_init[2] and self.Roi_init[1] != self.Roi_init[3]:
                rgb_img, self.hsv_range = self.color.Roi_hsv(rgb_img, self.Roi_init)
                # Save HSV range of ROI region Save HSV range of ROI region
                self.roi_hsv_range = self.hsv_range
                # Set dynamic update flag Set dynamic update flag
                self.dyn_update = True
            else: self.Track_state = 'init'
​
    # Identify state: load HSV threshold based on target color Identify state: load HSV threshold based on target color
    elif self.Track_state == "identify":
        # Red: load red HSV threshold Red: load red HSV threshold
        if self.target_color == 3:
            self.hsv_range = read_HSV(self.red_hsv_text)
            self.cur_color = "red"
            self.text_color = (0, 0, 255)
​
​
        # Green: load green HSV threshold Green: load green HSV threshold
        elif self.target_color == 2:
            self.hsv_range = read_HSV(self.green_hsv_text)
            self.cur_color = "green"
            self.text_color = (0, 255, 0)
​
​
        # Blue: load blue HSV threshold Blue: load blue HSV threshold
        elif self.target_color == 1:
            self.hsv_range = read_HSV(self.blue_hsv_text)
            self.cur_color = "blue"
            self.text_color = (255, 0, 0)
​
        # Yellow: load yellow HSV threshold Yellow: load yellow HSV threshold
        elif self.target_color == 4:
            self.hsv_range = read_HSV(self.yellow_hsv_text)
            self.cur_color = "yellow"
            self.text_color = (255, 255, 0)
​
        # Invalid color: return to init state Invalid color: return to init state
        else: 
            self.Track_state = 'init'
​
    # If not in init state, perform object tracking If not in init state, perform object tracking
    if self.Track_state != 'init':
        # If HSV range is valid, perform object tracking If HSV range is valid, perform object tracking
        if len(self.hsv_range) != 0:
            rgb_img, binary, self.circle,_,self.corners= self.color.object_follow(rgb_img, self.hsv_range)
            # If dynamic update is needed, save HSV threshold to file and update ROS parameters
            # If dynamic update is needed, save HSV threshold to file and update ROS parameters
            if self.dyn_update is True:
                # Write HSV threshold to corresponding file based on current target color Write HSV threshold to corresponding file based on current target color
                if self.target_color == 3:
                    write_HSV(self.red_hsv_text, self.hsv_range)
                elif self.target_color == 2:
                    write_HSV(self.green_hsv_text, self.hsv_range)
                elif self.target_color == 1:
                    write_HSV(self.blue_hsv_text, self.hsv_range)
                elif self.target_color == 4:
                    write_HSV(self.yellow_hsv_text, self.hsv_range)
​
                # Update ROS parameters Update ROS parameters
                self.Hmin = rclpy.parameter.Parameter('Hmin', rclpy.Parameter.Type.INTEGER, int(self.roi_hsv_range[0][0]))
                self.Smin = rclpy.parameter.Parameter('Smin', rclpy.Parameter.Type.INTEGER, int(self.roi_hsv_range[0][1]))
                self.Vmin = rclpy.parameter.Parameter('Vmin', rclpy.Parameter.Type.INTEGER, int(self.roi_hsv_range[0][2]))
                self.Hmax = rclpy.parameter.Parameter('Hmax', rclpy.Parameter.Type.INTEGER, int(self.roi_hsv_range[1][0]))
                self.Smax = rclpy.parameter.Parameter('Smax', rclpy.Parameter.Type.INTEGER, int(self.roi_hsv_range[1][1]))
                self.Vmax = rclpy.parameter.Parameter('Vmax', rclpy.Parameter.Type.INTEGER, int(self.roi_hsv_range[1][2]))
                all_new_parameters = [self.Hmin, self.Smin, self.Vmin, self.Hmax, self.Smax, self.Vmax]
                self.set_parameters(all_new_parameters)
                # Reset dynamic update flag Reset dynamic update flag
                self.dyn_update = False
​
            # Save circle center coordinates and radius Save circle center coordinates and radius
            self.cx = self.circle[0]
            self.cy = self.circle[1]
            self.circle_r = self.circle[2]
            # Save HSV threshold to file based on current target color Save HSV threshold to file based on current target color
            if self.cur_target_color == 3 and self.updata_flag == True:
                write_HSV(self.red_hsv_text, self.hsv_range)  # 红色 Red
            elif self.cur_target_color  == 2 and self.updata_flag == True:
                write_HSV(self.green_hsv_text, self.hsv_range)  # 绿色 Green
            elif self.cur_target_color == 1 and self.updata_flag == True:
                write_HSV(self.blue_hsv_text, self.hsv_range)  # 蓝色 Blue
            elif self.cur_target_color == 4 and self.updata_flag == True:
                write_HSV(self.yellow_hsv_text, self.hsv_range)  # 黄色 Yellow
            # Reset update flag Reset update flag
            self.updata_flag = False
​
    # Draw current color name on image Draw current color name on image
    rgb_img = cv2.putText(rgb_img, self.cur_color, (10, 30), cv2.FONT_HERSHEY_SIMPLEX, 1, self.text_color, 2)             
    # Return processed image and binary image Return processed image and binary image
    return rgb_img, binary
​

grasp.py

The previous chapter has explained this, so I won't repeat it here

Block color sorting
Yolov11 garbage sorting

COMPANY

  • About us
  • Team Style
  • Blog

LEARNING & EXPLORATION

  • Tutorials
  • Edge AI hardware
  • Educational robots
  • Embedded intelligent hardware

WHERE TO BUY

  • Yahboom Online Store
  • Amazon
  • Alibaba
  • AliExpress
  • Mercado

TECHNOLOGY SUPPORT

  • Email: support@yahboom.com

BE A DISTRIBUTOR

  • Email: sales@yahboom.com
QR Code

Copyright © 2017-2026 Yahboom. All Rights Reserved.

EN/中文