Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have the following directory strucure:

    project root/
      negatives/
        the negatives files
      ngest/
        00palmo/
          1510 positives files
        01pugno/
          1431 positive files 
        02indice/
          1073 positive files
        03v/
          1462 positive files 
I want to train a cascade classifier with the following script

    #!/bin/bash
    touch negatives/ls.txt
    ls -1 negatives|sed  -e "s/ *$//">negatives/ls.txt #list of negatives images
    for i in ~/workspace/sm/ngest/*;do

        cd $i
        find . -name '*' -exec identify -format '%i 1 0 0 %w %h' \{\} \; >ls.txt #list of all images in question
        opencv_createsamples -vec $(pwd)/coll.vec -info ls.txt -bg ../../negatives/ls.txt -w 24 -h 24 -num 1550
        mkdir out #the directory where we put the classifiers
        opencv_traincascade -data out -bg ../../negatives/ls.txt -vec coll.vec -featureType LBP \
            -w 24 -h 24 -numPos 1300 -minHitRate 0.99 -precalcValBufSize 4096 -precalcIdxBufSize 4096
        echo #line to separate the various iterations

    done

However ,while I got a full classifier in 00palmo/out/cascade.xml and in 03v/out/cascade.xml,in 01pugno/out teach up to the 10thstage before stopping(the other got up to the  12th before completing with success) and 02indice/out is an empty directory after the script complete.

Both the command 01pugno and 02indice terminate with the following error message ,after respectively 10 and 0 stages:


    POS current sOpenCV Error: Bad argument (Can not get new positive sample. The most possible reason is insufficient count of samples in given vec-file.
    ) in get, file /build/buildd/opencv-2.4.8+dfsg1/apps/traincascade/imagestorage.cpp, line 162
    terminate called after throwing an instance of 'cv::Exception'
      what():  /build/buildd/opencv-2.4.8+dfsg1/apps/traincascade/imagestorage.cpp:162: error: (-5) Can not get new positive sample. The most possible reason is insufficient
    count of samples in given vec-file.
     in function get


Here the link to the output of the script: https://www.dropbox.com/s/jz4nidgw1zwm8f6/out.txt?dl=0 .

And here the link to an archive with the files I used for creating the classifiers:
https://www.dropbox.com/s/63r71jlqpdxsbwf/files.zip?dl=0 .



Where did I got it wrong?
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900