主要内容

acfObjectDetector

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

描述

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

ACF目标检测器根据训练图像和使用的目标地面真实位置识别图像中的特定目标trainACFObjectDetector函数。

创建

创建一个acfObjectDetector对象,调用trainACFObjectDetector功能与训练数据。

探测器= trainACFObjectDetector (trainingData…)

描述

例子

探测器= acfObjectDetector (detectorStruct。分类器detectorStruct。TrainingOptions创建一个acfObjectDetector与现有对象相同的对象acfObjectDetector对象使用对象属性分类器TraningOptions,存储在detectorStruct结构字段。使用此语法重新创建用于代码生成的ACF对象检测器。

输入参数

全部展开

预先训练的acfObjectDetector对象分类器,指定为结构字段。获取对象属性分类器,转换预先训练的acfObjectDetector对象一个detectorStruct结构使用toStruct函数。然后,使用点符号。

预先训练的acfObjectDetector对象训练选项,指定为结构字段。获取对象属性TrainingOptions,转换预先训练的acfObjectDetector对象一个detectorStruct结构使用toStruct函数。然后,使用点符号。

属性

全部展开

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

例子:“stopSign”

此属性是只读的。

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

例子:(100 100)

此属性是只读的。

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

对象的功能

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

例子

全部折叠

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

加载训练数据。

负载(“stopSignsAndCars.mat”

选择地面真理为停止标志。这些地面真相是图像中已知的停车标志的位置。

stopSigns = stopSignsAndCars (:, 1:2);

将完整路径添加到图像文件中。

stopSigns。imageFilename = fullfile (toolboxdir (“愿景”),...“visiondata”, stopSigns.imageFilename);

培训ACF检测器。您可以通过指定关闭训练进度输出“详细”,假的作为一个名称,值对。

acfDetector = trainACFObjectDetector (stopSigns,“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 31.3174 seconds.

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

img = imread (“stopSignTest.jpg”);[bboxes,分数]=检测(acfDetector, img);

显示检测结果,并将物体的边框插入到图像中。

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

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

加载ACF停止信号检测器从stopSignDetector.mat文件,该文件作为支持文件出现在当前工作文件夹中。金宝app

stopSignDetector =负载(“stopSignDetectorACF.mat”);探测器= stopSignDetector.detector
detector = acfObjectDetector带有属性:ModelName: 'stopSign' ObjectTrainingSize: [34 31] NumWeakLearners: 61

将检测器转换为一个结构toStruct函数。

detectorStruct = toStruct(探测器);

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

detector1 = acfObjectDetector (detectorStruct.Classifier detectorStruct.TrainingOptions)
detector1 = acfObjectDetector带有属性:ModelName: 'stopSign' ObjectTrainingSize: [34 31] NumWeakLearners: 61

你可以通过detector1检测功能作为一个输入,从图像检测停止标志。

参考文献

P.阿佩尔、S. Belongie和P. Perona。目标检测的快速特征金字塔模式分析与机器智能,IEEE汇刊.2014年第36卷第8期1532-1545页。

扩展功能

介绍了R2017a