Trying to run createsamples, unsuccessfully though

asked 2017-02-12 05:35:34 -0600

sammy_dlx gravatar image

Hello dear community,

I am trying to run a Haar classifier, but I am stuck already with creating enough sample images (FYI I am using git clone github.com/mrnugget/opencv-haar-classifier-training.git)

I follow the instructions as per http://www.trevorsherrard.com/Haar_training.html (www.trevorsherrard.com/Haar_training....) up until the command $ perl bin/createsamples.pl ... in my terminal but I do not get any samples. The command returns only multiple lines like the following (for each positive example):

opencv_createsamples -bgcolor 0 -bgthresh 0 -maxxangle 1.1 -maxyangle 1.1 maxzangle 0.5 -maxidev 40 -w 3264 -h 2448 -img ./positive_images/IMG_0227.JPG -bg tmp -vec samples/IMG_0227.JPG.vec -num 69

Does anybody know what the problem could be? (please see below a detailed step-by-step description of what I did)

Thank you!


What I did, step by step (by default I am in the haar_classifier root dir):

(1) I created multiple positive examples by cropping the original large pictures with positive examples and reducing the pictures to the relevant area only, saved in folder "positive_images" (around 30)

(2) I created a random set of background examples and saved in folder "negative_images" (around 500)

(3) I created the lists of positive and negative examples with the terminal commands

$ find ./negative_images -iname "*.jpg" > negatives.txt
$ find ./positive_images -iname "*.jpg" > positives.txt

This command returns text files, which include only the names of the positive and negative files such as

"./positive_images/good01.jpg"

(4) I then run in my terminal

$ perl bin/createsamples.pl positives.txt negatives.txt samples 1500 "opencv_createsamples -bgcolor 0 -bgthresh 0 -maxxangle 1.1 -maxyangle 1.1 maxzangle 0.5 -maxidev 40 -w 80 -h 40"

To my understanding, this command should create 1500 distorted images in my "samples" directory. However, nothing really happens apart from the output

opencv_createsamples -bgcolor 0 -bgthresh 0 -maxxangle 1.1 -maxyangle 1.1 maxzangle 0.5 -maxidev 40 -w 3264 -h 2448 -img ./positive_images/IMG_0227.JPG -bg tmp -vec samples/IMG_0227.JPG.vec -num 69

edit retag flag offensive close merge delete

Comments

1

your tutorial is outdated. and that method of "synthesizing" positive samples won't give decent results.

rather have a look at opencv's tutorial

berak gravatar imageberak ( 2017-02-12 05:40:55 -0600 )edit

OpenCV 3 Blueprints, chapter 5 discusses in great detail why one should avoid using the old interface and the synthezing images from a single one, as noticed by @berak. Also the tutorial has been updated to give you the best information possible. If there is something you feel that is missing, do let us know so we can update it.

StevenPuttemans gravatar imageStevenPuttemans ( 2017-02-12 08:46:04 -0600 )edit