OpenCV Error: Bad argument (Can not get new positive sample









up vote
1
down vote

favorite












I am trying to train my own OpenCV Haar Classifier for cup detection.
I have 100 images which contain cup and 400 images which do not contain cup, So,



No of Positive Images = 100



No. of Negative Images = 400



At first I created dat for both of them by



find ./Negative_Images -name '*.jpg' >negatives.dat
find ./Positive_Images -name '*.jpg' >positives.dat


Next, I run the following command to generate samples (I put value for sample 100 as no of my positive images are 100. Is it right? )



perl createtrainsamples.pl positives.dat negatives.dat samples 100 "opencv_createsamples -bgcolor 0 -bgthresh 0 -maxxangle 1.1 -maxyangle 1.1 maxzangle 0.5 -maxidev 40 -w 80 -h 60"


Now 100 samples (*.jpg.vec) are created in samples folder. Next, I run the following command to generate samples.vac



python ./tools/mergevec.py -v samples/ -o samples.vec


mergevec.py found in the tutorial by mrnugget



Now for the next command is "opencv_haartraining",



opencv_traincascade -data classifier -vec samples.vec -bg negatives.dat -precalcValBufSize 2500 -precalcIdxBufSize 2500 -numPos 100 -numNeg 400 -numStages 15 -minhitrate 0.99 -maxfalsealarm 0.5 -w 80 -h 60


I am receiving error Error: Can not get new positive sample



Someone solved it by numPos = noOfPositiveImages*0.9, But it did not work for me



From different sources, I found a formula to calculate the value for numPose.



vec-file has to contain >= (numPose + (numStages-1) * (1 - minHitRate) * numPose) + S



So far I understand, for me



vec-file has to contain = 100 (As I had 100 positive Images, and from those 100 samples were created)



numStage = 4 (Or it can be any other value, as I want)



minHitRate = 0.99



S = count of samples from vec-file.(Some other place says, the count of all the skipped samples from vec-file (for all stages))



I do not understand, what value should I put for S?



Can anyone explain this formula with example? What value should I put in the command to solve this error?










share|improve this question

























    up vote
    1
    down vote

    favorite












    I am trying to train my own OpenCV Haar Classifier for cup detection.
    I have 100 images which contain cup and 400 images which do not contain cup, So,



    No of Positive Images = 100



    No. of Negative Images = 400



    At first I created dat for both of them by



    find ./Negative_Images -name '*.jpg' >negatives.dat
    find ./Positive_Images -name '*.jpg' >positives.dat


    Next, I run the following command to generate samples (I put value for sample 100 as no of my positive images are 100. Is it right? )



    perl createtrainsamples.pl positives.dat negatives.dat samples 100 "opencv_createsamples -bgcolor 0 -bgthresh 0 -maxxangle 1.1 -maxyangle 1.1 maxzangle 0.5 -maxidev 40 -w 80 -h 60"


    Now 100 samples (*.jpg.vec) are created in samples folder. Next, I run the following command to generate samples.vac



    python ./tools/mergevec.py -v samples/ -o samples.vec


    mergevec.py found in the tutorial by mrnugget



    Now for the next command is "opencv_haartraining",



    opencv_traincascade -data classifier -vec samples.vec -bg negatives.dat -precalcValBufSize 2500 -precalcIdxBufSize 2500 -numPos 100 -numNeg 400 -numStages 15 -minhitrate 0.99 -maxfalsealarm 0.5 -w 80 -h 60


    I am receiving error Error: Can not get new positive sample



    Someone solved it by numPos = noOfPositiveImages*0.9, But it did not work for me



    From different sources, I found a formula to calculate the value for numPose.



    vec-file has to contain >= (numPose + (numStages-1) * (1 - minHitRate) * numPose) + S



    So far I understand, for me



    vec-file has to contain = 100 (As I had 100 positive Images, and from those 100 samples were created)



    numStage = 4 (Or it can be any other value, as I want)



    minHitRate = 0.99



    S = count of samples from vec-file.(Some other place says, the count of all the skipped samples from vec-file (for all stages))



    I do not understand, what value should I put for S?



    Can anyone explain this formula with example? What value should I put in the command to solve this error?










    share|improve this question























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I am trying to train my own OpenCV Haar Classifier for cup detection.
      I have 100 images which contain cup and 400 images which do not contain cup, So,



      No of Positive Images = 100



      No. of Negative Images = 400



      At first I created dat for both of them by



      find ./Negative_Images -name '*.jpg' >negatives.dat
      find ./Positive_Images -name '*.jpg' >positives.dat


      Next, I run the following command to generate samples (I put value for sample 100 as no of my positive images are 100. Is it right? )



      perl createtrainsamples.pl positives.dat negatives.dat samples 100 "opencv_createsamples -bgcolor 0 -bgthresh 0 -maxxangle 1.1 -maxyangle 1.1 maxzangle 0.5 -maxidev 40 -w 80 -h 60"


      Now 100 samples (*.jpg.vec) are created in samples folder. Next, I run the following command to generate samples.vac



      python ./tools/mergevec.py -v samples/ -o samples.vec


      mergevec.py found in the tutorial by mrnugget



      Now for the next command is "opencv_haartraining",



      opencv_traincascade -data classifier -vec samples.vec -bg negatives.dat -precalcValBufSize 2500 -precalcIdxBufSize 2500 -numPos 100 -numNeg 400 -numStages 15 -minhitrate 0.99 -maxfalsealarm 0.5 -w 80 -h 60


      I am receiving error Error: Can not get new positive sample



      Someone solved it by numPos = noOfPositiveImages*0.9, But it did not work for me



      From different sources, I found a formula to calculate the value for numPose.



      vec-file has to contain >= (numPose + (numStages-1) * (1 - minHitRate) * numPose) + S



      So far I understand, for me



      vec-file has to contain = 100 (As I had 100 positive Images, and from those 100 samples were created)



      numStage = 4 (Or it can be any other value, as I want)



      minHitRate = 0.99



      S = count of samples from vec-file.(Some other place says, the count of all the skipped samples from vec-file (for all stages))



      I do not understand, what value should I put for S?



      Can anyone explain this formula with example? What value should I put in the command to solve this error?










      share|improve this question













      I am trying to train my own OpenCV Haar Classifier for cup detection.
      I have 100 images which contain cup and 400 images which do not contain cup, So,



      No of Positive Images = 100



      No. of Negative Images = 400



      At first I created dat for both of them by



      find ./Negative_Images -name '*.jpg' >negatives.dat
      find ./Positive_Images -name '*.jpg' >positives.dat


      Next, I run the following command to generate samples (I put value for sample 100 as no of my positive images are 100. Is it right? )



      perl createtrainsamples.pl positives.dat negatives.dat samples 100 "opencv_createsamples -bgcolor 0 -bgthresh 0 -maxxangle 1.1 -maxyangle 1.1 maxzangle 0.5 -maxidev 40 -w 80 -h 60"


      Now 100 samples (*.jpg.vec) are created in samples folder. Next, I run the following command to generate samples.vac



      python ./tools/mergevec.py -v samples/ -o samples.vec


      mergevec.py found in the tutorial by mrnugget



      Now for the next command is "opencv_haartraining",



      opencv_traincascade -data classifier -vec samples.vec -bg negatives.dat -precalcValBufSize 2500 -precalcIdxBufSize 2500 -numPos 100 -numNeg 400 -numStages 15 -minhitrate 0.99 -maxfalsealarm 0.5 -w 80 -h 60


      I am receiving error Error: Can not get new positive sample



      Someone solved it by numPos = noOfPositiveImages*0.9, But it did not work for me



      From different sources, I found a formula to calculate the value for numPose.



      vec-file has to contain >= (numPose + (numStages-1) * (1 - minHitRate) * numPose) + S



      So far I understand, for me



      vec-file has to contain = 100 (As I had 100 positive Images, and from those 100 samples were created)



      numStage = 4 (Or it can be any other value, as I want)



      minHitRate = 0.99



      S = count of samples from vec-file.(Some other place says, the count of all the skipped samples from vec-file (for all stages))



      I do not understand, what value should I put for S?



      Can anyone explain this formula with example? What value should I put in the command to solve this error?







      opencv haar-classifier






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 12 at 0:53









      Shaon Debnath

      184




      184



























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53254758%2fopencv-error-bad-argument-can-not-get-new-positive-sample%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53254758%2fopencv-error-bad-argument-can-not-get-new-positive-sample%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          這個網誌中的熱門文章

          How to read a connectionString WITH PROVIDER in .NET Core?

          Node.js Script on GitHub Pages or Amazon S3

          Museum of Modern and Contemporary Art of Trento and Rovereto