train.cpp
Go to the documentation of this file.
1 /**************************************************************************************************
2  Software License Agreement (BSD License)
3 
4  Copyright (c) 2011-2013, LAR toolkit developers - University of Aveiro - http://lars.mec.ua.pt
5  All rights reserved.
6 
7  Redistribution and use in source and binary forms, with or without modification, are permitted
8  provided that the following conditions are met:
9 
10  *Redistributions of source code must retain the above copyright notice, this list of
11  conditions and the following disclaimer.
12  *Redistributions in binary form must reproduce the above copyright notice, this list of
13  conditions and the following disclaimer in the documentation and/or other materials provided
14  with the distribution.
15  *Neither the name of the University of Aveiro nor the names of its contributors may be used to
16  endorse or promote products derived from this software without specific prior written permission.
17 
18  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
19  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20  FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
21  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
24  IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 ***************************************************************************************************/
27  #include "peddetect.h"
28 
29 int main (int argc, char **argv)
30 {
31 
32 /* STEP 2. Opening the file */
33 //1. Declare a structure to keep the data
34  CvMLData cvml;
35 //2. Read the file
36  cvml.read_csv ("/home/pedrobatista/workingcopy/lar3/perception/pedestrians/PedestrianDetect/train_15000_boot3.csv");
37 //3. Indicate which column is the response
38 
39  cvml.set_response_idx (0);
40 // CvTrainTestSplit cvtts (8000, true);
41 // cvml.set_train_test_split (&cvtts);
42 
43  const CvMat* Resp = cvml.get_responses();
44  const CvMat* Values = cvml.get_values();
45 
46  Mat RespM(Resp, false);
47  Mat ValM(Values,false);
48 
49 // RespM.assignTo(RespM, CV_32F );
50 // ValM.assignTo(ValM, CV_32F );
51 
52 
53 
54  Mat trainData = ValM.colRange(1, 15001);
55  cout<<trainData.size()<<endl;
56 // cout<<trainData.at<float>(0,0)<<endl;
57 
58 // Mat varIdx(1,NRFEATURE,CV_32F);
59 //
60 // for (int n=0; n<varIdx.cols;n++)
61 // varIdx.at<float>(1,n)=n;
62 //
63 // Mat sampleIdx(1,trainData.rows,CV_32F);
64 //
65 // for (int i=0; i<sampleIdx.cols;i++)
66 // sampleIdx.at<float>(1,i)=i;
67 //
68 // Mat varType(1,trainData.rows,CV_32F);
69 //
70 //
71 // for (int y=0; y<sampleIdx.cols;y++)
72 // varType.at<float>(1,y)=CV_VAR_CATEGORICAL;
73 
74 
75 
76 
77  CvBoost boost;
78 
79  boost.train( trainData,
80  CV_ROW_SAMPLE,
81  RespM,
82  Mat(),
83  Mat(),
84  Mat(),
85  Mat(),
86  CvBoostParams(CvBoost::REAL,2000, 0.95, 2, false, 0),
87  false);
88 
89 
90 // float elements[10];
91 // CvSeq * weak = boost.get_weak_predictors();
92 //
93 // CvtSeqToArray(weak,elements,CV_WHOLE_SEQ);
94 
95 
96 
97  // cout<<weak->total<<endl;
98 
99 // CvPoint pt0;
100 
101 // for(int i = 0; i < weak->total; i++)
102 // {
103 // pt0 = *CV_GET_SEQ_ELEM( CvPoint, weak, i );
104 // cout<<pt0.x<<endl;
105 // }
106 
107 
108 
109  boost.save ("./trained_boost_10Kf_2000w_13Ks_m8_M64_boot1.xml", "boost");
110 
111 
112  return 0;
113 
114 }
int main(int argc, char **argv)
Definition: train.cpp:29


pedestrian_detect
Author(s): Pedro Batista
autogenerated on Mon Mar 2 2015 01:32:33