diff --git a/Demo.cpp b/Demo.cpp index ab1861d21a5ce4d9528faf725957e73d07d41d67..c88d5945177bb9ec6a683511765c5247eab7b649 100644 --- a/Demo.cpp +++ b/Demo.cpp @@ -15,7 +15,7 @@ based on original demo.cpp #define PROCESS_CENTER_VERSION_MAJOR 0 #define PROCESS_CENTER_VERSION_MINOR 9 -#define PROCESS_CENTER_VERSION_MINOR_FIXES 3 +#define PROCESS_CENTER_VERSION_MINOR_FIXES 4 //opencv #include <opencv2/opencv.hpp> @@ -61,7 +61,7 @@ int main(int argc, char * argv[]) } char *testInputDir = getCmdOption(argv, argv + argc, "-i"); - string inputDir("."); + std::string inputDir("."); if (testInputDir) { //test dir exists @@ -78,7 +78,7 @@ int main(int argc, char * argv[]) char *centerFile = getCmdOption(argv, argv + argc, "-c"); - string centerFileString("."); + std::string centerFileString("."); if (centerFile) { //test dir exists @@ -86,7 +86,7 @@ int main(int argc, char * argv[]) } char *testOutputDir = getCmdOption(argv, argv + argc, "-o"); - string outputDir("."); + std::string outputDir("."); if (testOutputDir) { //test dir exists @@ -274,6 +274,7 @@ int main(int argc, char * argv[]) cout <<"\t"<<i <<"\t of \t"<<amountTrainingSteps<<" rnd file :"<< fileName<<endl; img_input = imread(fileName.c_str(), CV_LOAD_IMAGE_COLOR); + cout << " a "<<endl; if(img_input.data ) { @@ -290,6 +291,8 @@ int main(int argc, char * argv[]) bgs->process(img_input, img_mask, img_bkgmodel); // by default, it shows automatically the foreground mask image + cout << " b "<<endl; + // //we save the bk gmodel // std::string bkTestFileName = inputDir + "bk_"+TToolBox::mNzero(i)+".jpg"; // imwrite(bkTestFileName.c_str(),img_bkgmodel); @@ -302,6 +305,8 @@ int main(int argc, char * argv[]) } } + cout << " c "<<endl; + cout <<"c) we produce train the background with random choosen files"<< fileName<<endl; @@ -315,6 +320,8 @@ int main(int argc, char * argv[]) for(frameCounter=0;frameCounter<amountFiles;frameCounter++) { + cout << " d "<<endl; + //measure time consumption clock_t begin = clock(); @@ -331,6 +338,8 @@ int main(int argc, char * argv[]) //we open the file img_input = imread(fileName.c_str(), CV_LOAD_IMAGE_COLOR); + cout << " e "<<endl; + if(img_input.data ) { //! we cut out a smaller ROI, @@ -344,6 +353,8 @@ int main(int argc, char * argv[]) bgs->process(img_input, img_mask, img_bkgmodel); // by default, it shows automatically the foreground mask image + cout << " f "<<endl; + //! step 3) we make we apply a edge detection //TODO make this in a function, how many times is this listed ?? //TODO read from tapter config @@ -412,6 +423,9 @@ int main(int argc, char * argv[]) float areaMinThreshold = 150; float areaMaxThreshold = 300000; //old max threshold was to small //TODO apply moving filter ??, an more adaptive approach + cout << " g "<<endl; + + //iterate all rectangles for( size_t i = 0; i< minRect.size(); i++ ) { @@ -493,6 +507,10 @@ int main(int argc, char * argv[]) muConvexHull = moments(conHull, true ); muConvexHullMassCenter= Point2f( muConvexHull.m10/muConvexHull.m00 , muConvexHull.m01/muConvexHull.m00 ); } + + cout << " h "<<endl; + + }//end after selection is empty { cerr<<"error, no contour found after selection in file: "<< fileName<<endl; @@ -529,11 +547,15 @@ int main(int argc, char * argv[]) #endif + cout << " i "<<endl; //cout<<"we try to write file: "<< i <<endl; //! step 8: we write down all our results in yml file std::string nameOutPutFileData = outputDir + TToolBox::mNzero(frameCounter) + ".yml"; -// //check the string + cout << " j "<<endl; + + +// //check the string // cout <<"write output nameOutPutFileData: "<< nameOutPutFileData<<endl; // if(nameOutPutFileData.empty()) // cerr <<"error: empty string nameOutPutFileData"<<endl; @@ -546,6 +568,7 @@ int main(int argc, char * argv[]) fs << "masscenterconvexhull"<<muConvexHullMassCenter; fs.release(); + cout << " k "<<endl; //! we write from time to time a dbg picture if(frameCounter%everyPic==0) @@ -580,7 +603,7 @@ int main(int argc, char * argv[]) //we add a overlay of our paitings addWeighted( imgDebugPaint2, 0.7, imgOverlay2, 0.3, 0.0, imgOverlay2); //we write the file down - std::string nameOutPutFileDBGpic = outputDir + TToolBox::mNzero(frameCounter) + ".jpg"; + std::string nameOutPutFileDBGpic = outputDir + TToolBox::mNzero(frameCounter) + std::string(".jpg"); // //check the string // cout <<"write dbg file: "<< nameOutPutFileDBGpic<<endl; @@ -589,6 +612,7 @@ int main(int argc, char * argv[]) imwrite(nameOutPutFileDBGpic.c_str(),imgOverlay2); + cout << " l "<<endl; } }//end if the loaded picture has data @@ -608,7 +632,9 @@ int main(int argc, char * argv[]) double elapsedSecTotal = double(endAll - beginAll) / CLOCKS_PER_SEC; cout <<"process single pic:\t"<<elapsedSecs<<" s - \t\t"<<(int)(elapsedSecTotal/60)<<" min -\t"<<(int)(elapsedSecTotal/60/60)<<" h"<<endl; + cout << " --- "<<endl; } + cout << " X "<<endl; //finishing time clock_t endAll = clock();