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

new test

parent 09f48f44
Branches
No related tags found
No related merge requests found
......@@ -14,7 +14,7 @@ based on original demo.cpp
#define PROCESS_CENTER_VERSION_MAJOR 0
#define PROCESS_CENTER_VERSION_MINOR 1
#define PROCESS_CENTER_VERSION_MINOR 2
//opencv
#include <opencv2/opencv.hpp>
......@@ -105,7 +105,7 @@ int main(int argc, char * argv[])
outputDir = string(testOutputDir);
}
cout <<"args: -i "<<inputDir<<" -a "<<amountFiles << "-c" << centerFileString<<" -o " << outputDir;
cout <<"args: -i "<<inputDir<<" -a "<<amountFiles << " -c" << centerFileString<<" -o " << outputDir;
//!**** end parse input***********/
//./program -i pathToInputDir -a amountOfJpgFiles -o outPutPath
......@@ -277,16 +277,17 @@ int main(int argc, char * argv[])
}
cout <<"b) we train the background with random choosen files"<< fileName<<endl;
int j=255;
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++)
for(i=0;i<amountTrainingSteps;i++,j--)
{
//random index
int index = rand() % steps + begin; //TODO: double check no double draw ??
fileName = inputDir + TToolBox::getFileName(index);
myRandomTrainList.push_back(fileName);
cout <<"load rnd file :"<< fileName<<endl;
cout <<"\t"<<i <<"\t of \t"<<amountFilesload<<" rnd file :"<< fileName<<endl;
img_input = imread(fileName.c_str(), CV_LOAD_IMAGE_COLOR);
......@@ -297,12 +298,17 @@ int main(int argc, char * argv[])
//cv::imshow("input", img_input);
cv::Mat img_mask;
cv::Mat img_bkgmodel;
//adapter learning rate
if(j>62)
bgs->setLearningRate(j);
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);
// //we save the bk gmodel
// std::string bkTestFileName = inputDir + "bk_"+TToolBox::mNzero(i)+".jpg";
// imwrite(bkTestFileName.c_str(),img_bkgmodel);
}
else
{
......@@ -325,7 +331,7 @@ int main(int argc, char * argv[])
clock_t begin = clock();
fileName = inputDir + TToolBox::getFileName(i);
cout <<"\t"<<i<<"of \t"<<amountFiles<<" load file :"<< fileName<<endl;
cout <<"\t"<<i<<"\tof \t"<<amountFiles<<" load file :"<< fileName<<endl;
//cv::imwrite(convert.str().c_str(), img_output);
img_input = imread(fileName.c_str(), CV_LOAD_IMAGE_COLOR);
......
......@@ -54,11 +54,11 @@ void Tapter::setPathOut(std::string outPath)
}
//void Tapter::setPaths(std::string inPath,std::string outPath)
//{
// inputPath = inPath;
// outputPath = outPath;
//}
void Tapter::setLearningRate(int rate)
{
learningRate = rate;
}
void Tapter::setInitialFrameCounter(int counter)
{
frameCounter = counter;
......
......@@ -28,7 +28,6 @@ along with BGSLibrary. If not, see <http://www.gnu.org/licenses/>.
#include "ttoolbox.h"
//#define MC_SHOW_STEP_ANALYSE
using namespace lb_library;
......@@ -70,6 +69,9 @@ namespace bgslibrary
//! other no write
void setFlagWrite(short flag);
//! set learning rate
void setLearningRate(int rate);
//! 1 is on
//! other no write
void setFlagWriteDBGpic(short flag);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment