本文介绍了lbp分类器的训练有时会成功,有时则不会的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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?

推荐答案




这篇关于lbp分类器的训练有时会成功,有时则不会的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-09 22:34