ACF ベースの一時停止標識検出器の学習
学習データを使用して、ACF ベースの一時停止標識用オブジェクト検出器に学習させます。
MATLAB パスにイメージを含むフォルダーを追加します。
imageDir = fullfile(matlabroot, 'toolbox', 'vision', 'visiondata', 'stopSignImages'); addpath(imageDir);
グラウンド トゥルース データを読み込みます。これには、一時停止標識と自動車のデータが含まれます。
load('stopSignsAndCarsGroundTruth.mat','stopSignsAndCarsGroundTruth')
ラベル定義を表示して、グラウンド トゥルースに含まれるラベル タイプを確認します。
stopSignsAndCarsGroundTruth.LabelDefinitions
ans=3×3 table
Name Type Group
____________ _________ ________
{'stopSign'} Rectangle {'None'}
{'carRear' } Rectangle {'None'}
{'carFront'} Rectangle {'None'}
学習用の一時停止標識データを選択します。
stopSignGroundTruth = selectLabelsByName(stopSignsAndCarsGroundTruth,'stopSign');
一時停止標識オブジェクト検出器のための学習データを作成します。
trainingData = objectDetectorTrainingData(stopSignGroundTruth); summary(trainingData)
Variables: imageFilename: 41x1 cell array of character vectors stopSign: 41x1 cell
ACF ベースのオブジェクト検出器に学習させます。
acfDetector = trainACFObjectDetector(trainingData,'NegativeSamplesFactor',2);
ACF Object Detector Training The training will take 4 stages. The model size is 34x31. Sample positive examples(~100% Completed) Compute approximation coefficients...Completed. Compute aggregated channel features...Completed. -------------------------------------------- Stage 1: Sample negative examples(~100% Completed) Compute aggregated channel features...Completed. Train classifier with 42 positive examples and 84 negative examples...Completed. The trained classifier has 19 weak learners. -------------------------------------------- Stage 2: 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 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 20.3343 seconds.
ACF ベースの検出器をサンプル イメージでテストします。
I = imread('stopSignTest.jpg');
bboxes = detect(acfDetector,I);
検出したオブジェクトを表示します。
annotation = acfDetector.ModelName;
I = insertObjectAnnotation(I,'rectangle',bboxes,annotation);
figure
imshow(I)
パスからイメージ フォルダーを削除します。
rmpath(imageDir);