2

I am sorry it seems a starting question but just wondering can i use rectangular dimensions for training opencv haar cascade. I tried with square samples and the resultant image was detected fine but when i tried with rectangular width and height as for license plate the aspect ratio is 2:1 between width and height so i am using the same aspect ratio while training but the resultant classifier is not detecting anything in the image.

nStages = 14
nPositive = 1780
minHitrate = 0.996
maxFalseAlarm = 0.2
nNegatives = 14000
width = 48
height = 24
Haar classifier type = BASIC
Boost type = gentle adaboost

The above are the parameters i have set for training of the classifier. Can anyone please confirm that can i use rectangular parameters for positive samples or not. Also please suggest some modifications to have the training done properly.

The size of negative images for training is around 240x161 annd 420x240

Thank you.


EDIT 1:


I am using the call as follows.

f_cascade.detectMultiScale( image, detected_objects, pyramidScale, 2, 0|CV_HAAR_SCALE_IMAGE);
Hadi
  • 307
  • 6
  • 20
  • in short yes, the feature dimensions ideally should retain the same aspect ratio. the other answer is that it is extremely fiddly to use that program to make a good feature detector. you also can adjust the thresholds in the call to the detector in your code to make it more or less strict – chris Jan 22 '15 at 01:39
  • I am not using any size thresholds in the call but still it is not returning any error or nothing in the resultant image. Is it possible that the actual size of the license plates is with this aspect ratio but if it differs in a picture even slightly it will be difficult to detect ? and will it help if i use sample images of smaller size or less aspect ratio in detecting larger aspect ratio ones – Hadi Jan 22 '15 at 02:12
  • can you include how you call the detector in your q – chris Jan 22 '15 at 02:55
  • I did and sorry i commented out twice before but due to some reason its just getting deleted – Hadi Feb 03 '15 at 02:23

1 Answers1

0

The key parts of this are making sure your positive samples and training dimensions are the same. There is no reason why you won't be able to detect a rectangular object.

They key thing to remember is that traincascade is running whatever dimensions you specify over your images.

See here for some proof that rectangular objects should be detected just fine: http://coding-robin.de/2013/07/22/train-your-own-opencv-haar-classifier.html

Also I wrote a tutorial about object detection if anyone gets stuck on this stuff:

http://johnallen.github.io/opencv-object-detection-tutorial/

JohnAllen
  • 7,317
  • 9
  • 41
  • 65