Обучите основанный на 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.7195 seconds.

Протестируйте детектор на основе ACF на образцовом изображении.

I = imread('stopSignTest.jpg');
bboxes = detect(acfDetector,I);

Отображение обнаруженного объекта.

annotation = acfDetector.ModelName;
I = insertObjectAnnotation(I,'rectangle',bboxes,annotation);

figure 
imshow(I)

Figure contains an axes. The axes contains an object of type image.

Удалите папку изображений из пути.

rmpath(imageDir); 
Для просмотра документации необходимо авторизоваться на сайте