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

test bk model needs static picture

parent cf0601db
Branches
No related tags found
No related merge requests found
......@@ -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;
}
......
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment