All guides

What Is Object Detection? How It Works, Models and Cost

By Iu Ayala 15 min read Updated Published

Object detection is the computer vision task of finding the objects in an image or a video frame and saying what each one is. A detection model returns a box around every object it finds, a label such as “person” or “forklift”, and a confidence score. It tells you what is there, where, and how many.

We build object detection systems for a living, among them weapon detection that runs on more than 1,000 CCTV cameras. This guide covers how it works, where it fails and what it costs to build.

What is object detection?

You give the model an image. For every object it recognises, it gives back three things:

  • a bounding box: four numbers that place a rectangle round the object,
  • a class, the label: what the object is, chosen from the list the model was trained on,
  • a confidence score between 0 and 1: how sure the model is.

That is all a detector does. It does not know that a person is trespassing, that a shelf needs restocking or that a queue is too long. Ordinary code makes those decisions from the boxes: count them, check whether one is inside a marked zone, compare this frame with the last. When a product says it “detects loitering”, a detector found a person and a rule noticed that the box stayed in one place for two minutes.

The class list is fixed when the model is trained. A model you download free has usually been trained on COCO, a public dataset of 80 everyday classes such as person, car, dog and chair. To detect anything else (a weapon, a weld defect, your own product) you train it further on labelled pictures of that thing.

Object detection vs classification, segmentation and tracking

These four tasks are often sold under one name, and they answer different questions. Here is one camera frame read by each. Pick a tab, or let it play. The table below adds two more, pose estimation and anomaly detection.

One camera frame with 3 people, read four ways. Classification returns a single label for the whole frame: person. Object detection returns 3 boxes, each with the class person and a confidence score. Segmentation returns the exact pixels of each person. Tracking runs detection on every frame and joins the boxes so each person keeps the same number as they move.

  • The one label the model returns for the frame
The same frame read by four kinds of computer vision model. The scores are illustrative. People are drawn to scale for a camera 2.2 m up with a 2.8 mm lens.
TaskWhat the model returnsUse it for
Image classificationOne label for the whole imageIs this part good or faulty? Is there a person in this photo?
Object detectionA box, a label and a score for each objectHow many, where, and which kind
Instance segmentationThe exact pixels of each objectMeasuring area or shape, robots that grip, cutting an object out
Pose estimationBody joints (or other key points) for each objectFalls, posture, how a person or a machine arm is positioned
Object trackingThe same boxes with an ID that persists between framesCounting, dwell time, direction, speed
Anomaly detectionA score for how unusual the image isDefects you cannot list in advance

These are the main kinds of computer vision models, and object detection is the one most camera products are built on. Pick the simplest task that answers your question. Classification needs the least labelling and the smallest model, so if all you need is “is the bay empty or full”, do not pay for boxes. Segmentation labels are outlines traced by hand, which take far longer to draw than boxes, so use it only when the outline matters.

“Object recognition” and “image recognition” are looser terms. People use them for classification, for detection, or for both together. If a supplier uses either, ask which of the rows above the product returns.

How does object detection work?

A modern detector is a neural network: a long chain of arithmetic whose numbers were set by showing it many labelled examples. In training, the network is shown an image, makes its guess at the boxes, and is corrected towards the boxes a person drew. After enough images it draws good boxes on pictures it has never seen. Nobody writes rules for what a person looks like.

Papers describe the network in three parts. The backbone turns pixels into features. The neck combines features from coarse and fine scales, so large and small objects are both represented. The head turns those features into boxes, classes and scores.

When it runs, each image goes through these steps:

  1. Resize. The frame is shrunk to the size the model expects, commonly 640 pixels wide.
  2. Predict. The network turns the pixels into features (edges, then textures, then parts, then whole objects) and predicts candidate boxes with a class and a score.
  3. Filter. Boxes below a confidence threshold are dropped. Many models then run non-maximum suppression (NMS), a clean-up step that deletes duplicate boxes on the same object.

