diff --git a/Demo.cpp b/Demo.cpp index cf9f067c891c4a1a4d4163a7e562dceef7ba90f9..7eb867bd80978259484eeafdba20096e2af37832 100644 --- a/Demo.cpp +++ b/Demo.cpp @@ -234,25 +234,27 @@ int main(int argc, char * argv[]) cout <<"circleRadius: "<< circleRadius<<endl; fsCen.release(); - //first the static pic********** - //std::string fileName = getFileName(begin); - std::string staticFile = inputDir+"/bk.jpg"; - cout <<"a) load first static background pic :"<< staticFile<<endl; - img_input = imread(staticFile.c_str(), CV_LOAD_IMAGE_COLOR); - if(img_input.data ) - { - //we cut out a smaller ROI - img_input = TToolBox::cropImageCircle(img_input,circleCenterX,circleCenterY,circleRadius); - - cv::Mat img_mask; - cv::Mat img_bkgmodel; - bgs->process(img_input, img_mask, img_bkgmodel); - } - else - { - cout<<"error loading file: "<< staticFile<<", will abort"<<endl; - return EXIT_FAILURE; - } +// //first the static pic********** +// //std::string fileName = getFileName(begin); +// std::string staticFile = inputDir+"/bk.jpg"; +// cout <<"a) load first static background pic :"<< staticFile<<endl; +// img_input = imread(staticFile.c_str(), CV_LOAD_IMAGE_COLOR); +// if(img_input.data ) +// { +// //we cut out a smaller ROI +// img_input = TToolBox::cropImageCircle(img_input,circleCenterX,circleCenterY,circleRadius); + +// cv::Mat img_mask; +// cv::Mat img_bkgmodel; +// bgs->process(img_input, img_mask, img_bkgmodel); + + +// } +// else +// { +// cout<<"error loading file: "<< staticFile<<", will abort"<<endl; +// return EXIT_FAILURE; +// } std::string fileName; @@ -276,6 +278,7 @@ int main(int argc, char * argv[]) cout <<"b) we train the background with random choosen files"<< fileName<<endl; vector<string> myRandomTrainList; //we save all draws in a list which will save to the results + cv::Mat img_bkgmodel; for(i=0;i<amountTrainingSteps;i++) { //random index @@ -294,8 +297,12 @@ int main(int argc, char * argv[]) //cv::imshow("input", img_input); cv::Mat img_mask; - cv::Mat img_bkgmodel; + bgs->process(img_input, img_mask, img_bkgmodel); // by default, it shows automatically the foreground mask image + + //we save the bk gmodel + std::string bkTestFileName = inputDir + "bk_"+TToolBox::mNzero(i)+".jpg"; + imwrite(bkTestFileName.c_str(),img_bkgmodel); } else { @@ -304,6 +311,7 @@ int main(int argc, char * argv[]) } } + cout <<"c) we produce train the background with random choosen files"<< fileName<<endl; bgs->setInitialFrameCounter(0); bgs->setFlagWrite(1); @@ -317,7 +325,7 @@ int main(int argc, char * argv[]) clock_t begin = clock(); fileName = inputDir + TToolBox::getFileName(i); - cout <<"\t"<<i<<"of \t"<<begin+steps<<"load file :"<< fileName<<endl; + cout <<"\t"<<i<<"of \t"<<amountFiles<<" load file :"<< fileName<<endl; //cv::imwrite(convert.str().c_str(), img_output); img_input = imread(fileName.c_str(), CV_LOAD_IMAGE_COLOR); @@ -354,7 +362,7 @@ int main(int argc, char * argv[]) clock_t endAll = clock(); double elapsedSecTotal = double(endAll - beginAll) / CLOCKS_PER_SEC; - cout <<"process single pic:\t"<<elapsedSecs<<" s \t:"<<amountFiles<<"\t-\t"<<(int)(elapsedSecTotal/60)<<" min"<<endl; + cout <<"process single pic:\t"<<elapsedSecs<<" s - \t\t"<<(int)(elapsedSecTotal/60)<<" min -\t"<<(int)(elapsedSecTotal/60/60)<<" h"<<endl; } diff --git a/package_bgs/Tapter.cpp b/package_bgs/Tapter.cpp index e55c5e52a3778117b2ca23f0e85b3d93c49e3335..39744016729078d05a4a85235e7e7eabec6804b5 100644 --- a/package_bgs/Tapter.cpp +++ b/package_bgs/Tapter.cpp @@ -72,9 +72,6 @@ void Tapter::process(const cv::Mat &img_input, cv::Mat &img_output, cv::Mat &img IplImage *frame = new IplImage(img_input); - - - if (firstTime) { int w = cvGetSize(frame).width;