train cascade detector to detect more than one shape at the same time

1 回表示 (過去 30 日間)
Ibrahim alami merroui
Ibrahim alami merroui 2023 年 5 月 1 日
回答済み: Birju Patel 2023 年 6 月 1 日
I am interested in detecting or training a cascade detector to recognize two different regions of interest (ROIs) in an image. I have used the image labeler tool to label multiple ROIs across different images and assign them a label name. However, I am unsure how to use the gTruth database to train the cascade detector to detect and differentiate between the two shapes in an image, and then visualize them.
I anticipate that there may be challenges similar to those I have faced with the Image Labeler data.
I would appreciate any guidance on this matter.
% Load positive images and bounding boxes of bikes
load imageLabelingSession % Hier Training von Image Labeler mit Personen
% Step 2: Specify folder with negative images
negativeFolder = 'C:\Trainingsdaten\keine Personen'; % Hier Bilder von keine Personen einfügen
% Step 3: Train the detector
NumStages = 1;
FAR = 0.50;
trainCascadeObjectDetector('detectcodtraining_1_0.50.xml',gTruth , negativeFolder,...
'NumCascadeStages', NumStages, 'FalseAlarmRate', FAR);
%% Detektieren anhand der Trainingsdaten; der vorherigen Abschnitte auskommentiern nach der XML Generierung
% Select XML file for detection
%addpath('XML Files')
detector = vision.CascadeObjectDetector('detectcodtraining_1_0.50.xml');
% Load input
I=imread("ich1.PNG");
% Find the bounding box
bbox = step(detector,I);
% Mark the location on the image using a bounding box
J = insertShape(I,'rectangle',bbox);
imshow(J)
% Clean up
release(detector)
I would like to distinguish between a standing and a sleeping person.

回答 (1 件)

Birju Patel
Birju Patel 2023 年 6 月 1 日
It looks like you are trying to train a multi-class object detector. The cascade object detector is a single class detector. It can only detect one type of object.
Based on the data you've shared, it looks like "standing" is a circular blob and "sleeping" is more of an ellipsoid. You might be able to use image tresholding to detect the bright spots in the image and then use regionprops to estimate geometric properties of the blobs to differentiate between standing and sleeping. See the Eccentricity property in regionprops:
If you find out you still need a detector for this, then I'd start with a multi-class object detector such as YOLO v2:

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by