Ultralytics YOLO26 and OpenCV object tracking tutorial

Learn to select tracked objects with OpenCV mouse callbacks, then crop and resize them using a custom YOLO26 small drone model in Python.

Player not loading? Watch on YouTube

This Python tutorial builds an interactive object tracker with Ultralytics YOLO and OpenCV. A click inside a detected bounding box selects its tracking ID. The script then finds that ID in later results and displays a resized crop of the selected object in the video frame's top-right corner.

The walkthrough covers model initialization, video capture, mouse callbacks and the processing loop. The speaker explains that a base model or a custom trained model can supply detections, and that the input can be a video file, webcam or RTSP stream. NumPy slices the selected region, with padding to retain some surrounding context. The crop replaces pixels in the output frame rather than forming a transparent overlay. OpenCV displays the result, and a video writer can save it to an AVI file.

The title identifies YOLO26, and the later setup specifies a custom YOLO 26 small drone model, although the introduction says YOLOv8. The demonstration uses drone footage of vehicles and includes attempts to select different cars and trucks. The speaker suggests applying further analysis, such as number plate detection, to a selected crop; the tutorial does not implement that extension. It also gives no hardware requirements or tracking accuracy measurements.