Key takeaways
- Object detection underpins automation in driving, manufacturing, retail, healthcare and accessibility.
- YOLO predicts boxes and classes in one pass, which makes it fast enough for real-time video.
- OpenCV offers classical detectors and a DNN module for running exported deep models.
- Ultralytics and Roboflow cover labelling, training, evaluation and deployment for custom detectors.
- Ultralytics recommends about 1,500 images per class for best results, but prototypes need far fewer.
Object detection models locate and label objects in images, and building one has become accessible thanks to YOLO, OpenCV and labelling platforms such as Roboflow. The hard parts are now data and evaluation rather than code. I built FaceVision, which runs face detection in the browser with ONNX Runtime Web, so this page covers why detection matters, how YOLO works, key algorithms, OpenCV, YOLOv8, Roboflow, creating and training models, how many images you need, and a simple Arduino radar.
Why is object detection important?
Object detection lets machines understand where things are, not just what an image shows. That makes automation possible in driving assistance, manufacturing inspection, retail analytics, medical imaging, agriculture, security and accessibility tools.
Cars use detection to spot pedestrians and vehicles, factories to find defects on production lines, and farmers to count fruit or detect pests from drone images. Retailers monitor shelves, and accessibility apps describe surroundings for people with low vision. Detection is also the first step in many larger systems, such as tracking, counting, pose estimation and face recognition, where FaceVision detects faces before computing embeddings. Its importance grows as cameras become cheap and edge chips can run models in real time without the cloud.
How does YOLO work for object detection?
YOLO, short for You Only Look Once, processes the whole image in a single forward pass of one neural network, predicting bounding boxes and class probabilities together. This makes it fast enough for real-time video.
Also asked as: how yolo works for object detection
The original YOLO, by Redmon and colleagues, divided the image into a grid where each cell predicted boxes and classes. Modern versions use a backbone to extract features, a neck that combines features at several scales so small and large objects are both detected, and a head that predicts boxes directly, often without anchor boxes. Non-maximum suppression removes duplicates. Successive versions from different authors and Ultralytics improved accuracy, speed and training tricks such as mosaic augmentation, while keeping the single-pass design.
What are object detection algorithms?
Classical algorithms include Viola-Jones Haar cascades and HOG features with linear SVMs. Deep learning algorithms include two-stage detectors such as Faster R-CNN, one-stage detectors such as YOLO, SSD and RetinaNet, and transformer detectors such as DETR.
Haar cascades, from 2001, made real-time face detection possible on early hardware and still appear in OpenCV. HOG features with SVMs became standard for pedestrian detection. Deep learning took over after 2014, starting with R-CNN, which classified region proposals with a CNN. EfficientDet focused on efficiency across sizes, and RT-DETR brought transformers to real-time detection. Open-vocabulary detectors such as Grounding DINO detect objects described in text. For most practical projects today, a modern YOLO or RT-DETR model is the starting point.
How does OpenCV object detection work?
OpenCV offers several approaches: classical Haar cascade and HOG detectors, colour and contour-based detection for simple scenes, template matching, and a DNN module that runs pretrained deep learning models such as YOLO or SSD exported to ONNX.
Haar cascades slide a window over the image at multiple scales, applying simple features learned for faces or other objects; they are fast but less accurate. Colour thresholding and contours work well for controlled scenes, such as detecting a coloured ball. The DNN module loads a model, converts frames into input blobs, runs inference, then decodes boxes and applies non-maximum suppression. OpenCV also handles video capture, drawing boxes and image preprocessing, so it often pairs with dedicated detection libraries in real projects.
How do you use YOLOv8 for object detection?
Install the ultralytics package, load a pretrained model such as yolov8n.pt, and call it on an image, folder, video or webcam. The command line also works, using yolo detect predict with model and source arguments.
Also asked as: how to use yolov8 for object detection
For custom detection, prepare a dataset in YOLO format with images and text label files, write a YAML file listing class names and paths, and train with the train method, choosing epochs and image size. Validate to get mean average precision, then export to ONNX, TensorRT or other formats for deployment. YOLOv8 comes in sizes from nano to extra large, trading speed for accuracy. Newer Ultralytics versions such as YOLO11 use the same API, so upgrading is mostly a matter of changing the model name.
How do you use Roboflow for object detection?
Create a Roboflow project, upload images, label boxes with its annotation tools, including AI-assisted labelling, generate a dataset version with preprocessing and augmentation, then export it in YOLO or other formats, or train inside Roboflow.
Also asked as: how to use roboflow object detection
Roboflow Universe hosts many public datasets and pretrained models you can start from. After training, deploy models through Roboflow's hosted API or run them locally with the open-source Roboflow Inference server, including on edge devices. Its dataset health checks reveal class imbalance and annotation issues. Exporting to YOLO format lets you train with Ultralytics on your own GPU or Colab instead. Check plan limits and licensing for commercial projects, and keep a copy of your labelled data outside any single platform.
How do you create an object detection model?
Define the classes you need, collect diverse images of them in real conditions, label boxes consistently, split data into training, validation and test sets, fine-tune a pretrained detector, evaluate it, and iterate on failures.
Also asked as: how to create object detection model
Diversity matters more than volume: vary lighting, angles, backgrounds, distances and occlusions to match deployment. Write labelling guidelines so boxes are tight and consistent across annotators. Start with a small, fast model to validate the pipeline, then scale up if accuracy is insufficient. Review false positives and false negatives on the validation set, collect more examples of failure cases, and retrain. Finally, test on data from the actual deployment setting, such as the specific camera, since accuracy often drops in new conditions.
How are object detection models trained?
Models are trained with supervised learning on images labelled with boxes and classes. The network predicts boxes, a loss function compares them with ground truth, and an optimiser adjusts weights over many epochs to reduce that loss.
Losses combine classification terms for labels with box regression terms based on overlap, sometimes plus objectness. Training usually starts from weights pretrained on COCO, which speeds learning and reduces data needs. Augmentation such as mosaic, flips, scaling and colour changes improves robustness. Validation mean average precision is tracked each epoch, and training stops when it plateaus. GPUs make training practical, though small models can train on free Colab GPUs. Monitoring loss curves and sample predictions catches problems such as wrong labels early.
How many images do you need to train object detection?
It depends on the task and its variety. Ultralytics' training tips recommend at least 1,500 images and 10,000 labelled instances per class for best results, but useful prototypes can work with a few hundred images per class using pretrained models.
Also asked as: how many images to train object detection
Simple, consistent scenes, such as one product on a conveyor, need fewer images than varied outdoor environments. Rare classes need targeted collection, since imbalance makes models ignore them. Start with a few hundred labelled images, train, measure, then add images where the model fails rather than collecting blindly. Augmentation helps but does not replace real variety. Include background images without objects to reduce false positives. Track mean average precision per class as you add data, and stop when improvements level off.
How do you make an object detection radar?
The popular Arduino radar project mounts an ultrasonic sensor, such as the HC-SR04, on a servo that sweeps from side to side. The Arduino measures distance at each angle and sends readings to a computer that draws a radar-style display.
Also asked as: how to make object detection radar
The ultrasonic sensor sends sound pulses and times the echo to calculate distance, while the servo rotates step by step. The Arduino prints angle and distance over serial, and a Processing or Python sketch plots detected objects on a sweeping screen. Strictly, this is sonar, not radar, since it uses sound. True radar modules, such as millimetre-wave sensors, detect presence, motion and distance using radio waves and work through some materials. These projects teach sensors and signal timing, complementing camera-based detection with neural networks.
Sources
- Redmon et al., You Only Look Once: Unified, Real-Time Object Detectionarxiv.org
- Ultralytics, YOLOv8docs.ultralytics.com
- Ultralytics, Tips for best training resultsdocs.ultralytics.com
- Roboflow documentationdocs.roboflow.com
- OpenCV, Deep Neural Networks module tutorialsdocs.opencv.org
- Arduino documentationdocs.arduino.cc




