Skip to content
Snippets Groups Projects
Commit e727e0e9 authored by Andrews Sobral's avatar Andrews Sobral
Browse files

fixed demo and template

parent 72d02128
No related branches found
No related tags found
No related merge requests found
...@@ -31,8 +31,10 @@ int main(int argc, char **argv) ...@@ -31,8 +31,10 @@ int main(int argc, char **argv)
/* Background Subtraction Methods */ /* Background Subtraction Methods */
auto algorithmsName = BGS_Factory::Instance()->GetRegisteredAlgorithmsName(); 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) for (const std::string& algorithmName : algorithmsName)
{ {
std::cout << "Running " << algorithmName << std::endl; std::cout << "Running " << algorithmName << std::endl;
...@@ -43,6 +45,7 @@ int main(int argc, char **argv) ...@@ -43,6 +45,7 @@ int main(int argc, char **argv)
capture.set(CV_CAP_PROP_POS_FRAMES, 0); // Set index to 0 (start frame) capture.set(CV_CAP_PROP_POS_FRAMES, 0); // Set index to 0 (start frame)
auto frame_counter = 0; auto frame_counter = 0;
std::cout << "Press 's' to stop:" << std::endl; std::cout << "Press 's' to stop:" << std::endl;
auto key = 0;
while (key != 's') while (key != 's')
{ {
// Capture frame-by-frame // Capture frame-by-frame
......
...@@ -19,8 +19,10 @@ int main(int argc, char **argv) ...@@ -19,8 +19,10 @@ int main(int argc, char **argv)
/* Background Subtraction Methods */ /* Background Subtraction Methods */
auto algorithmsName = BGS_Factory::Instance()->GetRegisteredAlgorithmsName(); 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) for (const std::string& algorithmName : algorithmsName)
{ {
std::cout << "Running " << algorithmName << std::endl; std::cout << "Running " << algorithmName << std::endl;
...@@ -28,6 +30,7 @@ int main(int argc, char **argv) ...@@ -28,6 +30,7 @@ int main(int argc, char **argv)
auto frame_counter = 0; auto frame_counter = 0;
std::cout << "Press 's' to stop:" << std::endl; std::cout << "Press 's' to stop:" << std::endl;
auto key = 0;
while (key != 's') while (key != 's')
{ {
// Capture frame-by-frame // Capture frame-by-frame
......
...@@ -26,9 +26,22 @@ void MyBGS::process(const cv::Mat &img_input, cv::Mat &img_output, cv::Mat &img_ ...@@ -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::cvtColor(img_foreground, img_foreground, CV_BGR2GRAY);
cv::threshold(img_foreground, img_foreground, 15, 255, cv::THRESH_BINARY); 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_foreground.copyTo(img_output);
img_previous.copyTo(img_bgmodel); img_previous.copyTo(img_bgmodel);
img_input.copyTo(img_previous); 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;
}
...@@ -20,8 +20,8 @@ namespace bgslibrary ...@@ -20,8 +20,8 @@ namespace bgslibrary
void process(const cv::Mat &img_input, cv::Mat &img_output, cv::Mat &img_bgmodel); void process(const cv::Mat &img_input, cv::Mat &img_output, cv::Mat &img_bgmodel);
private: private:
void save_config(cv::FileStorage &fs) {} void save_config(cv::FileStorage &fs);
void load_config(cv::FileStorage &fs) {} void load_config(cv::FileStorage &fs);
}; };
bgs_register(MyBGS); bgs_register(MyBGS);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment