xml_test.cpp
Go to the documentation of this file.
00001 #include<cob_people_detection/subspace_analysis.h>
00002 #include<opencv/cv.h>
00003 #include<opencv/highgui.h>
00004 #include<iostream>
00005 #include<fstream>
00006 
00007 int main(int argc, const char *argv[])
00008 {
00009 
00010         std::string file1 = "/home/goa-tz/git/care-o-bot/cob_people_perception/cob_people_detection/common/files/training_data/30.xml";
00011         std::string file2 = "/home/goa-tz/git/care-o-bot/cob_people_perception/cob_people_detection/common/files/training_data/31.xml";
00012         std::string file3 = "/home/goa-tz/git/care-o-bot/cob_people_perception/cob_people_detection/common/files/training_data/32.xml";
00013         std::string file4 = "/home/goa-tz/git/care-o-bot/cob_people_perception/cob_people_detection/common/files/training_data/33.xml";
00014         std::string file5 = "/home/goa-tz/git/care-o-bot/cob_people_perception/cob_people_detection/common/files/training_data/34.xml";
00015         std::string file6 = "/home/goa-tz/git/care-o-bot/cob_people_perception/cob_people_detection/common/files/training_data/35.xml";
00016         std::string file7 = "/home/goa-tz/git/care-o-bot/cob_people_perception/cob_people_detection/common/files/training_data/36.xml";
00017         std::string file8 = "/home/goa-tz/git/care-o-bot/cob_people_perception/cob_people_detection/common/files/training_data/37.xml";
00018         std::string file9 = "/home/goa-tz/git/care-o-bot/cob_people_perception/cob_people_detection/common/files/training_data/38.xml";
00019         std::string file10 = "/home/goa-tz/git/care-o-bot/cob_people_perception/cob_people_detection/common/files/training_data/39.xml";
00020         std::string file11 = "/home/goa-tz/git/care-o-bot/cob_people_perception/cob_people_detection/common/files/training_data/40.xml";
00021         std::string file12 = "/home/goa-tz/git/care-o-bot/cob_people_perception/cob_people_detection/common/files/training_data/41.xml";
00022         std::string file13 = "/home/goa-tz/git/care-o-bot/cob_people_perception/cob_people_detection/common/files/training_data/42.xml";
00023         std::string file14 = "/home/goa-tz/git/care-o-bot/cob_people_perception/cob_people_detection/common/files/training_data/43.xml";
00024 
00025         std::vector < std::string > in_vec;
00026         std::vector<int> label_vec;
00027         in_vec.push_back(file1);
00028         label_vec.push_back(0);
00029         in_vec.push_back(file2);
00030         label_vec.push_back(0);
00031         in_vec.push_back(file3);
00032         label_vec.push_back(0);
00033         in_vec.push_back(file4);
00034         label_vec.push_back(0);
00035         in_vec.push_back(file5);
00036         label_vec.push_back(0);
00037         in_vec.push_back(file6);
00038         label_vec.push_back(0);
00039         in_vec.push_back(file7);
00040         label_vec.push_back(0);
00041         in_vec.push_back(file8);
00042         label_vec.push_back(1);
00043         in_vec.push_back(file9);
00044         label_vec.push_back(1);
00045         in_vec.push_back(file10);
00046         label_vec.push_back(1);
00047         in_vec.push_back(file11);
00048         label_vec.push_back(1);
00049         in_vec.push_back(file12);
00050         label_vec.push_back(1);
00051         in_vec.push_back(file13);
00052         label_vec.push_back(1);
00053         in_vec.push_back(file14);
00054         label_vec.push_back(1);
00055         // std::vector<int> label_vec;
00056         std::vector<cv::Mat> img_vec;
00057 
00058         for (int i = 0; i < in_vec.size(); i++)
00059         {
00060                 cv::Mat img;
00061                 cv::FileStorage fs(in_vec[i], cv::FileStorage::READ);
00062                 fs["depthmap"] >> img;
00063                 //img.convertTo(img,CV_8UC1,255);
00064                 //cv::equalizeHist(img,img);
00065                 //cv::imshow("img",img);
00066                 //cv::waitKey(0);
00067                 cv::resize(img, img, cv::Size(120, 120));
00068                 img.convertTo(img, CV_64FC1);
00069                 img_vec.push_back(img);
00070                 fs.release();
00071 
00072         }
00073 
00074         std::vector<cv::Mat> probe_mat_vec;
00075         probe_mat_vec.push_back(img_vec[0]);
00076 
00077         std::cout << "Size Training Set= " << img_vec.size() << std::endl;
00078 
00079         int ss_dim = 2;
00080         //SubspaceAnalysis::Eigenfaces EF;
00081         // EF.init(img_vec,label_vec,ss_dim);
00082         //std::vector<cv::Mat> eigenvecsEF(ss_dim);
00083         //cv::Mat eigenvalsEF,avgEF,projsEF;
00084         //EF.retrieve(eigenvecsEF,eigenvalsEF,avgEF,projsEF,cv::Size(img_vec[0].cols,img_vec[0].rows));
00085         //SubspaceAnalysis::dump_matrix(projsEF,"projEF");
00086 
00087 
00088         //SubspaceAnalysis::Fisherfaces FF;
00089         // FF.init(img_vec,label_vec);
00090 
00091         //cv::Mat eigenvalsFF,avgFF,projsFF;
00092         //std::vector<cv::Mat> eigenvecsFF(ss_dim);
00093         //FF.retrieve(eigenvecsFF,eigenvalsFF,avgFF,projsFF);
00094         //SubspaceAnalysis::dump_matrix(projsFF,"projFF");
00095 
00096         SubspaceAnalysis::FishEigFaces EFF;
00097 
00098         EFF.init(img_vec, label_vec, ss_dim, SubspaceAnalysis::METH_FISHER, true, true);
00099 
00100         for (int i = 0; i < probe_mat_vec.size(); i++)
00101         {
00102                 cv::Mat probe = probe_mat_vec[i];
00105                 //cv::Mat coeff_FF;
00106                 //int c_FF;
00107                 //double DFFS_FF;
00108                 //FF.projectToSubspace(probe,coeff_FF,DFFS_FF);
00109                 //FF.classify(coeff_FF,SubspaceAnalysis::CLASS_SVM,c_FF);
00110                 //std::cout<<"class FF SVM= "<<c_FF<<std::endl;
00111                 //FF.classify(coeff_FF,SubspaceAnalysis::CLASS_KNN,c_FF);
00112                 //std::cout<<"class FF KNN= "<<c_FF<<std::endl;
00113                 //FF.classify(coeff_FF,SubspaceAnalysis::CLASS_DIFS,c_FF);
00114                 //std::cout<<"class FF DIFFS= "<<c_FF<<std::endl;
00115 
00116                 //SubspaceAnalysis::dump_matrix(coeff_FF,"sampleFF");
00117                 //std::cout<<"--------------------------\n";
00118 
00119                 //int c_EF;
00120                 //cv::Mat coeff_EF;
00121                 //double DFFS_EF;
00122                 //EF.projectToSubspace(probe,coeff_EF,DFFS_EF);
00123                 //EF.classify(coeff_EF,SubspaceAnalysis::CLASS_SVM,c_EF);
00124                 //std::cout<<"class EF SVM= "<<c_EF<<std::endl;
00125                 //EF.classify(coeff_EF,SubspaceAnalysis::CLASS_KNN,c_EF);
00126                 //std::cout<<"class EF KNN= "<<c_EF<<std::endl;
00127                 //EF.classify(coeff_EF,SubspaceAnalysis::CLASS_DIFS,c_EF);
00128                 //std::cout<<"class EF DIFFS= "<<c_EF<<std::endl;
00129 
00130                 //SubspaceAnalysis::dump_matrix(coeff_EF,"sampleEF");
00131 
00132                 //std::cout<<"--------------------------\n";
00133 
00134                 int c_EFF;
00135                 cv::Mat coeff_EFF;
00136                 double DFFS_EFF;
00137                 EFF.projectToSubspace(probe, coeff_EFF, DFFS_EFF);
00138                 EFF.classify(coeff_EFF, SubspaceAnalysis::CLASS_SVM, c_EFF);
00139                 std::cout << "class EFF SVM= " << c_EFF << std::endl;
00140                 EFF.classify(coeff_EFF, SubspaceAnalysis::CLASS_KNN, c_EFF);
00141                 std::cout << "class EFF KNN= " << c_EFF << std::endl;
00142                 EFF.classify(coeff_EFF, SubspaceAnalysis::CLASS_DIFS, c_EFF);
00143                 std::cout << "class EFF DIFFS= " << c_EFF << std::endl;
00144 
00145                 SubspaceAnalysis::dump_matrix(coeff_EFF, "sampleEFF");
00146         }
00147 
00148         return 0;
00149 }


cob_people_detection
Author(s): Richard Bormann , Thomas Zwölfer
autogenerated on Fri Aug 28 2015 10:24:13