- Introduced by
- Girshick, R. et al. (R-CNN); Redmon, J. et al. (YOLO)
- Year
- 2014–2016
- Type
- Supervised deep learning (region proposal or single-shot)
- Family
- Deep learning / NLP / CV
What does it do?
Object detection is a computer vision task in which a deep neural network simultaneously locates and classifies every instance of one or more object categories within an image, producing a bounding box and a class label for each detected object.
Two families dominate: two-stage detectors such as R-CNN and Faster R-CNN, which first propose candidate regions, and one-stage detectors such as YOLO, which predict boxes and classes in a single pass.
The intuition behind the method
Rather than answering only 'what is in this image?' like a classifier, an object detector also answers 'where is each object?' It scans the image, either by proposing candidate regions first (two-stage detectors like Faster R-CNN) or by dividing the image into a grid and predicting boxes directly (one-stage detectors like YOLO), and outputs a box with a class score for each detected object. Scores below a confidence threshold are discarded, and overlapping boxes for the same object are suppressed by non-maximum suppression, which keeps only the highest-scoring box.
History
Before deep learning, detectors relied on hand-crafted features applied with sliding windows, in which a classifier is evaluated at many image locations. Girshick et al. (2014) introduced R-CNN, which replaced hand-crafted features with CNN features computed on region proposals, and reported that supervised pre-training followed by domain-specific fine-tuning was effective when labelled data was scarce. Later two-stage systems moved region proposal into the network itself. YOLO (Redmon et al., 2016) showed that a single network could detect objects in one pass at real-time speed. Subsequent work addressed class imbalance in one-stage training and introduced transformer-based set prediction (DETR), which removes the need for NMS.
When to use it
Choose object detection when the question requires both how many objects there are and where they are, for example counting cells in microscopy, detecting pedestrians in video, or locating products on shelves. It needs bounding-box annotations for every object class, which are costly to produce; when labelled data is scarce, start from a detector pre-trained on a large dataset and fine-tune it, and validate on held-out images. Do not use object detection if image-level labels are enough (use image classification), or if you need pixel-accurate boundaries or areas (use instance segmentation). If your objects are very small or heavily occluded, check whether a boxed detector can resolve them before committing to full annotation.
Limitations and considerations
- Requires bounding-box annotated training data for each class, which is expensive and time-consuming to produce at scale.
- Training larger detectors demands substantial GPU memory and compute.
- Performance degrades on heavily occluded objects, very small objects and densely packed scenes, where boxes overlap or become ambiguous.
- The YOLO paper notes a trade-off: compared with region-based systems, it makes more localisation errors but predicts fewer false positives on background.
- Results are sensitive to anchor sizes, the confidence threshold and the NMS overlap threshold, which usually need tuning for the target domain.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- Localisation and classification are predicted together, so one network outputs boxes, class labels and confidence scores for each detected instance.
- One-stage detectors such as YOLO run in a single forward pass; the YOLO paper reports real-time processing of about 45 frames per second for its base model, which is why this design suits video.
- Pre-trained backbones and fine-tuning allow adaptation to a new domain from a modest labelled set, as the R-CNN work reports for scarce data.
- The number of detections is not fixed in advance: the detector returns as many boxes as pass the score threshold, so object counts per image need not be specified beforehand.
- Feature pyramid designs help the model detect objects across a range of scales within one image.
Applications
- Autonomous driving: detecting vehicles, pedestrians, traffic signs, and obstacles in real time.
- Medical imaging: localising tumours, polyps, or anatomical landmarks in radiology and pathology images.
- Industrial quality control: spotting defects or foreign objects on manufacturing lines.
- Wildlife and ecological monitoring: counting and classifying animals in camera-trap imagery.
- Retail and logistics: detecting products, barcodes, and inventory items from shelf or warehouse footage.
- Surveillance and security: detecting persons, vehicles, or anomalous events in CCTV streams.
How it works
How it works
A convolutional backbone (e.g., ResNet, EfficientNet) or a Vision Transformer processes the full input image and produces a spatial feature map that encodes edges, textures and higher-level patterns at several scales. Backbone weights are commonly initialised from a model pre-trained on ImageNet; the R-CNN work reports that supervised pre-training followed by domain-specific fine-tuning gave a significant performance gain when labelled data was scarce.
Two-stage detectors (R-CNN, Faster R-CNN) use a region proposal mechanism to generate candidate bounding boxes, and each candidate is then classified. One-stage detectors such as YOLO and SSD skip the separate proposal step and predict boxes and classes in a single forward pass over a spatial grid. DETR is a transformer-based set-prediction detector: it predicts a fixed set of objects from learned queries and is trained to avoid NMS post-processing, so its training setup differs from that of grid-based one-stage models.
Each candidate region or grid location predicts a probability distribution over the target categories plus a background class, and regresses four box parameters (centre x, centre y, width, height). The loss \mathcal{L} = \mathcal{L}_{cls} + \lambda \mathcal{L}_{box} adds a classification term and a box regression term, with λ weighting how strongly localisation error counts; localisation-sensitive variants such as GIoU loss modify the box term.
Formula
\mathcal{L} = \mathcal{L}_{cls} + \lambda \mathcal{L}_{box}Inference typically produces many overlapping boxes for the same object. Non-maximum suppression (NMS) keeps the box with the highest confidence score and removes any other box whose intersection-over-union with it exceeds a chosen threshold, leaving one detection per object instance. DETR-style models are designed to avoid this post-processing step.
Detection quality is measured with mean Average Precision (mAP). A predicted box counts as correct when its intersection-over-union (IoU) with a ground-truth box, the area of their intersection divided by the area of their union, reaches the chosen threshold. Predictions are matched to ground-truth objects in descending order of confidence, and each ground-truth object can be matched only once; the remaining predictions count as false positives. For each class, average precision (AP) is the area under the precision-recall curve obtained by sweeping the confidence threshold, and mAP is the mean of AP over all classes. This is computed at one or more IoU thresholds (on COCO, 0.5 and the 0.5:0.95 range). Because it summarises precision-recall trade-offs per class, mAP is more informative than overall accuracy when object classes and background are highly imbalanced.
Formula
\text{mAP} = \frac{1}{|C|}\sum_{c}\text{AP}_{c}Common pitfalls
- Evaluating only at a single IoU threshold (e.g., 0.5) and omitting the stricter 0.5:0.95 range used in COCO evaluation.
- Overlooking class imbalance: in two-stage detectors, background candidates far outnumber object candidates, so overall accuracy can look high while object detection is poor.
- Keeping default anchor configurations designed for natural images when detecting objects with very different aspect ratios, such as in aerial or medical imagery.
- Reporting detection scores without stating the confidence and NMS thresholds used, since these change precision and recall.
- Treating bounding boxes as masks; boxes do not give pixel-level object boundaries, so areas or exact shapes cannot be measured from them.
Frequently asked questions
Which detector should I choose — Faster R-CNN, YOLO, or DETR?
Two-stage detectors such as Faster R-CNN have historically been slower but more accurate for localisation in many benchmarks, whereas one-stage YOLO-family models are designed for fast inference and are commonly used when real-time or edge deployment is needed. DETR-style models detect objects without NMS but typically need longer training. The trade-off depends on the dataset and hardware, so benchmark candidate detectors on your own validation data.
How many annotated images do I need to train a detector?
Training from scratch needs far more annotated images than fine-tuning a pre-trained detector. With pre-trained weights, usable results can sometimes come from a comparatively small labelled set, but the required amount depends strongly on the dataset and task, so always validate on a held-out test set and check that performance is adequate for your purpose.
What is mAP and why is it the standard metric?
Mean Average Precision (mAP) summarises the precision-recall curve for each class at a given IoU threshold and averages it over all classes. Unlike accuracy, it accounts for both localisation quality (via IoU) and classification confidence, making it far more informative for the class-imbalanced, multi-object detection task.
Can object detection work on video?
Yes. Frame-by-frame detection with a fast model like YOLO is common, often combined with a multi-object tracker that assigns consistent IDs to objects across frames and reduces flickering detections.
When should I use instance segmentation instead?
When you need pixel-accurate object masks, for example to measure exact object boundaries, compute areas, or handle highly irregular shapes, use instance segmentation, which assigns a mask to each object (see the related instance segmentation page). Object detection with bounding boxes is sufficient when approximate location and count are the research goal.
Related methods
Sources
Girshick, R., Donahue, J., Darrell, T., & Malik, J. (2014). Rich feature hierarchies for accurate object detection and semantic segmentation. Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 580–587.
Open DOI referenceRedmon, J., Divvala, S., Girshick, R., & Farhadi, A. (2016). You Only Look Once: Unified, Real-Time Object Detection. Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 779–788.
Open DOI reference