Skip to content
Snippets Groups Projects
Commit ccf00120 authored by Thomas Boy's avatar Thomas Boy
Browse files

pogo debug

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