diff --git a/examples/Demo.cpp b/examples/Demo.cpp index 6b081b74e4732a9acdeeaa4ddbb974684f3c8aa1..9166d48e54ccef8bb878f7b2ba35b6b4d98520cf 100644 --- a/examples/Demo.cpp +++ b/examples/Demo.cpp @@ -31,8 +31,10 @@ int main(int argc, char **argv) /* Background Subtraction Methods */ auto algorithmsName = BGS_Factory::Instance()->GetRegisteredAlgorithmsName(); - - auto key = 0; + + std::cout << "List of available algorithms:" << std::endl; + std::copy(algorithmsName.begin(), algorithmsName.end(), std::ostream_iterator<std::string>(std::cout, "\n")); + for (const std::string& algorithmName : algorithmsName) { std::cout << "Running " << algorithmName << std::endl; @@ -43,6 +45,7 @@ int main(int argc, char **argv) capture.set(CV_CAP_PROP_POS_FRAMES, 0); // Set index to 0 (start frame) auto frame_counter = 0; std::cout << "Press 's' to stop:" << std::endl; + auto key = 0; while (key != 's') { // Capture frame-by-frame diff --git a/examples/Demo2.cpp b/examples/Demo2.cpp index 544c6aeb7932abd2d51978421ef9b5f73e19b68c..dd867048ecf172556d525a2307fbe99b98793898 100644 --- a/examples/Demo2.cpp +++ b/examples/Demo2.cpp @@ -19,8 +19,10 @@ int main(int argc, char **argv) /* Background Subtraction Methods */ auto algorithmsName = BGS_Factory::Instance()->GetRegisteredAlgorithmsName(); - - auto key = 0; + + std::cout << "List of available algorithms:" << std::endl; + std::copy(algorithmsName.begin(), algorithmsName.end(), std::ostream_iterator<std::string>(std::cout, "\n")); + for (const std::string& algorithmName : algorithmsName) { std::cout << "Running " << algorithmName << std::endl; @@ -28,6 +30,7 @@ int main(int argc, char **argv) auto frame_counter = 0; std::cout << "Press 's' to stop:" << std::endl; + auto key = 0; while (key != 's') { // Capture frame-by-frame diff --git a/src/algorithms/_template_/MyBGS.cpp b/src/algorithms/_template_/MyBGS.cpp index 402dddbb8bd8528b3236e9bee9e4437cb525d345..bdab28a300dcac26672c816ff5f22999953f08ea 100644 --- a/src/algorithms/_template_/MyBGS.cpp +++ b/src/algorithms/_template_/MyBGS.cpp @@ -26,9 +26,22 @@ void MyBGS::process(const cv::Mat &img_input, cv::Mat &img_output, cv::Mat &img_ cv::cvtColor(img_foreground, img_foreground, CV_BGR2GRAY); cv::threshold(img_foreground, img_foreground, 15, 255, cv::THRESH_BINARY); + +#ifndef MEX_COMPILE_FLAG + if (showOutput) + cv::imshow(algorithmName + "_FG", img_foreground); +#endif img_foreground.copyTo(img_output); img_previous.copyTo(img_bgmodel); img_input.copyTo(img_previous); } + +void MyBGS::save_config(cv::FileStorage &fs) { + fs << "showOutput" << showOutput; +} + +void MyBGS::load_config(cv::FileStorage &fs) { + fs["showOutput"] >> showOutput; +} diff --git a/src/algorithms/_template_/MyBGS.h b/src/algorithms/_template_/MyBGS.h index db9b3357dd163b43d5a7badf1326d16a828a13fc..0f52f2229b6e21ec70809d295acaab4d607e5621 100644 --- a/src/algorithms/_template_/MyBGS.h +++ b/src/algorithms/_template_/MyBGS.h @@ -20,8 +20,8 @@ namespace bgslibrary void process(const cv::Mat &img_input, cv::Mat &img_output, cv::Mat &img_bgmodel); private: - void save_config(cv::FileStorage &fs) {} - void load_config(cv::FileStorage &fs) {} + void save_config(cv::FileStorage &fs); + void load_config(cv::FileStorage &fs); }; bgs_register(MyBGS);