Problems with Opencv_traincascade Training meeting __OPENCV---a magical country.

Source: Internet
Author: User
Tags memory usage x2 y2

In the use command "Opencv_traincascade-data data-vec pos/pos.vec-bg neg/neg.txt-numpos 433-numneg 5449-numstages 1-w 30-h 30-m Inhitrate 0.7-maxfalsealarmrate 0.02 "after

1. If there is a "Parameters can not be written, because file Data/params.xml can is not opened" error, you will need to manually create a folder data.


2. Appears "Train DataSet for temp stage can is filled. Branch training terminated. Cascade classifier can ' t be trained. Check The used training parameters. Error, the picture path in the Neg.txt file is written as an absolute path, while the Neg.txt folder is moved to the path where the command is currently used.

Reference: http://answers.opencv.org/question/91235/ Cascade-training-error-opencv-31-train-dataset-for-temp-stage-can-not-be-filled-branch-training-terminated-cascade-classi fier-cant-be-trained-check/

Partial Summary:

Ok downloading and inspecting your data, I have found already tons of problems when inspecting your training_negativ As.txt file, I The following Structure images/umd_001.jpg which is asking for trouble. Start by changing those to absolute paths and so this software reading it'll always find the exact image. For example it could be /data/images/umd_001.jpg. Relative paths always generate problems ... Same goes for The training.txt, which has the Same problem, but somehow your seemed to have trained the *.vec file It might have been going good. The Data inside training.txt is seperated using tabs while it is stated that data should to seperated by spaces . If I am afraid it is already possible that your VEC the file is actually and filled with the tabs. More a tip, avoid capitals in filenames. If you forget them somewhere some OS won't handle your data correctly. The file Training.txt got entries but the folder has onlY 490 images, where are the other 10?

Could you supply of the missing images so I can perform tests to-if it works as fixing all this?

UPDATE

After changing the data structure as follows ['ll ADD here later] I ran the Opencv_createsamples tool the The Foll Owing result

Then I ran the training command like this

Opencv_traincascade-data cascade/-vec positivas.vec-bg negativas.txt-numpos 400-numneg 2500-numstages 15-w 200-h 5 0-featuretype lbp-precalcvalbufsize 4048-precalcidxbufsize 4048-numthreads 24

Watch The fact that I increased the memory consumption ... because your system can take more than the standard 1GB per buf Fer and I set the number of threads to take advantage from that.

Training starts for me and features are being evaluated. However due to the amount's unique features and the size of the training samples this would take long ...

Looking at the memory consumption, this is the data uses a full blown 8.6GB, so you might want to lower those to buffers t Hat no swapping'll happen and that it'll cripple the system.

Would update once a stage is succesfully trained, and'll increase memory to speed the process up

UPDATE 2

I increased my buffers to 8GB each, since I have GB available using both fully would leads to a max allowed memory usage of 16GB. When looking in memory it halts around GB now, the spaces needed to represent all the Multiscale features A single training stage ....

I am guessing this are one of the main reasons why your program is running extremely I would suggest to reduce the dimensions of your model to like-w 100-h for a starter, which'll reduce the memory fo Otprint drastically. Else it would indeed take ages to train.

Using This memory for you can, weak classifiers and stages are being

UPDATE 3

Training finished on this 32GB RAM the core system in about 1 hour and half. The resulting model has 7 stages until it reaches satisfactory performance given the training parameters. The model and the data structure used by me can is found here.

FInally I used the model to perform a detection output, generated by this command in C + + code

Cascade.detectmultiscale (Frame_gray, objects, Reject_levels, Level_weights, 1.1, 1, 0, size (), size (), true);

If I then filter out all detections with at least a certainty of 0, then your get the detections stored inside. The the format is filename #detections x1 y1 W1 H1 score1 x2 y2 w2 h2 score2 ... XN yN the HN WN. The #detections is still wrong because I postfilter the certainty score. But'll update the dropbox file when I fixed this.

Didnt visualise the detections on the training data yet. I'll add those too once it works.

UPDATE 4

Added visualisations with their score. Basically if you are take the best hitting detection per image, you keep the numberplate. Better detectors would require Better and more training data.

Good luck with the application!

UPDATE 5

Like promised, the best hits collected.

3, error "Segmentation fault 11", increase the number of positive and negative samples, while the negative sample size is 2-4 times the positive sample.

4, Tip on 11/8/23, in a forum: a.Opencv_traincascade. Opencv_haartraining is a obsolete utility and probably'll be removed from trunk (actually better to do it ASAP, because It confuses people). Opencv_traincascade is a newer version and it has 2 important features:it supports LBP features and it supports MULTI-THR Eading. So, we should forget about opencv_haartraining and switch completely to Opencv_traincascade. B.LBP. In the short words, the LBP has one significant advantage over haar-speed. Both training and detection are much faster, you'll be the difference. At the same time LBP have a bit lower quality of detection. But If you do training the OK (good training dataset all), you can get almost the same quality. In the any case we are recommend to work with LBP features during training. Later can run training process on the final training set with Haar features and compare the results. But The most important step are to create a proper training dataset, and better to use LBP. C.multi-threading. If you are want to enable multi-threading into OpenCV, you are should build it from sources with Intel TBB support. The OpenMP is removed completely from OpenCV. To compile everything from sources, just look at Http://opencv.willowgarage.com/wiki/TBB and then follow Lowgarage.com/wiki/installguide. After this you should the Opencv_traincascade uses several cores during.

5. Error bad argument (Can don't get new positive sample. The most possible reason is insufficient count of samples in given Veg-file. http://answers.opencv.org/question/4368/ Traincascade-error-bad-argument-can-not-get-new-positive-sample-the-most-possible-reason-is-insufficient-count-of-samples -in-given-vec-file/

Some of the summaries are as follows:

The "All", "I have" to "note" You copied my formula description incompletely. I wrote at this issue: "S is a" of the samples from Vec-file, which can be recognized as background right away ". With the partial description of the question, the formula does do sense at all:)

For the document you asked. I don ' t remember that I wrote this formula anywhere except the issue. The formula is not to any paper of course, it just follows from how to Traincascade application selects a set of positive s Amples to train each stage of a cascade classifier. Ok, I ' ll describe my formula into more details as your ask.

Numpose-a count of positive samples which is used to train each stage (does not confuse it and a count of all samples in vec-file!).

Numstages-a stages count which a cascade classifier'll have after the training.

minhitrate-training constraint for each stage which means the following. Suppose a positive samples subset of size Numpose was selected to train the current i-stage (i is a zero-based index). After the training of "stage", at least minhitrate * numpose samples from this subset have to pass this stage, i.e. Current cascade classifier with i+1 stages has to recognize this part (Minhitrate) of the selected samples as positive.

If some positive samples (falsenegativecount pieces) from the set (of size numpose) which is used to train i-stage R Ecognized as negative (i.e. background) after the stage training, then numpose-falsenegativecount pieces of correctly re Cognized positive samples would be kept to train i+1-stage and Falsenegativecount pices of new positive samples (unused BEF Ore) would be selected from Vec-file to get a set of size numpose again.

One more important note:to train next i+1-stage "We select only the" samples "are passed a current cascade CLA Ssifier with i+1 stages.

Now we are ready to derive the formula. For the 0-stage training we just get numpose positive samples from Vec-file. In the worse case  (1-minhitrate) * numpose of This samples are recognized as negative by the Cascade with 0-s Tage only. So in this case to get a training set of positive samples for the 1-stage training we have to select  (1-minhitrate) * Numpose new samples from Vec-file, are recognized as positive by the Cascade and 0-stage only. While the selection, some new positive's samples from Vec-file can is recognized as background right away by the current CAs Cade and we skip such samples. The count of skipped sample depends on your vec-file (how different samples are into it) and other training parameters. By analogy, for each i-stage training (I=1,.. NUMSTAGES-1) In the "worse case" we have to select  (1-minhitrate) * numpose new positive samples and several POS Itive The samples would be skipped the process. As train all stagesWe need  Numpose + (numStages-1) * (1-minhitrate) * numpose + SPositive samples, where S is a count of the skipped samples from vec-file (for all stages).

Of course this formula does not allow to know a exact size of vec-file (samples count) We must have, because S depends on Vec-file samples quality. But The formula gives a estimation of this size and understanding its reason. I hope it is so:) If you are disagree or have more questions, please let me know.

r8913 is a link to the SVN revision 8913 and But we migrated on GIT. The corresponding fix is in OpenCV >= 2.4.2. And yes, 2.4.3 is actual version (the can always check here).

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.