Description
Describe the feature and motivation
Proposal: Add a Utility Class for Object Detection Inference and Annotation
I propose to add a utility class named ObjectDetection under a new or existing module (e.g., objdetect) in OpenCV that simplifies the pipeline for:
Running object detection using a provided model
Annotating the prediction results on images or video
🎯 Key Features:
Accepts a pre-trained model (OpenCV cv2.dnn, ONNX, PyTorch, etc.)
Accepts image(s) or video stream as input
Automatically handles:
Inference
Drawing bounding boxes
Overlaying class labels and confidence scores
Outputs annotated image or video
🧩 Motivation:
Many users (especially beginners or prototyping engineers) perform object detection and then manually write repetitive code to draw results using OpenCV primitives like cv2.rectangle and cv2.putText. A clean abstraction that integrates model inference and result annotation would:
Improve productivity
Encourage best practices (e.g., consistent styling, confidence thresholding)
Reduce boilerplate code in object detection applications
🏗️ Possible Extension:
Built-in color mapping for labels
Optional saving/display of output
Confidence thresholding
Format-agnostic support (accepting detection outputs from YOLO, SSD, etc.)
I’d love to hear your thoughts on whether this feature aligns with OpenCV’s direction. If approved, I’m happy to begin working on a prototype and PR under guidance.
Additional context
No response