Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9187725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:50:41+00:00 2026-06-17T19:50:41+00:00

I am trying to train a haar-like classifier for pedestrians in OpenCV using 3340

  • 0

I am trying to train a haar-like classifier for pedestrians in OpenCV using 3340 positive images and 1224 negative images. (in a .txt file I keep the negative image names i.e negatives(1).bmp, and in a txt file I keep the positives i.e. picture(1).bmp 1 0 0 64 128.
Actually positive examples are already cropped images of pedestrians so I only need specify one positive sample per image).

At some point during the training process it stops and says :

“Opencv Error: Assertion failed (elements_read==1)in unknown function, file c:\path\cvhaartraining.cpp, line 1858”

Any ideas as to what is causing this ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T19:50:42+00:00Added an answer on June 17, 2026 at 7:50 pm

    this issue was answered by creater of the utility on the OpenCV DevZone site in June 2012.

    To quote Maria:

    The problem is that your vec-file has exactly the same samples count
    that you passed in command line -numPos 979. Training application used
    all samples from the vec-file to train 0-stage and it can not get new
    positive samples for the next stage training because vec-file is over.
    The bug of traincascade is that it had assert() in such cases, but it
    has to throw an exception with error message for a user. It was fixed
    in r8913.
    -numPose is a samples count that is used to train each stage. Some already used samples can be filtered by each previous stage (ie
    recognized as background), but no more than (1 – minHitRate) * numPose
    on each stage. So vec-file has to contain >= (numPose + (numStages-1)
    * (1 – minHitRate) * numPose) + S, where S is a count of samples from vec-file that can be recognized as background right away. I hope it
    can help you to create vec-file of correct size and chose right numPos
    value.

    It worked for me. I also had same problem, I was following the famous tutorial on HAAR training but wanted to try the newer training utility with
    -npos 7000 -nneg 2973

    so i did following calcs:

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

    7000 >= (numPos + (20-1) * (1 – 0.999) * numPos) + 2973

    (7000 – 2973)/(1 + 19*0.001) >= numPos

    numPos <= 4027/1.019

    numPos <= 3951 ~~ 3950

    and used:

    -npos 3950 -nneg 2973

    It works. I also noticed that others have also had success with reducing numPos : here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to train a set of ~30,000 instances using an SMO classifier with
I am trying to read the file 'train-images-idx3-ubyte', which can be found here along
I've just recently started using libsvm. I've been trying for awhile to train my
Not quite sure where I'm going wrong - I'm trying to train OpenCV for
I'm trying to train a gbm using the caret package in R. I initially
Im trying to implement the bag of words approach using opencv. After making the
I trying to train haar cascade classificator for card suite detection (which no rotation
I'm trying to use sk-learn's RandomForestClassifier for a binary classification task (positive and negative
I am trying to extract features using OpenCV's HoG API, however I can't seem
I'm very new to OpenCV. I am trying to use the CvNormalBayesClassifier to train

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.