Navneet Dalal's OLT workflow description
By
Opencviv» 2010-01-23 4: 23
Navneet Dalal provides INRIA on the following websites
Object Detection and localization Toolkit
Http://pascal.inrialpes.fr/soft/olt/
Wilson suryajaya leoputra provides its Windows Version
Http://www.computing.edu.au /~ 12482661/hog.html
Copy all the DLL's (boost_1.34.1 *. dll, blitz_0.9.dll, opencv *. dll) into "<root_project_dir>/debug /"
Navneet Dalal provides executable programs in Linux. You can use other Linux systems to run them. First, you can understand the overall process.
The following describes the process in combination with the oltbinaries \ readme and oltbinaries \ hog \ record files.
1. Download The INRIA person detection database and decompress it to oltbinaries \. Rename 'train _ 64x128_h96 'to 'train', and rename 'test _ 64x128_h96' to 'test '.
2. Run 'runall. Sh' script in Linux.
After the result is displayed, open MATLAB and run plotdet. m to draw the det curve;
------ This is a one-step approach --------------------------------------------------
------- In addition, it also provides a step-by-step execution method -------------------------------------
1. The image provided by the POs. lst list is used to calculate the characteristics of the positive sample R-HOG. The POS. lst List format is as follows:
Train/POS/crop_20.10a.png
Train/POS/crop_1_10b.png
Train/POS/crop_1_11a.png
------ Run the following statement in Linux )------
. /Bin // dump_rhog-W 64,128-C 8, 8-N 2, 2-B 9-G 8-S 0 -- wtscale 2 -- maxvalue 0.2 -- Epsilon 1 -- fullcirc 0-V 3 -- proc rgb_sqrt -- norm l2hys-S 1 train/POS. LST hog/train_pos.rhog
2. Calculate features of negative sample R-HOG
. /Bin // dump_rhog-W 64,128-C 8, 8-N 2, 2-B 9-G 8-S 0 -- wtscale 2 -- maxvalue 0.2 -- Epsilon 1 -- fullcirc 0-V 3 -- proc rgb_sqrt -- norm l2hys-S 10 train/neg. LST hog/train_neg.rhog
3. Training
./Bin // dump4svmlearn-P hog/train_pos.rhog-N hog/train_neg.rhog hog/train_bisvmlight.blt-V
4. Create model file: hog/model_4bisvmlight.alt
./Bin // svm_learn-J 3-B 1-z C-V 1-T 0 hog/train_bisvmlight.blt hog/model_4bisvmlight.alt
5. Create a folder
Mkdir-P hog/hard
6. Category
. /Bin // classify_rhog train/neg. LST hog/hard/list.txt hog/model_4bisvmlight.alt-D hog/hard/hard_neg.txt-C hog/hard/hist.txt-M 0-T 0 -- no_nonmax 1 -- avsize 0 -- margin 0 -- scaleratio 1.2-l n-W 64,128-C 8 8-n-B 9-G 8-S 0 -- wtscale 2 -- maxvalue
0.2 --
Epsilon 1 -- fullcirc 0-V 3 -- proc rgb_sqrt -- norm l2hys
--------
False +/-The classification result will be written into hog/hard/hard_neg.txt
7. Add hard to neg and calculate the rhog feature again.
. /Bin // dump_rhog-W 64,128-C 8, 8-N 2, 2-B 9-G 8-S 0 -- wtscale 2 -- maxvalue 0.2 -- Epsilon 1 -- fullcirc 0-V 3 -- proc rgb_sqrt -- norm l2hys-S 0 hog/hard/hard_neg.txt OG/train_hard_neg.rhog -- poscases 2416 -- negcases 12180 -- dumphard 1 -- hardscore 0 --
Memorylimit 1700
8. Training again
./Bin // dump4svmlearn-P hog/train_pos.rhog-N hog/train_neg.rhog-N hog/train_hard_neg.rhog hog/train_bisvmlight.blt-V 4
9. Get the final model
./Bin // svm_learn-J 3-B 1-z C-V 1-T 0 hog/train_bisvmlight.blt hog/model_4bisvmlight.alt
The 3780 values used in opencv should be model_4bisvmlight.alt in this model. However, its format is unknown and cannot be directly read, but we can study how the svm_learn program generates it. In addition, this model is called by the program classify_rhog. It is estimated that it is an idea to parse this format.
10. Create a folder
Mkdir-P hog/windowtest_negative
11. Negative sample detection results
. /Bin // classify_rhog-W 64,128-C 0.2-n-B 9-g-S 0 -- wtscale 2 -- maxvalue -- Epsilon 1 -- fullcirc 0-V 3 -- proc rgb_sqrt -- norm l2hys-P 1 -- no_nonmax 1 -- nopyramid 0--scaleratio 1.2-T 0-M 0 -- avsize 0 -- margin 0 test/neg. LST hog/windowtest_negative/list.txt
Hog/model_4bisvmlight.alt-C hog/windowtest_negative/histogram.txt
12. Create a folder
Mkdir-P hog/windowtest_positive
13. Positive sample detection results
. /Bin // classify_rhog-W 64,128-C 0.2-n-B 9-g-S 0 -- wtscale 2 -- maxvalue -- Epsilon 1 -- fullcirc 0-V 3 -- proc rgb_sqrt -- norm l2hys-P 1 -- no_nonmax 1 -- nopyramid 1-T 0-M 0 -- avsize 0 -- margin 0 test/POS. LST hog/windowtest_positive/list.txt
Hog/model_4bisvmlight.alt-C hog/windowtest_positive/histogram.txt was last edited by opencviv.
-
Opencviv
-
Opencv pupils
-
-
Post:11
-
Registration:
Top
How to create training samples
By
Opencviv»
This section analyzes the original author's dataset and describes how to create a training sample based on some online materials.
1. How to generate samples from the original image
Compared with inriaperson \ train \ pos (original image), inriaperson \ train_64x128_h96 \ pos (sample generation), we can find that the author cropped some standing persons from the original image, the left-right reflect of the cropped image is required not to be blocked. Take the first image as an example: crop001001. It cut two unblocked people, added the original photo, a total of three images, plus the left and right images, a total of six images.
2. Cropping
You can crop and save the image per program based on opencv1.0. The file name is automatically generated and saved in the newly generated image per folder in the same path.
3. Change the image size
You can use ACDSee software, tools/open in editor, and then select the resize option. Tools/rotate can also implement left-right reflect.
I compiled a program to change the image size in batches. For the code, see the next floor.
4. Create a pos. lst list
Go to the DOS interface, locate the image folder to be created, and enter DIR/B> pos. lst to generate the file list;
-
Opencviv
-
Opencv pupils
-
-
Post:11
-
Registration:
Top
Auto batch resize Program
By
Opencviv»
# Include "cv. H"
# Include "highgui. H"
# Include "cvaux. H"
Int main (INT argc, char * argv [])
{
Iplimage * SRC;
Iplimage * DST = 0;
Cvsize dst_size;
File * f = 0;
Char _ filename [2, 1024];
Int L;
F = fopen (argv [1], "RT ");
If (! F)
{
Fprintf (stderr, "error: the specified file cocould not be loaded \ n ");
Return-1;
}
For (;;)
{
Char * filename = _ filename;
If (f)
{
If (! Fgets (filename, (INT) sizeof (_ filename)-2, F ))
Break;
If (filename [0] = '#')
Continue;
L = strlen (filename );
While (L> 0 & isspace (filename [L-1])
-- L;
Filename [l] = '\ 0 ';
Src = cvloadimage (filename, 1 );
}
Dst_size.width = 96;
Dst_size.height = 160;
DST = cvcreateimage (dst_size, Src-> depth, Src-> nchannels );
Cvresize (SRC, DST, cv_inter_linear );//////////////////
Char * filename2 = _ filename; char * filename3 = _ filename; filename3 = "_96x160.jpg ";
Strncat (filename2, filename, L-4 );
Strcat (filename2, filename3 );
Cvsaveimage (filename2, DST );
}
If (f)
Fclose (f );
Cvwaitkey (-1 );
Cvreleaseimage (& SRC );
Cvreleaseimage (& DST );
Return 0;
}
-
Opencviv
-
Opencv pupils
-
-
Post:11
-
Registration:
Top
Use opencv2.0 to calculate the detection operator directly
By
Opencviv» 2010-01-23 5:36
After carefully analyzing the compute function in cvhop. cpp, you can directly call it to obtain the sample hog, and then train it to obtain the detection operator.
1. Create a sample
2. Call each image
Hog. Compute (IMG, descriptors, size (8, 8), size (0, 0 ));
Generate hog descriptors and save it to the file.
For (Int J = 0; j <3780; j ++)
Fprintf (F, "% F,", descriptors [J]);
3. Use SVM for training and classification to obtain the weight coefficient, that is,
Detection Operator detector []
-
Opencviv
-
Opencv pupils
-
-
Post:11
-
Registration:
Top
Calculate the weight using libsvm
By
Opencviv»
-------- Calculate the weight using libsvm, that is, detector [] ---------- In opencv
To directly use libsvm, You need to construct the data according to its format. The following describes how to use libsvm in MATLAB.
Download libsvm-mat-2.9-1
Method 1:
Switch to the directory where the libsvm-mat-2.9-1 is located, open MATLAB and type:
Mex-Setup
Method 2: MATLAB menu file --> set path Add the path of the libsvm-mat-2.9-1.
----------------------
The following introduces the heart_scale which comes with libsvm-mat-2.9-1 as an example.
----------- Kernel_type is linear ----------------------------------
Load heart_scale.mat
Train_data = heart_scale_inst (1:150 ,:);
Train_label = heart_scale_label (1:150 ,:);
Test_data = heart_scale_inst (151: 270 ,:);
Test_label = heart_scale_label (151: 270 ,:);
Model_linear = svmtrain (train_label, train_data, '-T 0 ');
[Predict_label_l, accuracy_l, dec_values_l] = svmpredict (test_label, test_data, model_linear );
---------- Obtain the model after training -------
Model_linear =
Parameters: [5x1 double]
Nr_class: 2
Totalsv: 58
ROCK:-1.1848
Label: [2x1 double]
PROBA: []
Probb: []
NSv: [2x1 double]
Sv_coef: [58x1 double]
SVS: [58x13 double]
----------- How to obtain the weight coefficient from the model ----
See the following website for details:
Http://www.csie.ntu.edu.tw /~ Cjlin/libsvm/faq.html # f804
For the following two types of problems, we can solve the linear problem (y = wx + B) by weight coefficient w and B.
W = model_linear.svs '* model_linear.sv_coef;
B =-model_linear.rov;
---------
The obtained W is the detector in opencv []
Reprint opencv Forum http://www.opencv.org.cn/forum/viewtopic.php? T = 9146 # p35246