Main Content

Object Detection

Perform classification, object detection, transfer learning using convolutional neural networks (CNNs, or ConvNets), create customized detectors

Object detection is a computer vision technique for locating instances of objects in images or videos. Object detection algorithms typically leverage machine learning or deep learning to produce meaningful results. When looking at images or video, humans can recognize and locate objects of interest in a matter of moments. The goal of object detection is to replicate this intelligence using a computer. The best approach for object detection depends on your application and the problem you are trying to solve.

Deep learning techniques require a large number of labeled training images, so the use of a GPU is recommended to decrease the time needed to train a model. Deep learning-based approaches to object detection use convolutional neural networks (CNNs or ConvNets), such as R-CNN and YOLO, or use single-shot detection (SSD). You can train a custom object detector, or use a pretrained object detector by leveraging transfer learning, an approach that enables you to start with a pretrained network and then fine-tune it for your application. Convolutional neural networks require Deep Learning Toolbox™. Training and prediction are supported on a CUDA®-capable GPU. Use of a GPU is recommended and requires Parallel Computing Toolbox™. For more information, see Einstellungen der Computer Vision Toolbox and Parallel Computing Support in MathWorks Products (Parallel Computing Toolbox).

Machine learning techniques for object detection include aggregate channel features (ACF), support vector machines (SVM) classification using histograms of oriented gradient (HOG) features, and the Viola-Jones algorithm for human face or upper-body detection. You can choose to start with a pretrained object detector or create a custom object detector to suit your application.

Labeled boats, neural network, and person detector


Image LabelerLabel images for computer vision applications
Video LabelerLabel video for computer vision applications


alle erweitern

Deep Learning Detectors

rcnnObjectDetectorDetect objects using R-CNN deep learning detector
fastRCNNObjectDetectorDetect objects using Fast R-CNN deep learning detector
fasterRCNNObjectDetectorDetect objects using Faster R-CNN deep learning detector
ssdObjectDetectorDetect objects using SSD deep learning detector (Seit R2020a)
yolov2ObjectDetectorDetect objects using YOLO v2 object detector (Seit R2019a)
yolov3ObjectDetectorDetect objects using YOLO v3 object detector (Seit R2021a)
yolov4ObjectDetectorDetect objects using YOLO v4 object detector (Seit R2022a)
solov2Segment objects using SOLOv2 instance segmentation network (Seit R2023b)
maskrcnnDetect objects using Mask R-CNN instance segmentation (Seit R2021b)
ocrRecognize text using optical character recognition

Feature-based Detectors

readAprilTagDetect and estimate pose for AprilTag in image (Seit R2020b)
readBarcodeDetect and decode 1-D or 2-D barcode in image (Seit R2020a)
acfObjectDetectorDetect objects using aggregate channel features
peopleDetectorACFDetect people using aggregate channel features
vision.CascadeObjectDetectorDetect objects using the Viola-Jones algorithm
vision.ForegroundDetectorForeground detection using Gaussian mixture models
vision.PeopleDetectorDetect upright people using HOG features
vision.BlobAnalysisProperties of connected regions

Detect Objects Using Point Features

detectBRISKFeaturesDetect BRISK features
detectFASTFeaturesDetect corners using FAST algorithm
detectHarrisFeaturesDetect corners using Harris–Stephens algorithm
detectKAZEFeaturesDetect KAZE features
detectMinEigenFeaturesDetect corners using minimum eigenvalue algorithm
detectMSERFeaturesDetect MSER features
detectORBFeaturesDetect ORB keypoints (Seit R2019a)
detectSIFTFeaturesDetect scale invariant feature transform (SIFT) features (Seit R2021b)
detectSURFFeaturesDetect SURF features
extractFeaturesExtract interest point descriptors
matchFeaturesFind matching features

Select Detected Objects

