Welcome to MicroROS V2 Robot Car repository
2. CLI Usage
CLI Usage
1. Experiment Objective
Learn the basic usage of the YOLO command-line tool and independently test the image and video inference capabilities of YOLO models outside of ROS2.
2. Experiment Principle
1. Glossary
| Term | Description |
|---|---|
| YOLO CLI | The command-line inference tool provided by Ultralytics, invoked with the yolo <task> <mode> format; no Python code is needed |
| yolo11 | The Ultralytics YOLO11 series of models, lightweight and efficient, suitable for edge-device deployment |
| yolo26 | The Ultralytics YOLO26 series of models, a next-generation architecture with higher accuracy |
| Confidence (conf) | The minimum confidence threshold for detection boxes; detections below this value are discarded |
| IoU (iou) | Intersection over Union, the overlap-area threshold used for deduplication in NMS |
2. Technical Notes
The YOLO CLI is the command-line interface built into the ultralytics library. It supports all YOLO task types (detect, segment, classify, pose, obb) and modes (train, val, predict, export).
This section tests model inference independently outside of ROS2; it does not depend on micro_ros_agent, ROS2 nodes, or ESP32 hardware. You only need to activate the YOLO virtual environment to run it.
3. Experiment Steps
1. Hardware Requirements
| Hardware | Requirement |
|---|---|
| PTZ version | ✅ Supported |
| No-PTZ version | ✅ Supported |
| Required peripheral | None (can be tested offline) |
2. Activate the YOLO Environment
xxxxxxxxxxyolo_env3. Image Prediction
yolo11
xxxxxxxxxxyolo detect predict \ model=~/MODELS/yolo/yolo11n.onnx \ source=~/MODELS/yolo/assets/bus.jpg \ project=~/MODELS/yolo/assets/output \ exist_ok=True \ save=True \ imgsz=640 \ conf=0.25 \ iou=0.7 \ max_det=300 \ device=cpu \ show=FalseGenerated image path: /home/yahboom/MoDELS/yolo/assets/output/predict The terminal will print the generated path


yolo26
xxxxxxxxxxyolo detect predict \ model=~/MODELS/yolo/yolo26n.pt \ source=~/MODELS/yolo/assets/bus.jpg \ project=~/MODELS/yolo/assets/output \ exist_ok=True \ save=True \ imgsz=640 \ conf=0.25 \ iou=0.7 \ max_det=300 \ device=cpu \ show=FalseThe terminal will print the generated path


4. Video Prediction
yolo11
xxxxxxxxxxyolo detect predict \ model=~/MODELS/yolo/yolo11n.pt \ source=~/MODELS/yolo/videos/car.mp4 \ project=~/MODELS/yolo/videos/output \ name=visdrone_predict_yolo11n_vehicle_conf003 \ exist_ok=True \ save=True \ imgsz=960 \ conf=0.03 \ iou=0.75 \ max_det=1500 \ device=cpu \ vid_stride=1 \ classes=2,3,5,7 \ show=FalseThe terminal will print the generated path


yolo26
xxxxxxxxxxyolo detect predict \ model=~/MODELS/yolo/yolo26n.pt \ source=~/MODELS/yolo/videos/car.mp4 \ project=~/MODELS/yolo/videos/output \ name=visdrone_predict_yolo26n_vehicle_conf003 \ exist_ok=True \ save=True \ imgsz=960 \ conf=0.03 \ iou=0.75 \ max_det=1500 \ device=cpu \ vid_stride=1 \ classes=2,3,5,7 \ show=FalseThe terminal will print the generated path


5. CLI Parameter Quick Reference
| Parameter | Description | Common Values |
|---|---|---|
model | Model file path | yolo11n.pt / yolo26n.pt |
source | Input source (image/video path) | File path |
project | Output project directory | Directory path |
name | Output subdirectory name | Custom name |
exist_ok | Allow overwriting existing outputs | True |
save | Save output results | True |
imgsz | Inference input image size | 640 / 960 |
conf | Confidence threshold | 0.03 ~ 0.25 |
iou | NMS IoU threshold | 0.45 ~ 0.75 |
max_det | Maximum number of detected objects | 300 / 1500 |
device | Inference device | cpu / cuda:0 |
show | Whether to show the inference window | False (CLI mode) |
vid_stride | Video frame-skipping interval | 1 |
classes | Filter specific class IDs | 2,3,5,7 |
4. Experimental Phenomena
- Image prediction: The terminal prints the number of detected objects, and the result images are saved to the
project/name/directory. - Video prediction: The terminal prints processing progress and FPS frame by frame, and the result video is saved to the
project/name/directory. - Compared with yolo11, yolo26 usually has higher accuracy in the same scene, but inference takes slightly longer.
5. Common Problems
| Problem | Cause | Solution |
|---|---|---|
| Model file not found | The model path does not exist | Check whether there is a .pt file under ~/MODELS/yolo/ |
| Output image/video is empty | Confidence threshold too high or save=False | Check save=True and lower conf |
| Inference is very slow | CPU inference or the model is too large | Use the lightweight yolo11n model and lower imgsz |