The designs differ in how they get from pixels to boxes:

DesignHow it finds objectsWhere it stands
Two-stage R-CNN (2013), Faster R-CNN (2015)Proposes regions that might hold an object, then classifies each one.Accurate but slow. Still common in research and medical imaging.
One-stage YOLO (2015), SSD (2015)Predicts every box and label in a single pass over the image.The default for live video and small computers.
Transformer DETR (2020), RT-DETR (2023), RF-DETR (2025)Asks a fixed set of questions of the image and returns one box per object, with no clean-up step.Now the most accurate at real-time speed on a GPU.
Open-vocabulary Grounding DINO (2023), YOLO-World, YOLOETakes a text prompt (“forklift”, “red helmet”) and looks for that, with no training.Good for trying an idea and for labelling data. Slower and less exact than a trained model.

Speed is what separated them. The Faster R-CNN paper reported 5 frames a second on a GPU (a graphics card, the chip these models run fastest on). The first YOLO paper, published four days later in June 2015, reported 45, and that made detection on live video practical. DETR brought the transformer, the design behind language models, to detection in 2020, and its descendants now run in real time.

Open-vocabulary models are the newest kind. You type what to look for and the model finds it without any training. Grounding DINO scored 52.5 out of 100 on the COCO benchmark (the AP score explained below) without seeing a single COCO training image, close to the 52.9 of a large YOLO trained on COCO that year. Large AI assistants that accept images can also return boxes when asked. Both are slow and expensive per image next to a small trained detector, and they are less consistent on unusual objects. Use them to test whether an idea is feasible and to draft labels, then train a small model for the real job.

Before deep learning, detectors were built from hand-written features and a simple classifier slid across the image: the Viola-Jones face detector of 2001 and HOG pedestrian detectors are the best known. The face boxes on digital cameras of the 2000s worked that way. Those methods still run where the object is rigid and the lighting is controlled, but they do not cope with the variety of a street or a warehouse.

Object detection models: YOLO, RF-DETR and which to consider

You rarely design a model. You pick a published family, choose a size, and train it on your data. As of 30 November 2026 these are the ones we would shortlist:

ModelLicenceConsider it when
YOLO26 UltralyticsAGPL-3.0 (publish your source), or a paid licenceYou want the best tooling and documentation, or you run on a CPU or a small device
RF-DETR RoboflowApache 2.0 (free in closed products; nano to large sizes)You have a GPU and want the most accuracy in a closed product
D-FINE USTCApache 2.0The same case as RF-DETR, plus a very small size for weak hardware
YOLOv10 Tsinghua; our AngelCVAGPL-3.0 original, Apache 2.0 in AngelCVYou want a YOLO with no NMS step and a permissive licence
Grounding DINO, YOLOE open vocabularyVariesYou are testing an idea or drafting labels, not shipping

Each family comes in sizes from nano to extra large. A bigger size is more accurate and slower, and the published figures show the size you pick moving accuracy more than the version does. Our comparison of every YOLO version has the accuracy and speed of each size, with RF-DETR and D-FINE set beside them.

Check the licence before you write code. The Ultralytics models are AGPL-3.0, which asks a closed commercial product to publish its source or buy a licence. Our guide to which YOLO versions you can use commercially goes through each one. That licence is the reason we wrote AngelCV, our own Apache 2.0 implementation of YOLOv10, for a client's product.

How object detection accuracy is measured

“Our model is 95% accurate” means nothing until you know which number it is. A detector can be wrong in two ways: it can miss an object, or it can draw a box where there is none. Two figures keep those apart.

  • Recall: of the objects really there, the share the model found. Low recall means misses.
  • Precision: of the boxes the model drew, the share that are right. Low precision means false alarms.

You trade one for the other with a single setting, the confidence threshold. The model scores every candidate box, and you choose the score below which boxes are thrown away. In the frame below, a detector looking for people has scored four people, a bollard and a wheelie bin. Drag the threshold, or watch it sweep.

A camera frame with 4 people, a bollard and a wheelie bin. The detector gives every one of them a confidence score for the class person: the people score 0.93, 0.86, 0.71, 0.44 from nearest to farthest, the bollard 0.58 and the bin 0.36. Because the bollard scores higher than the farthest person, no confidence threshold keeps every person and drops every false box: a low threshold finds everyone and adds false boxes, a high one removes the false boxes and misses people.

0.93
0.58
0.86
0.36
0.71
MISSED
0.25 usual default
← keep more boxeskeep fewer →
threshold
0.50
recall: people found
75%
precision: boxes that are right
75%
  • Person, kept
  • False box kept, or a person missed
  • False box thrown away
Each number on a box is the model's confidence that the thing is a person. The scores are illustrative, chosen to show the usual pattern: confidence falls with distance, and some lookalike scores higher than the hardest real case. Everything is drawn to scale for a 4MP camera 2.2 m up with a 2.8 mm lens.

No position of the slider gets everything right, because the bollard scores higher than the farthest person. That is normal. The threshold cannot fix a model that ranks a lookalike above a real object. Only better training data can. So choose the threshold from what a mistake costs you. A weapon detector should lean towards recall and send its doubtful boxes to a person to check. A system that sounds a siren should lean towards precision. Ultralytics ships its models with a default threshold of 0.25, which suits a demo more than it suits either of those.

IoU, AP and mAP

Published benchmarks add their own terms:

  • IoU (intersection over union) measures how well a predicted box overlaps the true one, from 0 (no overlap) to 1 (identical). A box usually counts as correct at an IoU of 0.5 or more.
  • AP (average precision) is precision averaged over every recall level, so it sums up every threshold setting in one score from 0 to 100.
  • mAP (mean average precision) is AP averaged over all the classes. COCO's own evaluation rules “make no distinction between AP and mAP”, and nor do most papers.

Three predicted boxes over the same hand-drawn box round a person. A box with an IoU of 0.30 counts as correct at 0 of the 10 IoU levels. A box with an IoU of 0.50 counts as correct at 1 of the 10 IoU levels. A box with an IoU of 0.85 counts as correct at 8 of the 10 IoU levels. IoU is the area the two boxes share divided by the area they cover together.

0.30 a miss at every level

0.50 correct at 1 of the 10 levels

0.85 correct at 8 of the 10 levels

  • Box a person drew
  • Predicted box, close enough to count
  • Predicted box, too far off
IoU is the area the two boxes share divided by the area they cover together. The levels are the ten that COCO averages for mAP50-95: 0.50, 0.55 and so on up to 0.95.

Two versions of mAP are quoted, and they differ a lot. mAP50 counts a box as correct at an IoU of 0.5. mAP50-95, the main COCO score, averages over ten IoU levels from 0.5 to 0.95, so it also rewards tight boxes. The same model scores far lower on the second: YOLOv8-L scores 69.8 on COCO at mAP50 and 52.9 at mAP50-95. When a supplier quotes one number, ask which it is, and on whose images.

That last question matters most. A benchmark score tells you how a model does on the benchmark. Our weapon detection for Angel Protection reaches 97.3% detection accuracy, and that figure describes that system on its cameras. It says nothing about how the same model would do on yours. The only accuracy figure worth trusting for your project is one measured on your own footage, on frames the model never saw in training.

Why small and distant objects are missed

The most common reason a detector misses something is that the object is too small in the picture. COCO splits its scores by object size, and the gap is wide. In the table published with the RT-DETR paper, YOLOv8-L scores 69.8 on large objects, 58.3 on medium ones and 35.3 on small ones. COCO's own rules call an object small when its area is under 32 × 32 pixels, and say about 41% of the objects in the dataset are that small.

You can see it in a real frame. We ran the small pre-trained YOLO26 on this photo of a busy crossing, at its default settings:

Night photo of a pedestrian crossing. A cyan box labelled person 0.88 surrounds a man walking in the foreground and another marks his handbag at 0.41. Of the dozens of people waiting on the far pavement, three have cyan boxes scoring 0.26 to 0.31 and the rest have thin amber outlines or none.
Real output of YOLO26s. Cyan: boxes kept at the default threshold of 0.25. Amber: people the model scored below it. Photo: “Shibuya Scramble Crossing” by Yoshikazu Takada, CC BY 2.0, cropped, boxes added by us.

The man in the foreground scores 0.88 and his bag 0.41. Of the dozens of people across the road, the model keeps 3, none scoring above 0.31. It drew 25 more person boxes scoring between 0.05 and 0.25, some of them overlapping on the same figure, too low to keep without also keeping rubbish. The rest of the crowd got no box at all. Every one of those far figures is smaller than 32 × 32 pixels once the frame is at the model's 640-pixel input.

A camera frame is shrunk before the model sees it, so objects become small sooner than you would think. Here is a standing adult on a 4MP camera with a wide 2.8mm lens, a common kind on a building, once the frame is reduced to 640 pixels wide:

DistanceHeight in the 4MP frameSize the model seesCOCO size class
3 m833 px58 × 198 pxlarge YOLOv8-L scores 69.8
5 m500 px35 × 119 pxmedium YOLOv8-L scores 58.3
10 m250 px17 × 59 pxmedium YOLOv8-L scores 58.3
15 m167 px12 × 40 pxsmall YOLOv8-L scores 35.3
20 m125 px9 × 30 pxsmall YOLOv8-L scores 35.3
30 m83 px6 × 20 pxsmall YOLOv8-L scores 35.3

The table is our own geometry, for a person 1.7 m tall and 0.5 m wide and a lens that sees 54.7° top to bottom. The scores are the benchmark's averages over all 80 classes, so read them as a direction and not a forecast for people. We class by the area of the box. COCO counts only the pixels of the object itself, less than the box for a standing person, so the real cut-offs come sooner: on this camera a person is a “small object” by about 10 metres at the latest.

These are the fixes, in the order to try them:

  1. Give the model more pixels. Run it at 1,280 pixels wide, or cut the frame into tiles and run each one. Both cost computing time: four times the pixels takes roughly four times as long.
  2. Change the picture. A narrower lens or a camera nearer the subject is often cheaper than a bigger model.
  3. Train on the small cases. Add labelled examples of the object at the distance where it is missed.

Object detection in video: tracking and counting

A detector treats each frame as a separate photo. It has no idea that the person in this frame is the person from the last one. An object tracker adds that: it matches boxes between frames by position and appearance and gives each object an ID that persists. The Ultralytics package bundles several trackers, including ByteTrack and BoT-SORT, that sit on top of any of its detectors.

Most of the numbers a business wants come from tracked boxes. Counting people through a door is a tracked box crossing a line. Dwell time is how long an ID stays in a zone. Speed is how far a tracked box moves between frames. Our guide to people counters and footfall counters shows how a camera count is built that way and how accurate it gets.

You do not need to run the detector on every frame. Most cameras record 15 to 25 frames a second, and a person on foot moves very little in a fifth of a second, so a few detections a second are usually enough. For Angel Protection we went further. Cheap processors check each stream for movement, and only frames with movement reach the graphics card. That cut the hardware cost by 90% across 1,000+ cameras. The design is described in how we run weapon detection on 1,000 cameras.

What is object detection used for?

SectorWhat is detectedMore
Security and CCTVPeople and vehicles in the wrong place at the wrong time, weapons, left bagsvideo analytics on CCTV
Retail and venuesFootfall, queue length, empty shelvespeople counters compared
Warehouses and logisticsParcels, pallets and forklifts, people in vehicle laneswarehouse case study
ManufacturingMissing parts, defects, wrong labels on a linevision for quality control
Construction and industryHard hats and hi-vis, people near plant, perimeter breachesperimeter detection
Vehicles and robotsPedestrians, vehicles, obstacles, wavesunmanned boats

