1

I'm trying to train my own Haar Cascade classifier for apple according to this article. I collected 1000 positive images and 500 negative images from the internet. Each image has different sizes and I cropped the images to create "info.txt" file. While I creating samples like this,

createsamples.exe -info positive/info.txt -vec vector/applevector.vec - 
num 1000 -w 24 -h 24 

there is some parameters -w and -h. What does it mean ? Should I resize all my positive and negative images ? I tried to train my classifier with default parameters (-w 24 and -h 24) but accuracy of my classifier is so weak. Can it be related with this parameters ? Thank you for advice.

UPDATE

There is some examples of my positive images. I collected them from the internet.

apple 1 apple 2 apple 3

onurcanak
  • 109
  • 1
  • 9
  • createsamples will automatically resize all the samples to w and h size. Your original samples should have the right aspect ratio. – Micka Mar 25 '18 at 10:10
  • @Micka so should my original samples has the same size ? For example my positive samples have different sizes like 620x320, 500x413, 1000x1000. Should I fixed their sizes for example 620x320 of all ? – onurcanak Mar 25 '18 at 10:19
  • no, but you must label the objects (samples) within those images (pos.txt) and you must choose a single aspect ratio you want to detect. The chosen w and h will be the minimum size of the object you will be able to detect after training. If the aspect ratio of the samples does not fit the aspect ratio during createsamples, the objects will be distorted, which might or might not be a problem – Micka Mar 25 '18 at 12:33
  • post some sample images for further explanation. – Micka Mar 25 '18 at 12:33
  • I updated the question and add some positive images. Could you please check it ? – onurcanak Mar 25 '18 at 13:21
  • are you using the full images as single samples or did you select thr object via labeling a subregion? – Micka Mar 25 '18 at 18:22
  • @Micka I'm using the tool that in the article which I mentioned in the question. My images are full images like I added. I cut the apples in the images to create "info.txt" file. This file contains each image's name, and location of the apple(s) in that image. For example; rawdata/b(1).bmp 1 96 10 375 390 – onurcanak Mar 26 '18 at 08:07
  • ok, then you should use a quadratic aspect ratio since apples are about quadratic. I would only use "upright side view" apples in the beginning. To reduce distortion I would crop/label real quadratic regions around the apples (adding a bit of background if necessary). You can choose any w/h, but you won't be able to detect anything smaller than the chosen size and sizes bigger than some size (maybe 64x64) might be impossible to train because of the number of possible features and memory needs for a "real" number of samples. I would choose 24x24 or 32x32. – Micka Mar 26 '18 at 08:55
  • and it is not guaranteed that haar cascades are any good for "apple detection", since there is imho no typical texture pattern behaviour on the surface. – Micka Mar 26 '18 at 08:57

0 Answers0