annotate c/Parameters.cpp @ 398:3399bd48cb40

Ajout d'une méthode pour obtenir le nombre de FPS Méthode de capture des trames vidéos plus résistante aux erreur Utilisation d'un dictionnaire pour les fichier de configuration afin de garder le nom des sections
author Jean-Philippe Jodoin <jpjodoin@gmail.com>
date Mon, 29 Jul 2013 13:46:07 -0400
parents 72aa44072093
children c389fae9689a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
137
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1 #include "Parameters.hpp"
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3 #include <boost/program_options.hpp>
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
4
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5 #include <iostream>
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
6 #include <fstream>
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8 namespace po = boost::program_options;
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9 using namespace std;
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
10
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
11 KLTFeatureTrackingParameters::KLTFeatureTrackingParameters(const int argc, char* argv[]) {
231
249d65ff6c35 merged modifications for windows
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 230 229
diff changeset
12 string configurationFilename;
137
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
13 po::options_description onlyCmdLine("Command line only");
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
14 po::options_description cmdLineAndFile("Command line and configuration file");
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
15
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
16 // configuration filename
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
17 onlyCmdLine.add_options()
141
6f10a227486c modifications to get nframes option working on the command line
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 137
diff changeset
18 ("help,h", "displays this help message")
164
76610dcf3b8d added test code to read trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 141
diff changeset
19 ("tf", "tracks features")
76610dcf3b8d added test code to read trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 141
diff changeset
20 ("gf", "groups features")
348
c64a4f889b97 added safety analysis options to feature tracking (with default values for backward compatibility)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 278
diff changeset
21 ("config-file", po::value<string>(&configurationFilename), "configuration file")
137
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
22 ;
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
23
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
24 po::positional_options_description p;
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
25 p.add("config-file", 1);
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
26
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
27 // common to cnnfiguration and command line
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
28 cmdLineAndFile.add_options()
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
29 ("video-filename", po::value<string>(&videoFilename), "filename of the video to process")
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
30 ("database-filename", po::value<string>(&databaseFilename), "filename of the database where results are saved")
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
31 ("homography-filename", po::value<string>(&homographyFilename), "filename of the homography matrix")
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
32 ("mask-filename", po::value<string>(&maskFilename), "filename of the mask image (where features are detected)")
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
33 ("load-features", po::value<bool>(&loadFeatures), "load features from database")
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
34 ("display", po::value<bool>(&display), "display trajectories on the video")
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
35 ("video-fps", po::value<float>(&videoFPS), "original video frame rate")
229
6e73b112370b correction for unsigned int parameters
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 191
diff changeset
36 ("frame1", po::value<unsigned int>(&frame1), "first frame to process")
278
f21ef87f98f1 resolved issue 2 and problem with negative nframes parameter
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 231
diff changeset
37 ("nframes", po::value<int>(&nFrames), "number of frame to process")
137
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
38 // feature tracking
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
39 ("max-nfeatures", po::value<int>(&maxNFeatures), "maximum number of features added at each frame")
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
40 ("feature-quality", po::value<float>(&featureQuality), "quality level of the good features to track")
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
41 ("min-feature-distanceklt", po::value<float>(&minFeatureDistanceKLT), "minimum distance between features")
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
42 ("window-size", po::value<int>(&windowSize), "size of the search window at each pyramid level")
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
43 ("use-harris-detector", po::value<bool>(&useHarrisDetector), "use of Harris corner detector")
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
44 ("k", po::value<float>(&k), "k parameter to detect good features to track (OpenCV)")
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
45 ("pyramid-level", po::value<int>(&pyramidLevel), "maximal pyramid level in the feature tracking algorithm")
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
46 ("ndisplacements", po::value<unsigned int>(&nDisplacements), "number of displacement to test minimum feature motion")
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
47 ("min-feature-displacement", po::value<float>(&minFeatureDisplacement), "minimum displacement to keep features")
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
48 ("acceleration-bound", po::value<float>(&accelerationBound), "maximum feature acceleration")
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
49 ("deviation-bound", po::value<float>(&deviationBound), "maximum feature deviation")
141
6f10a227486c modifications to get nframes option working on the command line
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 137
diff changeset
50 ("smoothing-halfwidth", po::value<int>(&nFramesSmoothing), "number of frames to smooth positions (half window)")
137
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
51 ("max-number-iterations", po::value<int>(&maxNumberTrackingIterations), "maximum number of iterations to stop feature tracking")
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
52 ("min-tracking-error", po::value<float>(&minTrackingError), "minimum error to reach to stop feature tracking")
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
53 ("min-feature-time", po::value<unsigned int>(&minFeatureTime), "minimum length of a feature (number of frames) to consider a feature for grouping")
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
54 ("mm-connection-distance", po::value<float>(&mmConnectionDistance), "connection distance in feature grouping")
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
55 ("mm-segmentation-distance", po::value<float>(&mmSegmentationDistance), "segmentation distance in feature grouping")
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
56 ("max-distance", po::value<float>(&maxDistance), "maximum distance between features for grouping")
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
57 ("min-velocity-cosine", po::value<float>(&minVelocityCosine), "minimum cosine of the angle between the velocity vectors for grouping")
191
0e60a306d324 added basic code to identify features and save them (crash)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 164
diff changeset
58 ("min-nfeatures-group", po::value<float>(&minNFeaturesPerGroup), "minimum average number of features per frame to create a vehicle hypothesis")
137
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
59 // ("max-uturn-cosine", po::value<float>(&maxUTurnCosine), "maximum cosine value to detect U-turn")
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
60 // ("nframes-avoid-uturn", po::value<int>(&nFramesAvoidUTurn), "number of frames over which a feature should not make a U-turn")
348
c64a4f889b97 added safety analysis options to feature tracking (with default values for backward compatibility)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 278
diff changeset
61 // Safety Analysis
c64a4f889b97 added safety analysis options to feature tracking (with default values for backward compatibility)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 278
diff changeset
62 ("max-predicted-speed", po::value<float>(&maxPredictedSpeed)->default_value(50.), "maximum speed when predicting future motion (km/h)")
c64a4f889b97 added safety analysis options to feature tracking (with default values for backward compatibility)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 278
diff changeset
63 ("prediction-time-horizon", po::value<float>(&predictionTimeHorizon)->default_value(5.), "time horizon for collision prediction (s)")
c64a4f889b97 added safety analysis options to feature tracking (with default values for backward compatibility)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 278
diff changeset
64 ("collision-distance", po::value<float>(&collisionDistance)->default_value(1.8), "collision distance threshold (m)")
c64a4f889b97 added safety analysis options to feature tracking (with default values for backward compatibility)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 278
diff changeset
65 ("crossing-zones", po::value<bool>(&crossingZones)->default_value(false), "option to compute crossing zones and predicted PET")
352
72aa44072093 safety analysis script with option for prediction method
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 351
diff changeset
66 ("prediction-method", po::value<string>(&predictionMethod)->default_value("na"), "prediction method")
349
e3f910c26fae added other safety analysis parameters
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 348
diff changeset
67 ("npredicted-trajectories", po::value<int>(&nPredictedTrajectories)->default_value(1), "number of predicted trajectories (use depends on prediction method)")
e3f910c26fae added other safety analysis parameters
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 348
diff changeset
68 ("min-acceleration", po::value<float>(&minAcceleration)->default_value(-9.1), "minimum acceleration for input distribution (m/s2) (used only for evasive action distributions)")
e3f910c26fae added other safety analysis parameters
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 348
diff changeset
69 ("max-acceleration", po::value<float>(&maxAcceleration)->default_value(2.), "maximum acceleration for input distribution (m/s2)")
e3f910c26fae added other safety analysis parameters
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 348
diff changeset
70 ("max-steering", po::value<float>(&maxSteering)->default_value(0.5), "maximum steering for input distribution (rad/s)")
351
891858351bcb added new parameter (use features) for safety analysis
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 349
diff changeset
71 ("use-features-prediction", po::value<bool>(&useFeaturesForPrediction)->default_value(false), "use feature positions and velocities for prediction")
348
c64a4f889b97 added safety analysis options to feature tracking (with default values for backward compatibility)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 278
diff changeset
72 ;
c64a4f889b97 added safety analysis options to feature tracking (with default values for backward compatibility)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 278
diff changeset
73
137
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
74 po::options_description cmdLine;
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
75 cmdLine.add(onlyCmdLine).add(cmdLineAndFile);
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
76 try {
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
77 po::variables_map vm;
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
78 store(po::command_line_parser(argc, argv).
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
79 options(cmdLine).positional(p).allow_unregistered().run(), vm);
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
80 notify(vm);
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
81
348
c64a4f889b97 added safety analysis options to feature tracking (with default values for backward compatibility)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 278
diff changeset
82 if (vm.count("config-file") == 0) {
c64a4f889b97 added safety analysis options to feature tracking (with default values for backward compatibility)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 278
diff changeset
83 cout << "Missing configuration file" << endl;
c64a4f889b97 added safety analysis options to feature tracking (with default values for backward compatibility)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 278
diff changeset
84 cout << cmdLine << endl;
c64a4f889b97 added safety analysis options to feature tracking (with default values for backward compatibility)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 278
diff changeset
85 exit(0);
c64a4f889b97 added safety analysis options to feature tracking (with default values for backward compatibility)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 278
diff changeset
86 }
c64a4f889b97 added safety analysis options to feature tracking (with default values for backward compatibility)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 278
diff changeset
87
141
6f10a227486c modifications to get nframes option working on the command line
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 137
diff changeset
88 cout << "Using configuration file " << configurationFilename << endl;
6f10a227486c modifications to get nframes option working on the command line
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 137
diff changeset
89
6f10a227486c modifications to get nframes option working on the command line
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 137
diff changeset
90 ifstream configurationFile(configurationFilename.c_str());
348
c64a4f889b97 added safety analysis options to feature tracking (with default values for backward compatibility)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 278
diff changeset
91 store(po::parse_config_file(configurationFile, cmdLineAndFile, true), vm);
141
6f10a227486c modifications to get nframes option working on the command line
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 137
diff changeset
92 notify(vm);
6f10a227486c modifications to get nframes option working on the command line
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 137
diff changeset
93
6f10a227486c modifications to get nframes option working on the command line
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 137
diff changeset
94 parameterDescription = getParameterDescription(cmdLineAndFile, vm);
6f10a227486c modifications to get nframes option working on the command line
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 137
diff changeset
95
164
76610dcf3b8d added test code to read trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 141
diff changeset
96 trackFeatures = vm.count("tf")>0;
76610dcf3b8d added test code to read trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 141
diff changeset
97 groupFeatures = vm.count("gf")>0;
76610dcf3b8d added test code to read trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 141
diff changeset
98
137
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
99 if (vm.count("help")) {
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
100 cout << cmdLine << endl;
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
101 // cout << "Positional options:";
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
102 // for (unsigned int i=0; i<p.max_total_count(); i++)
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
103 // cout << " " << p.name_for_position(i);
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
104 // cout << endl;
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
105 exit(0);
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
106 }
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
107 } catch(exception& e) {
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
108 cout << e.what() << endl;
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
109 }
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
110 }
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
111
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
112 string KLTFeatureTrackingParameters::getParameterDescription(po::options_description& options, const po::variables_map& vm, const string& separator /* = " " */) const {
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
113 stringstream stream;
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
114 vector<boost::shared_ptr<po::option_description> > optionsVec = options.options();
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
115 for (unsigned int i=0; i<optionsVec.size(); ++i) {
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
116 boost::any value = vm[optionsVec[i]->long_name()].value();
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
117 if (value.type() == typeid(bool))
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
118 stream << boost::any_cast<bool>(value) << separator;
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
119 else if (value.type() == typeid(int))
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
120 stream << boost::any_cast<int>(value) << separator;
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
121 else if (value.type() == typeid(unsigned int))
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
122 stream << boost::any_cast<unsigned int>(value) << separator;
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
123 else if (value.type() == typeid(float))
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
124 stream << boost::any_cast<float>(value) << separator;
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
125 else if (value.type() == typeid(string))
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
126 stream << boost::any_cast<string>(value) << separator;
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
127 else
141
6f10a227486c modifications to get nframes option working on the command line
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 137
diff changeset
128 cerr << "the type of the option " << optionsVec[i]->long_name() << " (" << i << ") is not int, float or string." << endl;
137
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
129 }
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
130
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
131 return stream.str();
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
132 }