The same technique reads medical scans for tumours and fractures, counts fruit and spots weeds on farms, and follows players and the ball in sport.

The projects that work have these in common. The object is visible to a person looking at the same picture. There is a clear action to take when it appears. And a mistake is affordable, either because a person checks the alert or because the count only needs to be roughly right. If a trained person cannot tell from the image, a model will not either.

What you need to build an object detector

If your object is one of COCO's 80 classes (people, cars, lorries, bags, common animals) a pre-trained model works from the first minute. With Python installed, this finds the people in a photo:

pip install ultralytics
from ultralytics import YOLO

model = YOLO("yolo26s.pt")
# class 0 is "person" in COCO
results = model(
    "yard.jpg",
    conf=0.4,
    classes=[0],
)

names = results[0].names
for box in results[0].boxes:
    print(
        names[int(box.cls)],
        float(box.conf),
        box.xyxy.tolist(),
    )

For anything else you train your own. That takes four things:

  1. Images from the real setting. Your cameras, your lighting, your angles, including night, rain and the awkward cases. Pictures from the internet teach the model the internet.
  2. Labels. A person draws a box round every object in every image. For a production model, Ultralytics recommends at least 1,500 images and 10,000 labelled objects per class. A few hundred images are enough to learn whether the idea works at all.
  3. Training. You start from a pre-trained model and carry on training it on your images (fine-tuning), which takes hours on one rented GPU, not weeks.
  4. A test you did not train on. Hold back footage from different days or sites, and measure precision and recall there.

The labelling and the test are where projects succeed or fail. We think careful labels and a few hundred more hard examples move the result further than swapping one current model for another.

What hardware does it run on?

Less than most people expect. Ultralytics reports its small YOLO26 at 87.2 milliseconds an image on a CPU, about 11 frames a second, and the nano at about 26. On an NVIDIA T4, a modest data-centre graphics card, the small model takes 2.5 milliseconds, so one card can serve many cameras. On one UK CCTV product we designed, where a video model spots trespass and violence, a single consumer graphics card (an RTX 5060 Ti) handles 15 to 20 cameras on site, and the footage never leaves the building.

What it costs: cloud API or your own model

For occasional photos, a cloud vision API is the cheapest way to detect common objects. Google Cloud Vision charges $2.25 per 1,000 images for object localisation after the first 1,000 each month. Amazon Rekognition charges $0.001 an image for the first million in a month and $0.0008 after that. A shop uploading 10,000 product photos a month pays about $20 with Google or $10 with Amazon (about £15 or £8).

Video changes the sum. One camera sending one frame a second produces 2,592,000 images in a 30-day month:

RouteOne camera, one frame a secondDetects
Google Cloud Vision$5,830 a month about £4,443Google's general object list
Amazon Rekognition$2,274 a month about £1,733Amazon's general label list
Your own model on your own hardwareThe hardware once, then electricityWhatever you trained it on

The sums are ours, from the two public price lists read on 30 November 2026, with pounds at $1 = £0.76 (European Central Bank reference rates, 27 November 2026). Both vendors also sell trainable and video-specific services at other rates, and you can cut the bill by sending fewer frames. But for cameras that run all day the comparison nearly always ends the same way: a per-image price loses to a computer you own. Running the model yourself also keeps your footage on your premises, which makes the data protection work simpler.

The cost of your own model is mostly people: collecting and labelling images, training, testing, and wiring the result into whatever acts on it. As a guide to scale, our computer vision feasibility study is £4,000 to £6,000 (about $5,200 to $7,900) and tells you whether the detection is achievable on your footage before you commit. A working first version is £15,000 to £20,000 (about $19,700 to $26,200) in four to six weeks, with the study credited against it. Our guide to running an AI proof of concept covers how to set the pass mark and how many test images you need.

