Welcome to DOFBOT-Pi repository
3. Object Detection
Object Detection
Note: If using the docker container from the factory image, you don't need to rebuild the environment. The environment is already set up, you just need to enter the docker according to the previous tutorial and run the corresponding function commands to use it.
1. Object Detection: Image
Use yolo11n.pt to predict images that come with the ultralytics project.
Enter the code folder:
cd /root/ultralytics/ultralytics/yahboom_demo
Run the code:
xxxxxxxxxxpython3 01.detection_image.py

Effect Preview
yolo recognition output image location:
xxxxxxxxxx/root/ultralytics/ultralytics/output/bus_output.jpg

Example code:
xfrom ultralytics import YOLO# Load a modelmodel = YOLO("/root/ultralytics/ultralytics/yolo11n.pt")# Run batched inference on a list of imagesresults = model("/root/ultralytics/ultralytics/assets/bus.jpg") # return a list of Results objects# Process results listfor result in results: boxes = result.boxes # Boxes object for bounding box outputs # masks = result.masks # Masks object for segmentation masks outputs # keypoints = result.keypoints # Keypoints object for pose outputs # probs = result.probs # Probs object for classification outputs # obb = result.obb # Oriented boxes object for OBB outputs result.show() # display to screen result.save(filename="/root/ultralytics/ultralytics/output/bus_output.jpg") # save to disk2. Object Detection: Video
Use yolo11n.pt to predict videos in the ultralytics project (not videos that come with ultralytics).
Enter the code folder:
xxxxxxxxxxcd /root/ultralytics/ultralytics/yahboom_demo
Run the code:
xxxxxxxxxxpython3 01.detection_video.py