selectStrongestBboxSelect strongest bounding boxes from overlapping clusters using nonmaximal suppression (NMS)
selectStrongestBboxMulticlassSelect strongest multiclass bounding boxes from overlapping clusters using nonmaximal suppression (NMS

Load Training Data

boxLabelDatastoreDatastore for bounding box label data (Seit R2019b)
groundTruthGround truth label data
imageDatastoreDatastore for image data
objectDetectorTrainingDataCreate training data for an object detector
ocrTrainingOptionsOptions for training OCR model (Seit R2023a)
combineCombine data from multiple datastores (Seit R2019a)

Train Feature-Based Object Detectors

trainACFObjectDetectorTrain ACF object detector
trainCascadeObjectDetectorTrain cascade object detector model
trainImageCategoryClassifierTrain an image category classifier

Train Deep Learning Based Object Detectors

trainRCNNObjectDetectorTrain an R-CNN deep learning object detector
trainFastRCNNObjectDetectorTrain a Fast R-CNN deep learning object detector
trainFasterRCNNObjectDetectorTrain a Faster R-CNN deep learning object detector
trainSSDObjectDetectorTrain an SSD deep learning object detector (Seit R2020a)
trainYOLOv2ObjectDetectorTrain YOLO v2 object detector (Seit R2019a)
trainYOLOv4ObjectDetectorTrain YOLO v4 object detector (Seit R2022a)
trainSOLOV2Train SOLOv2 network to perform instance segmentation (Seit R2023b)
trainMaskRCNNTrain Mask R-CNN network to perform instance segmentation (Seit R2022a)
ocrTrainingOptionsOptions for training OCR model (Seit R2023a)
trainOCRTrain OCR model to recognize text in image (Seit R2023a)
quantizeOCRQuantize OCR model (Seit R2023a)

Augment and Preprocess Training Data for Deep Learning

balanceBoxLabelsBalance bounding box labels for object detection (Seit R2020a)
bboxcropCrop bounding boxes (Seit R2019b)
bboxeraseRemove bounding boxes (Seit R2021a)
bboxresizeResize bounding boxes (Seit R2019b)
bboxwarpApply geometric transformation to bounding boxes (Seit R2019b)
bbox2pointsConvert rectangle to corner points list
imwarpApply geometric transformation to image
imcropCrop image
imresizeResize image
randomAffine2dCreate randomized 2-D affine transformation (Seit R2019b)
centerCropWindow2dCreate rectangular center cropping window (Seit R2019b)
randomWindow2dRandomly select rectangular region in image (Seit R2021a)
integralImageCalculate 2-D integral image

R-CNN (Regions With Convolutional Neural Networks)

rcnnBoxRegressionLayerBox regression layer for Fast and Faster R-CNN
fasterRCNNLayersCreate a faster R-CNN object detection network (Seit R2019b)
rpnSoftmaxLayerSoftmax layer for region proposal network (RPN)
rpnClassificationLayerClassification layer for region proposal networks (RPNs)
regionProposalLayerRegion proposal layer for Faster R-CNN
roiAlignLayerNon-quantized ROI pooling layer for Mask-CNN (Seit R2020b)
roiInputLayerROI input layer for Fast R-CNN
roiMaxPooling2dLayerNeural network layer used to output fixed-size feature maps for rectangular ROIs
roialignNon-quantized ROI pooling of dlarray data (Seit R2021b)

YOLO v2 (You Only Look Once version 2)

yolov2LayersCreate YOLO v2 object detection network (Seit R2019a)
yolov2TransformLayerCreate transform layer for YOLO v2 object detection network (Seit R2019a)
yolov2OutputLayerCreate output layer for YOLO v2 object detection network (Seit R2019a)
spaceToDepthLayerSpace to depth layer (Seit R2020b)

Focal Loss Layers

focalLossLayerCreate focal loss layer using focal loss function (Seit R2020a)
focalCrossEntropyCompute focal cross-entropy loss (Seit R2020b)

SSD (Single Shot Detector)

ssdMergeLayerCreate SSD merge layer for object detection (Seit R2020a)

Anchor Boxes

estimateAnchorBoxesEstimate anchor boxes for deep learning object detectors (Seit R2019b)
cuboid2imgProject cuboids from 3-D world coordinates to 2-D image coordinates (Seit R2022b)
insertObjectAnnotationAnnotate truecolor or grayscale image or video
insertObjectMask Insert masks in image or video stream (Seit R2020b)
insertShapeInsert shapes in image or video
showShapeDisplay shapes on image, video, or point cloud (Seit R2020b)
evaluateObjectDetectionEvaluate object detection data set against ground truth (Seit R2023b)
objectDetectionMetricsObject detection quality metrics (Seit R2023b)
evaluateInstanceSegmentationEvaluate instance segmentation data set against ground truth (Seit R2022b)
instanceSegmentationMetricsInstance segmentation quality metrics (Seit R2022b)
bboxOverlapRatioCompute bounding box overlap ratio
bboxPrecisionRecallCompute bounding box precision and recall against ground truth
evaluateOCREvaluate OCR results against ground truth (Seit R2023a)
evaluateDetectionMissRate(To be removed) Evaluate miss rate metric for object detection
evaluateDetectionPrecision(To be removed) Evaluate precision metric for object detection
evaluateDetectionAOS(To be removed) Evaluate average orientation similarity metric for object detection (Seit R2020a)


Deep Learning Object DetectorDetect objects using trained deep learning object detector (Seit R2021b)


Get Started

Training Data for Object Detection and Instance Segmentation

Get Started With Deep Learning

  • Deep Network Designer (Deep Learning Toolbox)
  • List of Deep Learning Layers (Deep Learning Toolbox)
    Discover all the deep learning layers in MATLAB®.
  • Deep Learning in MATLAB (Deep Learning Toolbox)
    Discover deep learning capabilities in MATLAB using convolutional neural networks for classification and regression, including pretrained networks and transfer learning, and training on GPUs, CPUs, clusters, and clouds.
  • Pretrained Deep Neural Networks (Deep Learning Toolbox)
    Learn how to download and use pretrained convolutional neural networks for classification, transfer learning and feature extraction.