主要内容

本页采用了机器翻译。点击此处可查看英文原文。

目标检测

使用 YOLO 和 Grounding DINO 等预训练 AI 模型标注真实值和检测目标,使用迁移学习创建自定义检测器

Computer Vision Toolbox™ 提供了一套全面的工具和函数,用于使用深度学习和传统计算机视觉技术来构建、训练、评估和部署目标检测模型。您可以首先使用图像标注器视频标注器创建标注真实值,它们支持对图像和视频帧中的目标进行交互式和 AI 辅助的边界框注解。

获得标注数据后,您可以从多种预训练深度学习目标检测器中进行选择,包括 YOLO v2、YOLO v3、YOLO v4、YOLOX、RTMDet、SSD 和 Grounding DINO。工具箱还包含 peopleDetectorfaceDetector 等专用检测器,用于人体和人脸识别任务。您可以直接使用这些模型进行推断,也可以将其作为迁移学习的起点,从而能够针对特定领域的数据集自定义检测器。有关详细信息,请参阅使用深度学习入门目标检测。对于经典目标检测方法,工具箱支持聚合通道特征 (ACF) 和级联 (Viola-Jones) 目标检测器。

工具箱提供了使用迁移学习训练目标检测器的函数。工具箱还提供了用于管理和预处理训练数据的功能以及数据增强工具。通过模拟真实世界中的各种变化,这些工具有助于确保模型得到稳健训练。有关详细信息,请参阅Get Started with Image Preprocessing and Augmentation for Deep Learning

使用预训练或自定义模型生成检测结果后,您可以使用目标检测器分析器将检测结果与真实值数据进行对比。该 App 支持支持在一系列交并比 (IOU) 阈值下评估关键性能度量,如混淆矩阵、精确率、召回率、F1 分数和平均精度均值 (mAP)。或者,您也可以使用 evaluateObjectDetection 函数以编程方式计算检测性能度量。有关详细信息,请参阅Evaluate Object Detector PerformanceGet Started with Object Detector Analyzer App

Three images: the first contains labeled boats, the second a diagram of a neural network, and the third the keypoints from a person detector overlaid on the image of the people it has detected.

App

图像标注器为计算机视觉应用标注图像
视频标注器Label video for computer vision applications
目标检测器分析器Interactively visualize and evaluate object detection results against ground truth (自 R2026a 起)

函数

全部展开

深度学习检测器

groundingDinoObjectDetectorDetect and localize objects using Grounding DINO object detector (自 R2026a 起)
rtmdetObjectDetectorDetect objects using RTMDet object detector (自 R2024b 起)
ssdObjectDetectorDetect objects using SSD deep learning detector
yolov2ObjectDetectorDetect objects using YOLO v2 object detector
yolov3ObjectDetectorDetect objects using YOLO v3 object detector
yolov4ObjectDetector使用 YOLO v4 目标检测器检测目标 (自 R2022a 起)
yoloxObjectDetector使用 YOLOX 目标检测器检测目标 (自 R2023b 起)
peopleDetectorDetect people using pretrained deep learning object detector (自 R2024b 起)
faceDetectorDetect faces using pretrained RetinaFace face detector (自 R2025a 起)
detectTextCRAFTDetect texts in images by using CRAFT deep learning model (自 R2022a 起)
imfindcirclesYOLOFind circles using YOLOX object detector (自 R2026a 起)

基于特征的检测器

acfObjectDetectorDetect objects using aggregate channel features
peopleDetectorACF利用聚合通道特征检测人员
vision.CascadeObjectDetectorDetect objects using the Viola-Jones algorithm
vision.ForegroundDetectorForeground detection using Gaussian mixture models
vision.BlobAnalysisProperties of connected regions

选择检测到的目标

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

加载训练数据

boxLabelDatastoreDatastore for bounding box label data
groundTruthGround truth label data
imageDatastore图像数据的数据存储
objectDetectorTrainingDataCreate training data for an object detector
combine合并来自多个数据存储的数据

训练基于深度学习的目标检测器

trainSSDObjectDetectorTrain SSD deep learning object detector
trainYOLOv2ObjectDetectorTrain YOLO v2 object detector
trainYOLOv3ObjectDetectorTrain YOLO v3 object detector (自 R2024a 起)
trainYOLOv4ObjectDetectorTrain YOLO v4 object detector (自 R2022a 起)
trainYOLOXObjectDetectorTrain YOLOX object detector (自 R2023b 起)

训练基于特征的目标检测器

trainACFObjectDetectorTrain ACF object detector
trainCascadeObjectDetectorTrain cascade object detector model

增强和预处理用于深度学习的训练数据

balanceBoxLabelsBalance bounding box labels for object detection
bboxcropCrop bounding boxes
bboxeraseRemove bounding boxes
bboxresizeResize bounding boxes
bboxwarp对边界框应用几何变换
bbox2pointsConvert rectangle to corner points list
blockLocationsWithROISelect image block locations that contain bounding box ROIs (自 R2025a 起)
imwarp对图像应用几何变换
imcrop裁剪图像
imresize调整图像大小
randomAffine2dCreate randomized 2-D affine transformation
centerCropWindow2dCreate rectangular center cropping window
randomWindow2dRandomly select rectangular region in image
integralImageCalculate 2-D integral image
transform变换数据存储

R-CNN(基于卷积神经网络的区域)

roiAlignLayerNon-quantized ROI pooling layer for Mask-CNN
roiMaxPooling2dLayerNeural network layer used to output fixed-size feature maps for rectangular ROIs
roialignNon-quantized ROI pooling of dlarray data (自 R2021b 起)

YOLO v2(you only look once 版本 2)

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

焦点损失

focalCrossEntropyCompute focal cross-entropy loss

SSD(单次检测器)

ssdMergeLayerCreate SSD merge layer for object detection

锚框

estimateAnchorBoxesEstimate anchor boxes for deep learning object detectors
evaluateObjectDetectionEvaluate object detection data set against ground truth (自 R2023b 起)
objectDetectionMetricsObject detection quality metrics (自 R2023b 起)
mAPObjectDetectionMetricMean average precision (mAP) metric for object detection (自 R2024a 起)
bboxOverlapRatioCompute bounding box overlap ratio
bboxPrecisionRecallCompute bounding box precision and recall against ground truth
driseExplain object detection network predictions using D-RISE (自 R2024a 起)
cuboid2imgProject cuboids from 3-D world coordinates to 2-D image coordinates (自 R2022b 起)
insertObjectAnnotationAnnotate truecolor or grayscale image or video
insertObjectMask Insert masks in image or video stream
insertShape在图像或视频中插入图形
insertText在图像或视频中插入文字
showShapeDisplay shapes on image, video, or point cloud

模块

Deep Learning Object Detector使用经过训练的深度学习目标检测器检测目标 (自 R2021b 起)

主题

为目标检测创建真实值和训练数据

使用预训练检测器检测目标

评估目标检测结果

精选示例