The samples were updated through CommandLineParser class
This commit is contained in:
parent
2c1e913b2d
commit
07a9d3558e
samples/cpp
@ -1,3 +1,4 @@
|
|||||||
|
#include "opencv2/core/core.hpp"
|
||||||
#include "opencv2/highgui/highgui.hpp"
|
#include "opencv2/highgui/highgui.hpp"
|
||||||
#include "opencv2/imgproc/imgproc.hpp"
|
#include "opencv2/imgproc/imgproc.hpp"
|
||||||
#include "opencv2/features2d/features2d.hpp"
|
#include "opencv2/features2d/features2d.hpp"
|
||||||
@ -27,29 +28,26 @@ const string bowImageDescriptorsDir = "/bowImageDescriptors";
|
|||||||
const string svmsDir = "/svms";
|
const string svmsDir = "/svms";
|
||||||
const string plotsDir = "/plots";
|
const string plotsDir = "/plots";
|
||||||
|
|
||||||
void help(char** argv)
|
void help()
|
||||||
{
|
{
|
||||||
cout << "\nThis program shows how to read in, train on and produce test results for the PASCAL VOC (Visual Object Challenge) data. \n"
|
printf("\nThis program shows how to read in, train on and produce test results for the PASCAL VOC (Visual Object Challenge) data. \n"
|
||||||
<< "It shows how to use detectors, descriptors and recognition methods \n"
|
"It shows how to use detectors, descriptors and recognition methods \n"
|
||||||
"Using OpenCV version %s\n" << CV_VERSION << "\n"
|
"Usage: \n"
|
||||||
<< "Call: \n"
|
"Format:\n"
|
||||||
<< "Format:\n ./" << argv[0] << " [VOC path] [result directory] \n"
|
"./bagofwords_classification \n"
|
||||||
<< " or: \n"
|
"--voc_path=<Path to Pascal VOC data (e.g. /home/my/VOCdevkit/VOC2010). \n"
|
||||||
<< " ./" << argv[0] << " [VOC path] [result directory] [feature detector] [descriptor extractor] [descriptor matcher] \n"
|
" Note: VOC2007-VOC2010 are supported.> \n"
|
||||||
<< "\n"
|
"--result_directory=<Path to result directory. Following folders will be created in [result directory]: \n"
|
||||||
<< "Input parameters: \n"
|
" bowImageDescriptors - to store image descriptors, \n"
|
||||||
<< "[VOC path] Path to Pascal VOC data (e.g. /home/my/VOCdevkit/VOC2010). Note: VOC2007-VOC2010 are supported. \n"
|
" svms - to store trained svms, \n"
|
||||||
<< "[result directory] Path to result diractory. Following folders will be created in [result directory]: \n"
|
" plots - to store files for plots creating. \n"
|
||||||
<< " bowImageDescriptors - to store image descriptors, \n"
|
"[--feature_detector]=<Feature detector name (e.g. SURF, FAST...) - see createFeatureDetector() function in detectors.cpp \n"
|
||||||
<< " svms - to store trained svms, \n"
|
" Currently 12/2010, this is FAST, STAR, SIFT, SURF, MSER, GFTT, HARRIS> \n"
|
||||||
<< " plots - to store files for plots creating. \n"
|
"[--descriptor_extractor]=<Descriptor extractor name (e.g. SURF, SIFT) - see createDescriptorExtractor() function in descriptors.cpp \n"
|
||||||
<< "[feature detector] Feature detector name (e.g. SURF, FAST...) - see createFeatureDetector() function in detectors.cpp \n"
|
" Currently 12/2010, this is SURF, OpponentSIFT, SIFT, OpponentSURF, BRIEF> \n"
|
||||||
<< " Currently 12/2010, this is FAST, STAR, SIFT, SURF, MSER, GFTT, HARRIS \n"
|
"[--descriptor_matcher]=<Descriptor matcher name (e.g. BruteForce) - see createDescriptorMatcher() function in matchers.cpp \n"
|
||||||
<< "[descriptor extractor] Descriptor extractor name (e.g. SURF, SIFT) - see createDescriptorExtractor() function in descriptors.cpp \n"
|
" Currently 12/2010, this is BruteForce, BruteForce-L1, FlannBased, BruteForce-Hamming, BruteForce-HammingLUT> \n"
|
||||||
<< " Currently 12/2010, this is SURF, OpponentSIFT, SIFT, OpponentSURF, BRIEF \n"
|
"\n");
|
||||||
<< "[descriptor matcher] Descriptor matcher name (e.g. BruteForce) - see createDescriptorMatcher() function in matchers.cpp \n"
|
|
||||||
<< " Currently 12/2010, this is BruteForce, BruteForce-L1, FlannBased, BruteForce-Hamming, BruteForce-HammingLUT \n"
|
|
||||||
<< "\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2507,16 +2505,24 @@ void computeGnuPlotOutput( const string& resPath, const string& objClassName, Vo
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, const char** argv)
|
||||||
{
|
{
|
||||||
if( argc != 3 && argc != 6 )
|
help();
|
||||||
|
|
||||||
|
CommandLineParser parser(argc, argv);
|
||||||
|
|
||||||
|
const string vocPath = parser.get<string>("--voc_path");
|
||||||
|
const string resPath = parser.get<string>("--result_directory");
|
||||||
|
const string featureDetectName = parser.get<string>("--feature_detector");
|
||||||
|
const string descExtName = parser.get<string>("--descriptor_extractor");
|
||||||
|
const string descMatchName = parser.get<string>("--descriptor_matcher");
|
||||||
|
|
||||||
|
if( vocPath.empty() || resPath.empty())
|
||||||
{
|
{
|
||||||
help(argv);
|
help();
|
||||||
|
printf("Cannot find --voc_path=%s or --result_directory=%s\n", vocPath.c_str(), resPath.c_str());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const string vocPath = argv[1], resPath = argv[2];
|
|
||||||
|
|
||||||
// Read or set default parameters
|
// Read or set default parameters
|
||||||
string vocName;
|
string vocName;
|
||||||
DDMParams ddmParams;
|
DDMParams ddmParams;
|
||||||
@ -2534,12 +2540,12 @@ int main(int argc, char** argv)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
vocName = getVocName(vocPath);
|
vocName = getVocName(vocPath);
|
||||||
if( argc!= 6 )
|
if( featureDetectName.empty() || descExtName.empty() || descMatchName.empty())
|
||||||
{
|
{
|
||||||
cout << "Feature detector, descriptor extractor, descriptor matcher must be set" << endl;
|
cout << "Feature detector, descriptor extractor, descriptor matcher must be set" << endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
ddmParams = DDMParams( argv[3], argv[4], argv[5] ); // from command line
|
ddmParams = DDMParams( featureDetectName.c_str(), descExtName.c_str(), descMatchName.c_str()); // from command line
|
||||||
// vocabTrainParams and svmTrainParamsExt is set by defaults
|
// vocabTrainParams and svmTrainParamsExt is set by defaults
|
||||||
paramsFS.open( resPath + "/" + paramsFile, FileStorage::WRITE );
|
paramsFS.open( resPath + "/" + paramsFile, FileStorage::WRITE );
|
||||||
if( paramsFS.isOpened() )
|
if( paramsFS.isOpened() )
|
||||||
|
@ -1,32 +1,40 @@
|
|||||||
|
#include "opencv2/core/core.hpp"
|
||||||
#include "opencv2/video/background_segm.hpp"
|
#include "opencv2/video/background_segm.hpp"
|
||||||
#include "opencv2/highgui/highgui.hpp"
|
#include "opencv2/highgui/highgui.hpp"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
using namespace cv;
|
using namespace cv;
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
void help()
|
void help()
|
||||||
{
|
{
|
||||||
printf("\nDo background segmentation, especially demonstrating the use of cvUpdateBGStatModel().\n"
|
printf("\nDo background segmentation, especially demonstrating the use of cvUpdateBGStatModel().\n"
|
||||||
"Learns the background at the start and then segments.\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"
|
" Learning is togged by the space key. Will read from file or camera\n"
|
||||||
"Call:\n"
|
"Usage: \n"
|
||||||
"./ bgfg_segm [file name -- if no name, read from camera]\n\n");
|
" ./bgfg_segm [--file_name]=<input file, camera as defautl>\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
//this is a sample for foreground detection functions
|
//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;
|
VideoCapture cap;
|
||||||
bool update_bg_model = true;
|
bool update_bg_model = true;
|
||||||
|
|
||||||
if( argc < 2 )
|
|
||||||
|
if(fileName == "0" )
|
||||||
cap.open(0);
|
cap.open(0);
|
||||||
else
|
else
|
||||||
cap.open(argv[1]);
|
cap.open(fileName.c_str());
|
||||||
help();
|
|
||||||
|
|
||||||
if( !cap.isOpened() )
|
if( !cap.isOpened() )
|
||||||
{
|
{
|
||||||
|
help();
|
||||||
printf("can not open camera or video file\n");
|
printf("can not open camera or video file\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user