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

new test

parent 09f48f44
No related branches found
No related tags found
No related merge requests found
...@@ -14,7 +14,7 @@ based on original demo.cpp ...@@ -14,7 +14,7 @@ based on original demo.cpp
#define PROCESS_CENTER_VERSION_MAJOR 0 #define PROCESS_CENTER_VERSION_MAJOR 0
#define PROCESS_CENTER_VERSION_MINOR 1 #define PROCESS_CENTER_VERSION_MINOR 2
//opencv //opencv
#include <opencv2/opencv.hpp> #include <opencv2/opencv.hpp>
...@@ -105,7 +105,7 @@ int main(int argc, char * argv[]) ...@@ -105,7 +105,7 @@ int main(int argc, char * argv[])
outputDir = string(testOutputDir); 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***********/ //!**** end parse input***********/
//./program -i pathToInputDir -a amountOfJpgFiles -o outPutPath //./program -i pathToInputDir -a amountOfJpgFiles -o outPutPath
...@@ -277,16 +277,17 @@ int main(int argc, char * argv[]) ...@@ -277,16 +277,17 @@ int main(int argc, char * argv[])
} }
cout <<"b) we train the background with random choosen files"<< fileName<<endl; 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 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++,j--)
for(i=0;i<amountTrainingSteps;i++)
{ {
//random index //random index
int index = rand() % steps + begin; //TODO: double check no double draw ?? int index = rand() % steps + begin; //TODO: double check no double draw ??
fileName = inputDir + TToolBox::getFileName(index); fileName = inputDir + TToolBox::getFileName(index);
myRandomTrainList.push_back(fileName); 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); img_input = imread(fileName.c_str(), CV_LOAD_IMAGE_COLOR);
...@@ -297,12 +298,17 @@ int main(int argc, char * argv[]) ...@@ -297,12 +298,17 @@ int main(int argc, char * argv[])
//cv::imshow("input", img_input); //cv::imshow("input", img_input);
cv::Mat img_mask; 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 bgs->process(img_input, img_mask, img_bkgmodel); // by default, it shows automatically the foreground mask image
//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);
} }
else else
{ {
...@@ -325,7 +331,7 @@ int main(int argc, char * argv[]) ...@@ -325,7 +331,7 @@ int main(int argc, char * argv[])
clock_t begin = clock(); clock_t begin = clock();
fileName = inputDir + TToolBox::getFileName(i); 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); //cv::imwrite(convert.str().c_str(), img_output);
img_input = imread(fileName.c_str(), CV_LOAD_IMAGE_COLOR); img_input = imread(fileName.c_str(), CV_LOAD_IMAGE_COLOR);
......
...@@ -54,11 +54,11 @@ void Tapter::setPathOut(std::string outPath) ...@@ -54,11 +54,11 @@ void Tapter::setPathOut(std::string outPath)
} }
//void Tapter::setPaths(std::string inPath,std::string outPath) void Tapter::setLearningRate(int rate)
//{ {
// inputPath = inPath; learningRate = rate;
// outputPath = outPath;
//} }
void Tapter::setInitialFrameCounter(int counter) void Tapter::setInitialFrameCounter(int counter)
{ {
frameCounter = counter; frameCounter = counter;
......
...@@ -28,7 +28,6 @@ along with BGSLibrary. If not, see <http://www.gnu.org/licenses/>. ...@@ -28,7 +28,6 @@ along with BGSLibrary. If not, see <http://www.gnu.org/licenses/>.
#include "ttoolbox.h" #include "ttoolbox.h"
//#define MC_SHOW_STEP_ANALYSE //#define MC_SHOW_STEP_ANALYSE
using namespace lb_library; using namespace lb_library;
...@@ -70,6 +69,9 @@ namespace bgslibrary ...@@ -70,6 +69,9 @@ namespace bgslibrary
//! other no write //! other no write
void setFlagWrite(short flag); void setFlagWrite(short flag);
//! set learning rate
void setLearningRate(int rate);
//! 1 is on //! 1 is on
//! other no write //! other no write
void setFlagWriteDBGpic(short flag); 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