First of all, it is necessary to note that the Haar training extracted by OPENCV is characterized by haar characteristics (refer to my other article on Haar features: http://blog.csdn.net/carson2005/article/ details/8094699), the classifier is the AdaBoost cascade classifier (if you need to understand the adaboost algorithm, please refer to my other article: http://blog.csdn.net/carson2005/article/details/
.
$ Haartraining-data haarcascade-VEC samples. vec-BG negatives. dat-nstages 20-nsplits 2-minhitrate 0.999-maxfalsealarm 0.5-NPOs 7000-nneg 3019-W 20-H 20-nonsym-MEM 512-mode all
The "-nonsym" option is used for object classes without vertical (left-right) symmetry. If the object class is vertical symmetric, such as the positive face, use "-Sym (default )". This will increase the computing speed because only half of Haier-like features are put into use."-Mode all" uses
OPENCV provides two programs that can train their own cascading classifiers opencv_haartraining and Opencv_traincascade. Opencv_traincascade is a new program that is written in C + + using the OpenCV 2.x API. The main difference is that Opencv_traincascade supports both Haar and LBP (local Binary Patterns), and it is easy to add other features. Compared with the Haar feature, LBP features are integer featur
First of all, it should be noted that the Haar training feature extracted by opencv is the Haar feature (For details, refer to my other article about Haar features: http://blog.csdn.net/carson2005/article/details/8094699 ), classifier is a AdaBoost cascade classifier (if you need to know the Adaboost algorithm, please refer to my another article: http://blog.csdn.net/carson2005/article/details/8130557 ). Th
Reprint: Https://mp.weixin.qq.com/s/J6eo4MRQY7jLo7P-b3nvJg
Li Lin compiled from PyimagesearchAuthor Adrian rosebrockQuantum bit Report | Public number Qbitai
OpenCV is a 2000 release of the open-source computer vision Library, with object recognition, image segmentation, face recognition, motion recognition and other functions, can be run on Linux, Windows, Android, Mac OS and other operating systems, with lightweight, efficient known, and provides
Opencv training ClassifierI. IntroductionThe target detection method was initially proposed by Paul Viola [vila01] and improved by Rainer lienhart [lienhart02. The basic steps of this method are as follows: First, use the Harr feature of the sample (about several hundred sample images) for Classifier Training to obtain a cascade boosted classifier.In a classifier
I haven't written a blog for a long time, and my student's career ends. I will not summarize it. Today, I will record the Adaboost training and detection process in opencv, so that it is convenient for others ~~~ Ah, haha ~~~~
I. Basic Knowledge preparation
First, opencv currently only supports training and detection
Pedestrian training:Http://www.tuicool.com/articles/MvYfuiCharacter Recognition: http://www.haogongju.net/art/2328003The approximate flow of training with OPENCV using hog features for SVM algorithm is 1) Set up the training sample setTwo sets of data are required, one is the category of the data, and the other is the vector information of the data.2) Set SVM par
yesterday saw a day of OPENCV training classifier information, want to try. After yesterday's toss of the day finally successful training out of their own classifier, although the effect is not good, but is a better beginning. I encountered a lot of problems throughout the process, here and share with you, hope to help you. 1. The process of creating a positive s
The opencv3.0 and 2.4 SVM interfaces are different and can be performed in the following format:
ML::SVM::P arams Params;
Params.svmtype = ml::svm::c_svc;
Params.kerneltype = ML::SVM::P oly;
Params.gamma = 3;
ptr
But note that if the error is best to see the opencv3.0 document, which has function prototypes and explanations, I in the actual operation of the process, also made a number of changes
1) Set parameters
SVM has a lot of parameters, but the c_svc and RBF related to only gamma and C, so
normalized the size of the picture, which can be used in the United States 美图秀秀, bulk modification size
4. In the downloaded OpenCV folder, locate the Opencv_createsamples.exe and Opencv_traincascade.exe and paste the two EXE files into the training folder.
5. Create two BOS command files as shown in figure. bat usage and cmd command line are the same, the advantage is that you can save the view
use: Opencv_haartraining.exeGo to the directory where the tool is located, first create the directory: Cascade, and then execute the command:Opencv_haartraining.exe-data./cascade-vec./pos/sample_pos.vec-bg./neg/sample_neg.dat-nstage 20-npos 100-nneg 300 -mem 256-mode all-w 20-h 20-nstage: How many layers to train-npos: Number of positive samples per layer-nneg: Number of negative samples per layerPS: In this step often throw exception, usually negative sample file is wrong, and DAT file name mu
Keywords: cascade classifier, Opencv_traincascadeThe following is a brief description of the operation process:
Prepare positive and negative samples: neg, pos
Positive and negative sample path generation: Dir/a/b>path.txt//path:pos or neg
Positive sample Training Set generation: Opencv_createsamples.exe-info Pos\pos.txt-vec pos\pos.vec-num 799-w 24-h Pause
Sample training: Opencv_train
sample's description file in the execution directory, negative samples of the description of the image to increase the location of the path to solve.Finally, there is no error, the training file will be generated under the-data path. Three: Using a well-trained classifier to do the testing# #TODO haven't found the Performance.exe program yetPerformance.exeUse Python-cv2 to invoke the generated classifier:Import Cv2Cascade = Cv2. Cascadeclassifier ('
Opencv training classifier creation XML document (for conversion)
I found Chinese documents on the Internet and found that most of the articles were reposted, and there were errors in the two articles. After two days of exploration, I finally succeeded in training the classifier, I would like to share with you here.
Http://note.sonots.com/SciSoftware/haartraini
Take advantage of "opencv training classifier preparation XML document"
Understand the command line parameters for creating Functions
Let's take a positive sample as an example:
Suppose there are 5 positive sample image files img1.bmp ,... Img5.bmp; create a TXT text document with a positive sample named info.txtThe content of info.txt is as follows:
Positive/image1.bmp 1 0 0 24 28Positive/image2.bmp 1 0 0
-vec is to specify the file name of the following output VEC file,-info Specify a positive sample description file,-BG Specify a negative sample description file, W and H respectively, the width and height of the sample,-num indicates the number of positive samples. After executing the command, a Face.vec file is produced in the current directory.Step 4: Start trainingCreate a new XML folder in the current directory to hold the generated. xml file.Opencv_haartraining-data Xml-vec face.vec-bg non
Generate necessaryProgram:
Add all header files under the D: \ opencv \ apps \ haartraining directory to the "header file", and add all CPP files to the "source file", as shown below:
When compiling createsamples.exe, remove the haartraining. cpp and performance. cpp files (because these two CPP files are used to generate the corresponding exe program)
Click compile and run as follows:
Createsamples.exe (generate a sample description file)
The realization of OPENCV's CVSVM is based on LIBSVM,LIBSVM, a world-famous SVM library written by Professor Lin Chih-jen of Taiwan University (probably the most widely used library in the industry today). The input of SVM's Perdict method is the characteristic of the data to be predicted, also called features. Here, we enter a feature that is all pixels of the image. Since SVM requires that the input should be a vector, and mat is a matrix corresponding to the width of the image, we need to use
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.