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 Préférences de 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


développer tout

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
yolov2ObjectDetectorDetect objects using YOLO v2 object detector
yolov3ObjectDetectorDetect objects using YOLO v3 object detector
yolov4ObjectDetectorDetect objects using YOLO v4 object detector
maskrcnnDetect objects using Mask R-CNN instance segmentation
ocrRecognize text using optical character recognition

Feature-based Detectors

readAprilTagDetect and estimate pose for AprilTag in image
readBarcodeDetect and decode 1-D or 2-D barcode in image
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
detectSIFTFeaturesDetect scale invariant feature transform (SIFT) features
detectSURFFeaturesDetect SURF features
extractFeaturesExtract interest point descriptors
matchFeaturesFind matching features

Select Detected Objects

selectStrongestBboxSelect strongest bounding boxes from overlapping clusters
selectStrongestBboxMulticlassSelect strongest multiclass bounding boxes from overlapping clusters

Load Training Data

boxLabelDatastoreDatastore for bounding box label data
groundTruthGround truth label data
imageDatastoreDatastore for image data
objectDetectorTrainingDataCreate training data for an object detector
ocrTrainingOptionsOptions for training OCR model
combineCombine data from multiple datastores

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
trainYOLOv2ObjectDetectorTrain YOLO v2 object detector
trainYOLOv4ObjectDetectorTrain YOLO v4 object detector
trainMaskRCNNTrain Mask R-CNN network to perform instance segmentation
ocrTrainingOptionsOptions for training OCR model
trainOCRTrain OCR model to recognize text in image
quantizeOCRQuantize OCR model

Augment and Preprocess Training Data for Deep Learning

balanceBoxLabelsBalance bounding box labels for object detection
bboxcropCrop bounding boxes
bboxeraseRemove bounding boxes
bboxresizeResize bounding boxes
bboxwarpApply geometric transformation to bounding boxes
bbox2pointsConvert rectangle to corner points list
imwarpApply geometric transformation to image
imcropCrop image
imresizeResize image
randomAffine2dCreate randomized 2-D affine transformation
centerCropWindow2dCreate rectangular center cropping window
randomWindow2dRandomly select rectangular region in image
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
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
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

YOLO v2 (You Only Look Once version 2)

yolov2LayersCreate YOLO v2 object detection network
yolov2TransformLayerCreate transform layer for YOLO v2 object detection network
yolov2OutputLayerCreate output layer for YOLO v2 object detection network
spaceToDepthLayerSpace to depth layer

Focal Loss Layers

focalLossLayerCreate focal loss layer using focal loss function
focalCrossEntropyCompute focal cross-entropy loss

SSD (Single Shot Detector)

ssdMergeLayerCreate SSD merge layer for object detection

Anchor Boxes

estimateAnchorBoxesEstimate anchor boxes for deep learning object detectors
cuboid2imgProject cuboids from 3-D world coordinates to 2-D image coordinates
insertObjectAnnotationAnnotate truecolor or grayscale image or video stream
insertObjectMask Insert masks in image or video stream
insertShapeInsert shapes in image or video
showShapeDisplay shapes on image, video, or point cloud
evaluateDetectionAOSEvaluate average orientation similarity metric for object detection
evaluateDetectionMissRateEvaluate miss rate metric for object detection
evaluateDetectionPrecisionEvaluate precision metric for object detection
bboxOverlapRatioCompute bounding box overlap ratio
bboxPrecisionRecallCompute bounding box precision and recall against ground truth
evaluateInstanceSegmentationEvaluate instance segmentation data set against ground truth
evaluateOCREvaluate OCR results against ground truth
instanceSegmentationMetricsInstance segmentation quality metrics


Deep Learning Object DetectorDetect objects using trained deep learning object detector


Get Started

Training Data for Object Detection and Semantic 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.