Cascade Object Detector: Unable to generate a sufficient number of negative samples

Hi, I am using the cascade object detector. I'm currently using the training image labeler to draw a bounding box around the ROI. However, when I run the command, trainCascadeObjectDetector, it only includes the positive images which I've provided in the training labeler and it will use the positive images to generate negative samples.
Also, I have this error message. "Cannot find enough samples for training."
"Unable to generate a sufficient number of negative samples for this stage. Consider reducing the number of stages, reducing the false alarm rate or adding more negative images."
May I know how do I train my negative images to include in the cascade object detector? I have my own set of negative images that I wish to include into my training sets. Thanks!

 採用された回答

Dima Lisin
Dima Lisin 2015 年 12 月 1 日

1 投票

Hi Leonard,
Negative images are images that do not contain the objects that you are trying to detect. They should, however, contain backgrounds that are typically associated with your objects of interest. So if you are trying to detect stop signs, the negative images should be pictures of streets and roads with no stop signs in them.
The Training Image Labeler app does not directly produce the negative images. The simplest thing is to capture of find them yourself. If that is difficult, then you can take the output of the Training Image Labeler app, and fill the regions corresponding to the bounding boxes with zeros or random noise.

12 件のコメント

Leonard Yeo
Leonard Yeo 2015 年 12 月 2 日
編集済み: Leonard Yeo 2015 年 12 月 2 日
Hi Dima,
I do have my own set of negative images which I would like to include in my training set however, I do not know how to include them in.
Dima Lisin
Dima Lisin 2015 年 12 月 3 日
trainCascadeObjectDetector takes a parameters called negativeImages. It can either be a cell array containing the file names of the negative images, or it can be a directory where the negative images are stored.
Leonard Yeo
Leonard Yeo 2015 年 12 月 10 日
Do I include negative image into the Training Image Labeler?
Dima Lisin
Dima Lisin 2015 年 12 月 10 日
No, because you do not need to label anything in the negative images. You just need to tell trainCascadeObjectDetector where they are.
How do I resolve "Unable to generate a sufficient number of negative samples" issue? I have added more negative images into the folder but it is still giving the same problem. Currently, I have 600 positive and 1100 negative samples. Below is my code:
%%Load data
% Training image labeler (ROI)
load('trainingImage.mat');
data = positiveInstances;
% Positive images folder
imDir = 'C:\Users\MATLAB\Photos\Training\Positive';
addpath(imDir);
% Negative images folder
negativeFolder = 'C:\Users\MATLAB\Photos\Training\Negative';
trainCascadeObjectDetector (train image):
trainCascadeObjectDetector('output.xml',data,...
negativeFolder,'FalseAlarmRate',0.2,'NumCascadeStages',15,...
'TruePositiveRate',0.995,'FeatureType','Haar');
Dima Lisin
Dima Lisin 2015 年 12 月 10 日
What kind of objects are you trying to detect? What do your negative images look like?
In the mean time try increasing the FalseAlarmRate to 0.5. If that doesn't work, try decreasing the NegativeSamplesFactor to 1.5.
Also note that there is difference between "negative samples" and "negative images". What you are providing to the function are negative images, which should be large. The function generates the negative samples automatically from the negative images.
Leonard Yeo
Leonard Yeo 2015 年 12 月 10 日
I am trying to detect wheelchairs. My negative images are background of hospitals without any wheelchairs.
If I were to increase my FalseAlarmRate to 0.5, wouldn't it have a higher false positive?
Dima Lisin
Dima Lisin 2015 年 12 月 10 日
I would think detecting wheelchairs would be hard... You may have to train multiple detectors (side view, front view, etc.).
Increasing FalseAlarmRate is ok, as long as you have enough stages. If FalseAlarmRate is .5, then after two stages the overall false positive rate will be 1/4. After 3 stages it will be 1/8, and so on.
Leonard Yeo
Leonard Yeo 2015 年 12 月 11 日
Alright but how do I combine multiple detectors into one if I have split my images and trained them into sub-categories?
Dima Lisin
Dima Lisin 2015 年 12 月 11 日
You would have to run each detector separately.
Leonard Yeo
Leonard Yeo 2015 年 12 月 11 日
Hmmm.. So I cannot combine both set of detector codes into one program to run? I have to run 2 different files separately at each time for the detection?
Dima Lisin
Dima Lisin 2015 年 12 月 11 日
You would need to train two separate detectors, and get two separate XML files. Then you would need to create two separate vision.CascadeObjectDetector objects, and run each one on your image. You can certainly have two detector objects in the same program (or function).

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeImage Processing and Computer Vision についてさらに検索

質問済み:

2015 年 12 月 1 日

コメント済み:

2015 年 12 月 11 日

Community Treasure Hunt

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

Start Hunting!

Translated by