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

6.Voice Control Object Tracking

Voice Control Object Tracking

1. Function Description

After the program starts, the robotic arm will move to the tracking pose. Hold the object you want to track and grasp, and appear it in the camera field of view. Use the mouse to draw a box around the selected object, and release the mouse to complete the selection. Say "Hi, yahboom" to the voice recognition module, and the speaker will announce "I am here". Then say "Tracking and picking up objects" to the voice module, and the speaker will announce "OK". Then the robotic arm starts tracking the selected object. Slowly move the object, and the robotic arm will also move along with it.

Note: When tracking an object, it needs to be moved slowly within the camera's field of view. This case will not perform grasping operations on the target, it only has the tracking function!

2. Startup and Operation

# Start camera and inverse kinematics
ros2 launch dofbot_info camera_arm_kin.launch.py
# Start voice recognition and announcement
ros2 launch yahboom_speech speech.launch.py
# Start robotic arm control
ros2 run dofbot_voice_ctrl grasp_VC 
# Start object tracking
ros2 run dofbot_voice_ctrl KCF_follow 

3. Core Code Analysis

Object Tracking Node KCF_follow

Source code path: /home/yahboom/dofbot_ws/src/dofbot_voice_ctrl/dofbot_voice_ctrl/KCF/KCF_follow.py

Image subscription callback

xxxxxxxxxx
def ImageCallback(self, color_frame):
    # Convert ROS2 Image message to OpenCV BGR image format
    # 将ROS2 Image消息转换为OpenCV BGR图像格式
    rgb_image = self.rgb_bridge.imgmsg_to_cv2(color_frame, 'bgr8')
    
    # Create a copy of the image for drawing results
    # 创建图像副本用于绘制结果
    result_image = np.copy(rgb_image)
    
    # Capture key press for user interaction
    # 捕获按键以进行用户交互
    action = cv.waitKey(10) & 0xFF
    
    # Spacebar toggles the follow mode
    # 空格键切换跟随模式
    if action == 32:
        self.start_follow = True
    
    # Resize the image to 640x480 resolution
    # 将图像调整为640x480分辨率
    result_image = cv.resize(result_image, (640, 480))
    
    # Process the image
    # 处理图像
    result_frame = self.process(result_image, action)
    
    # Check if object is detected and follow mode is active
    # 检查物体是否被检测到且跟随模式是否激活
    if self.cx != 0 and self.cy != 0 and self.start_follow == True:
        # Image center: (320, 240) for 640x480 resolution
        # 图像中心:(320, 240),对应640x480分辨率
        # Threshold: 10 pixels (dead zone to avoid jitter)
        # 阈值:10像素(死区以避免抖动)
        if (abs(self.cx - 320) > 10 or abs(self.cy - 240) > 10):
            # Call XY tracking function to adjust arm position
            # 调用XY跟踪函数以调整机械臂位置
            self.XY_track(self.cx, self.cy)
            
        # Draw a circle at the detected object's center
        # 在检测到的物体中心绘制一个圆
        cv2.circle(result_frame, (int(self.cx), int(self.cy)), 10, (255, 255, 0), thickness=None, lineType=None, shift=None)
    
    # Calculate and display FPS (frames per second)
    # 计算并显示FPS(每秒帧数)
    cur_time = time.time()
    fps = str(int(1 / (cur_time - self.pr_time)))
    self.pr_time = cur_time
    cv2.putText(result_frame, fps, (10, 30), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 0), 2)
    
    # Display the result image in a window
    # 在窗口中显示结果图像
    cv.imshow(self.windows_name, result_frame)

Image processing function process

​x
def process(self, rgb_img, action):        
    # Resize the input image to 640x480 resolution
    # 将输入图像调整为640x480分辨率
    rgb_img = cv.resize(rgb_img, (640, 480))
​
    # If 'r' key is pressed, reset the tracking system to initial state
    # 如果按下 'r' 键,将跟踪系统重置为初始状态
    if action == ord('r') or action == 114: 
        self.Reset()
​
    # State machine: Initialization state
    # 状态机:初始化状态
    if self.Track_state == 'init':
        # Create a named window for mouse interaction (ROI selection)
        # 创建用于鼠标交互(ROI选择)的命名窗口
        cv.namedWindow(self.windows_name, cv.WINDOW_AUTOSIZE)
        # Set mouse callback function for selecting ROI
        # 设置鼠标回调函数用于选择感兴趣区域
        cv.setMouseCallback(self.windows_name, self.onMouse, 0)
        
        if self.select_flags == True:
            # Draw a line from start point to current mouse position
            # 从起点到当前鼠标位置绘制线条
            cv.line(rgb_img, self.cols, self.rows, (255, 0, 0), 2)
            # Draw a rectangle representing the ROI
            # 绘制代表ROI的矩形
            cv.rectangle(rgb_img, self.cols, self.rows, (0, 255, 0), 2)
                
    # State machine: Tracking state
    # 状态机:跟踪状态
    if self.Track_state != 'init':
        # If tracker initialization is requested
        # 如果需要初始化跟踪器
        if self.gTracker_state == True:
            Roi = (self.Roi_init[0], self.Roi_init[1], 
                   self.Roi_init[2] - self.Roi_init[0], 
                   self.Roi_init[3] - self.Roi_init[1])
            
            # Reinitialize the tracker with the selected ROI
            # 使用选定的ROI重新初始化跟踪器
            self.gTracker = Tracker(tracker_type=self.tracker_type)
            self.gTracker.initWorking(rgb_img, Roi)
            self.gTracker_state = False  # Clear the initialization flag
        
        # Perform tracking on the current frame
        # 对当前帧执行跟踪
        rgb_img, (targBegin_x, targBegin_y), (targEnd_x, targEnd_y) = self.gTracker.track(rgb_img)
        
        # Calculate the center of the tracked object
        # 计算跟踪物体的中心
        center_x = targEnd_x / 2 + targBegin_x / 2
        center_y = targEnd_y / 2 + targBegin_y / 2
        
        # Update global center coordinates
        # 更新全局中心坐标
        self.cx = center_x
        self.cy = center_y
        .....
    return rgb_img
xxxxxxxxxx
# Create subscriber for voice recognition result topic
# 创建订阅语音识别结果话题的订阅者
self.sub_voice =self.create_subscription(Int8,"voice_result",self.getVoiceResultCallBack,1)
​
def getVoiceResultCallBack(self,msg):
    if msg.data == 107:
        self.start_follow = True
        print("Start tracking .")
    elif msg.data == 76:
        self.Reset()
​

The XY_track tracking function has been explained in previous tutorials, so it will not be repeated here.

Voice Control Color Block Tracking
AI large model types and principles

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
QR Code

Copyright © 2017-2026 Yahboom. All Rights Reserved.

EN/中文