Opencv_traincascade train your own Detector

Source: Internet
Author: User

After nearly a month of engineering practice, I will share my accumulated experience with you and teach you how to train a converged XML that is better than the built-in data of opencv.

Openvhas two training exe, one is opencv_haartraining.exe, the other is opencv_traincascade.exe, and the latter is a new version of the former. Generally, we use the latter, or we have three features: Compile. (cmake is the new tool for opencv, remember to put the corresponding opencv liband opencv_traincascade.exe together ). Opencv_createsamples.exe is used to generate a positive sample Vec.

The bat of the two EXE files is as follows:

Opencv_createsamples.exe-Info name763.dat-VEC zhengmian_763.vec-num 763-W 50-h 55

Opencv_traincascade.exe-data datahog-VEC 763.vec-BG negname. dat-numpos 700-numneg 2100-featuretype hog-W 50-h 55-numstages 20

Well, many people have talked about specific commands. This is not a long question. Let's talk about my actual considerations:

1. The positive sample is not described by some people. You actually have 300 positive samples, which can be written as 3000 in traincascade. This idea is useless. When collecting positive samples, you must ensure that the width and height of all samples are roughly the same. If you are yourself, we recommend that you use a magic player. Or you can write a GUI tool yourself. To avoid opencv errors, when opencv_traincascade.exe is used,-numpos is slightly lower than the actual number of positive samples. For example, if you have 2100 samples, you can set numpos to 1900-2000,

2. Negative samples of positive samples. Special samples are not required when the image name is used. You should make sure that the correct name is pos1.jpg ..... And so on. special characters include (), which may contain opencv error or cannot be identified.

3 Positive and Negative sample ratio ~ArticleTo reduce false positive, we can increase the number of negative samples.

4. When memory is insufficient, you can use either of the following methods: 1. You can run on a 64-bit PC and 2. Reduce the number of positive and negative samples. 3. Reduce the width and height of the positive sample.

Let us give more comments on experiences and poor things.

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.