Where object detection fails

  • Small objects. The first thing to check, for the reasons in why small and distant objects are missed.
  • Hidden objects. A person half behind a pillar, a part under another part. Crowds are hard for the same reason.
  • Conditions it never saw. A model trained on daytime footage does badly at night under infrared, in rain, or from a new camera angle. It gives no warning. It just misses more.
  • Lookalikes. A drill held like a pistol, a coat on a chair, a reflection in a window. Each needs examples in the training data labelled as “not the object”.
  • Things outside its list. A model trained on four classes will force a fifth kind of object into one of the four, or ignore it.
  • Meaning. A detector sees a person holding a bag. It does not see theft.

Every detector makes mistakes, so design for them. Decide who sees a doubtful alert, how quickly, and what a miss costs. If people can be identified in the footage, UK data protection law applies to it whatever the model does with it. Our guide to CCTV and UK GDPR covers what an operator has to do.

Object detection without a camera: sensors

If you only need to know that something is there, and not what it is, a sensor is cheaper and more reliable than a camera. A photoelectric beam tells a conveyor that a box has arrived. An ultrasonic sensor tells a car how far the wall is. Radar and lidar measure range directly and work in darkness, and radar works through fog and rain.

A camera earns its place when the system must tell one kind of object from another. Many machines combine the two. We have worked on that side too. For the UK Ministry of Defence we built radar-based navigation for a self-driving Humvee, accurate to under a metre where there is no GPS.

Questions

Can I use AI to identify an object?

Yes. For a single photo, Google Lens or any AI assistant that accepts images will name most everyday things. For a camera or a product that must do it thousands of times a day, use an object detection model, either a pre-trained one for common objects or one trained on your own images.

Why is YOLO used so much for object detection?

YOLO was the first object detection model fast enough for live video that was also far more accurate than the other real-time detectors of its day. It also comes in sizes small enough for a CPU, and the Ultralytics package makes training one a few lines of code. It is no longer the most accurate for its speed, but it has the most tutorials, tools and people who know it.

Which is better, OpenCV or YOLO?

They are different things. OpenCV is a library of image tools: reading video, resizing, colour, older detection methods. YOLO is a family of detection models. Most projects use both: OpenCV handles the video and a YOLO or DETR model finds the objects. That is why people still use OpenCV.

Can lidar do object detection?

Yes. Lidar measures the distance to every point it scans, so it finds objects by their shape and range, in darkness as well as daylight. It cannot read colour, text or fine detail, which is why vehicles and robots usually pair it with a camera.

Is YOLO free?

It is free to download. The Ultralytics versions are under AGPL-3.0, so a closed commercial product needs a paid licence or a model under a different licence. See our YOLO licence guide.

What is the difference between object detection and object tracking?

Detection finds the objects in one frame. Tracking links those detections from frame to frame so each object keeps an identity. You need detection for “is there a person”, and tracking for “how many people came in” or “how long did they stay”.

What is the difference between object detection and object recognition?

Detection says what the objects are and where. “Recognition” is used loosely: sometimes for naming the main thing in an image, which is classification, and sometimes for identifying a particular individual, as in facial recognition, which is a separate step that runs after a face has been detected.

How many images do I need to train an object detection model?

A few hundred labelled images will tell you whether it can work. For production, Ultralytics recommends at least 1,500 images and 10,000 labelled objects per class. Variety counts for more than volume: a thousand near-identical frames from one camera teach less than two hundred from different days, sites and lighting.

Which object detection model is best?

There is no single best. On a GPU, RF-DETR and D-FINE currently lead on accuracy for their speed. On a CPU or a small device, the nano and small YOLO26 models are hard to beat. Test two or three on your own images. Our guide to YOLO models and their rivals has the figures.

Does object detection need a GPU?

To train, in practice yes, though a rented one for a few hours is enough. To run, often not. A small model manages about 11 frames a second on a CPU in Ultralytics' own benchmark.

Sources