The samples were updated through CommandLineParser class

This commit is contained in:
Kirill Kornyakov
2011-06-03 16:41:41 +00:00
parent 2c1e913b2d
commit 07a9d3558e
2 changed files with 53 additions and 39 deletions

View File

@@ -1,32 +1,40 @@
#include "opencv2/core/core.hpp"
#include "opencv2/video/background_segm.hpp"
#include "opencv2/highgui/highgui.hpp"
#include <stdio.h>
using namespace cv;
using namespace std;
void help()
{
printf("\nDo background segmentation, especially demonstrating the use of cvUpdateBGStatModel().\n"
"Learns the background at the start and then segments.\n"
"Learning is togged by the space key. Will read from file or camera\n"
"Call:\n"
"./ bgfg_segm [file name -- if no name, read from camera]\n\n");
" Learns the background at the start and then segments.\n"
" Learning is togged by the space key. Will read from file or camera\n"
"Usage: \n"
" ./bgfg_segm [--file_name]=<input file, camera as defautl>\n\n");
}
//this is a sample for foreground detection functions
int main(int argc, char** argv)
int main(int argc, const char** argv)
{
help();
CommandLineParser parser(argc, argv);
string fileName = parser.get<string>("file_name", "0");
VideoCapture cap;
bool update_bg_model = true;
if( argc < 2 )
if(fileName == "0" )
cap.open(0);
else
cap.open(argv[1]);
help();
cap.open(fileName.c_str());
if( !cap.isOpened() )
{
help();
printf("can not open camera or video file\n");
return -1;
}