Ultralytics YOLO26 tutorial: store detections in SQLite

Learn to save YOLO26 detections and tracking data in SQLite, query summaries, and export object crops as JPEG files using Python.

Player not loading? Watch on YouTube

This Python tutorial builds a computer vision pipeline around Ultralytics YOLO26 and a local SQLite database. It follows detection results beyond the video overlay, storing records that applications can query later.

The database class creates a detections table with source and frame information, timestamps, class labels, confidence scores, bounding boxes and tracking IDs. It also stores image dimensions and object crops. A buffer collects records before committing them, with a default batch size of 200. Summary methods retrieve detection counts and average confidence scores, while an export method writes stored crops into JPEG files grouped by class.

The detection and tracking code accepts a video file or webcam input. The presenter explains where to substitute custom model weights, then walks through extracting results, cropping each object and encoding the crop as JPEG data for storage. Optional output includes tracking trails and an annotated video.

The example runs on traffic.mp4 and ends with the presenter reporting 4,200 stored track crops. The speaker describes the run as real time without slowdown; the supplied material gives no hardware specifications or benchmark measurements. Parking management and database access for an AI agent are suggested extensions rather than completed demonstrations.