主要内容

acfObjectDetector

使用聚合通道特性检测对象

描述

acfObjectDetectorobject使用聚合通道特征(ACF)对象检测器从图像中检测对象。若要在图像上使用ACF检测器,请将训练过的检测器传递给检测函数。

该ACF对象检测器识别图像中的特定对象,基于训练图像和对象地面真相位置使用trainACFObjectDetector函数。

创建

创建一个acfObjectDetector对象通过调用trainACFObjectDetector函数与训练数据。

检测器= trainACFObjectDetector(trainingData,…)

描述

例子

探测器= acfObjectDetector (分类器trainingOptions创建一个基于指定预训练的ACF对象检测器分类器而且trainingOptions.您可以使用此语法重新创建用于代码生成的ACF对象检测器。

输入参数

全部展开

预先训练的acfObjectDetector对象分类器,指定为结构字段。方法将预训练的ACF分类器对象转换为结构,从而获得分类器结构字段toStruct函数。

预先训练的acfObjectDetector对象训练选项,指定为结构字段。方法将预训练的ACF分类器对象转换为结构,从而获得训练选项结构字段toStruct函数。

属性

全部展开

分类模型的名称,指定为字符向量或字符串标量。类的第二列标题默认设置为名称trainingData表中指定的trainACFObjectDetector函数。您可以在创建您的acfObjectDetector对象。

例子:“stopSign”

此属性是只读的。

训练图像的大小,指定为[高度宽度)向量。

例子:(100 100)

此属性是只读的。

检测器中使用的弱学习器的数量,指定为整数。NumWeakLearners小于或等于最后一个训练阶段弱学习者的最大数量。要限制此最大值,可以使用“MaxWeakLearners”属性中的名称-值对trainACFObjectDetector函数。

对象的功能

检测 使用ACF对象检测器检测对象
toStruct 将训练好的集合信道特征(ACF)目标检测器转换为结构

例子

全部折叠

使用trainACFObjectDetector与训练图像一起创建一个ACF对象检测器,可以检测到停止标志。用单独的图像测试检测器。

加载训练数据。

负载(“stopSignsAndCars.mat”

为停止标志图像的完整路径加上前缀。

stopSigns = fullfile(toolboxdir(“愿景”),“visiondata”stopSignsAndCars {: 1});

创建数据存储以加载停止标志的真实数据。

imds = imageDatastore(stopSigns);blds = boxLabelDatastore(stopSignsAndCars(:,2));

组合图像和框标签数据存储。

Ds = combine(imds,blds);

训练ACF检测器。设置每个阶段要使用的负样本数量为2.您可以通过指定关闭训练进度输出Verbose = false,作为一个名称-值论点。

acfDetector = trainACFObjectDetector(ds,NegativeSamplesFactor=2);
ACF对象检测器培训培训将分为4个阶段。模型尺寸为34x31。样本正面例子(~100%完成)计算近似系数…完成。计算聚合通道特性…已完成。-------------------------------------------- 阶段1:样本的负面例子(~ 100%)完成计算聚合通道特性…完成。用42个正例和84个反例训练分类器…完成。训练后的分类器有19个弱学习器。-------------------------------------------- 阶段2:样本负面例子(~ 100%完成)发现了84个新的负面例子进行训练。计算聚合通道特性…已完成。用42个正例和84个反例训练分类器…完成。 The trained classifier has 20 weak learners. -------------------------------------------- Stage 3: Sample negative examples(~100% Completed) Found 84 new negative examples for training. Compute aggregated channel features...Completed. Train classifier with 42 positive examples and 84 negative examples...Completed. The trained classifier has 54 weak learners. -------------------------------------------- Stage 4: Sample negative examples(~100% Completed) Found 84 new negative examples for training. Compute aggregated channel features...Completed. Train classifier with 42 positive examples and 84 negative examples...Completed. The trained classifier has 61 weak learners. -------------------------------------------- ACF object detector training is completed. Elapsed time is 13.9535 seconds.

在测试图像上测试ACF检测器。

Img = imread(“stopSignTest.jpg”);[bboxes,scores] = detect(acfDetector,img);

显示检测结果,并在图像中插入对象的包围框。

I = 1:length(scores) annotation = sprintf(“信心= %.1f”分数(i));img = insertObjectAnnotation(img,“矩形”bboxes(我:),注释);结束图imshow (img)

图中包含一个轴对象。axis对象包含一个image类型的对象。

从。加载ACF停止标志检测器stopSignDetector.mat文件,该文件作为支持文件存在于当前工作文件夹中。金宝app

stopSignDetector = load(“stopSignDetectorACF.mat”);检测器= stopsigndetector .检测器
ModelName: 'stopSign' ObjectTrainingSize: [34 31] NumWeakLearners: 61

方法将检测器转换为结构toStruct函数。

detectorStruct = toStruct(检测器);

为了生成代码,将结构传递给MATLAB函数。然后在MATLAB函数中,使用现有的检测器属性创建一个相同的ACF停止标志检测器。

detector1 = acfObjectDetector(detectorStruct.Classifier,detectorStruct.TrainingOptions)
detector1 = acfObjectDetector with properties: ModelName: 'stopSign' ObjectTrainingSize: [34 31] NumWeakLearners: 61

你可以通过detector1检测函数作为从图像中检测停止标志的输入。

参考文献

Dollar, P., R. Appel, S. Belongie和P. Perona。“用于物体检测的快速特征金字塔。”模式分析与机器智能,IEEE会刊.卷36,2014年第8期,第1532-1545页。

扩展功能

版本历史

在R2017a中引入