diff --git a/Demo.cpp b/Demo.cpp index 7eb867bd80978259484eeafdba20096e2af37832..69f75db0af3725da5282fbea542b313c177db48a 100644 --- a/Demo.cpp +++ b/Demo.cpp @@ -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); diff --git a/package_bgs/Tapter.cpp b/package_bgs/Tapter.cpp index 39744016729078d05a4a85235e7e7eabec6804b5..4c485ca6dd938b385f5cba4d3cc19a33e1c231d2 100644 --- a/package_bgs/Tapter.cpp +++ b/package_bgs/Tapter.cpp @@ -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; diff --git a/package_bgs/Tapter.h b/package_bgs/Tapter.h index ce7f6d836dbb9a86db2b4a09a9e346be27804a0d..ccc08db6781dbed3010877a098d58fb0027daa06 100644 --- a/package_bgs/Tapter.h +++ b/package_bgs/Tapter.h @@ -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);