Mercurial Hosting > traffic-intelligence
comparison c/Parameters.cpp @ 141:6f10a227486c
modifications to get nframes option working on the command line
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Wed, 24 Aug 2011 01:34:27 -0400 |
parents | 445e773c9be3 |
children | 76610dcf3b8d |
comparison
equal
deleted
inserted
replaced
140:8de5e8256224 | 141:6f10a227486c |
---|---|
13 po::options_description onlyCmdLine("Command line only"); | 13 po::options_description onlyCmdLine("Command line only"); |
14 po::options_description cmdLineAndFile("Command line and configuration file"); | 14 po::options_description cmdLineAndFile("Command line and configuration file"); |
15 | 15 |
16 // configuration filename | 16 // configuration filename |
17 onlyCmdLine.add_options() | 17 onlyCmdLine.add_options() |
18 ("help,h", "displays this help message") | |
18 ("config-file", po::value<string>(&configurationFilename)->default_value("tracking.cfg"), "configuration file") | 19 ("config-file", po::value<string>(&configurationFilename)->default_value("tracking.cfg"), "configuration file") |
19 ; | 20 ; |
20 | 21 |
21 po::positional_options_description p; | 22 po::positional_options_description p; |
22 p.add("config-file", 1); | 23 p.add("config-file", 1); |
23 | 24 |
24 // common to cnnfiguration and command line | 25 // common to cnnfiguration and command line |
25 cmdLineAndFile.add_options() | 26 cmdLineAndFile.add_options() |
26 ("help,h", "displays this help message") | |
27 ("video-filename", po::value<string>(&videoFilename), "filename of the video to process") | 27 ("video-filename", po::value<string>(&videoFilename), "filename of the video to process") |
28 ("database-filename", po::value<string>(&databaseFilename), "filename of the database where results are saved") | 28 ("database-filename", po::value<string>(&databaseFilename), "filename of the database where results are saved") |
29 ("homography-filename", po::value<string>(&homographyFilename), "filename of the homography matrix") | 29 ("homography-filename", po::value<string>(&homographyFilename), "filename of the homography matrix") |
30 ("mask-filename", po::value<string>(&maskFilename), "filename of the mask image (where features are detected)") | 30 ("mask-filename", po::value<string>(&maskFilename), "filename of the mask image (where features are detected)") |
31 ("load-features", po::value<bool>(&loadFeatures), "load features from database") | 31 ("load-features", po::value<bool>(&loadFeatures), "load features from database") |
43 ("pyramid-level", po::value<int>(&pyramidLevel), "maximal pyramid level in the feature tracking algorithm") | 43 ("pyramid-level", po::value<int>(&pyramidLevel), "maximal pyramid level in the feature tracking algorithm") |
44 ("ndisplacements", po::value<unsigned int>(&nDisplacements), "number of displacement to test minimum feature motion") | 44 ("ndisplacements", po::value<unsigned int>(&nDisplacements), "number of displacement to test minimum feature motion") |
45 ("min-feature-displacement", po::value<float>(&minFeatureDisplacement), "minimum displacement to keep features") | 45 ("min-feature-displacement", po::value<float>(&minFeatureDisplacement), "minimum displacement to keep features") |
46 ("acceleration-bound", po::value<float>(&accelerationBound), "maximum feature acceleration") | 46 ("acceleration-bound", po::value<float>(&accelerationBound), "maximum feature acceleration") |
47 ("deviation-bound", po::value<float>(&deviationBound), "maximum feature deviation") | 47 ("deviation-bound", po::value<float>(&deviationBound), "maximum feature deviation") |
48 ("nframes-smoothing", po::value<int>(&nFramesSmoothing), "number of frames to smooth positions (half window)") | 48 ("smoothing-halfwidth", po::value<int>(&nFramesSmoothing), "number of frames to smooth positions (half window)") |
49 ("max-number-iterations", po::value<int>(&maxNumberTrackingIterations), "maximum number of iterations to stop feature tracking") | 49 ("max-number-iterations", po::value<int>(&maxNumberTrackingIterations), "maximum number of iterations to stop feature tracking") |
50 ("min-tracking-error", po::value<float>(&minTrackingError), "minimum error to reach to stop feature tracking") | 50 ("min-tracking-error", po::value<float>(&minTrackingError), "minimum error to reach to stop feature tracking") |
51 ("min-feature-time", po::value<unsigned int>(&minFeatureTime), "minimum length of a feature (number of frames) to consider a feature for grouping") | 51 ("min-feature-time", po::value<unsigned int>(&minFeatureTime), "minimum length of a feature (number of frames) to consider a feature for grouping") |
52 ("mm-connection-distance", po::value<float>(&mmConnectionDistance), "connection distance in feature grouping") | 52 ("mm-connection-distance", po::value<float>(&mmConnectionDistance), "connection distance in feature grouping") |
53 ("mm-segmentation-distance", po::value<float>(&mmSegmentationDistance), "segmentation distance in feature grouping") | 53 ("mm-segmentation-distance", po::value<float>(&mmSegmentationDistance), "segmentation distance in feature grouping") |
65 po::variables_map vm; | 65 po::variables_map vm; |
66 store(po::command_line_parser(argc, argv). | 66 store(po::command_line_parser(argc, argv). |
67 options(cmdLine).positional(p).allow_unregistered().run(), vm); | 67 options(cmdLine).positional(p).allow_unregistered().run(), vm); |
68 notify(vm); | 68 notify(vm); |
69 | 69 |
70 cout << "Using configuration file " << configurationFilename << endl; | |
71 | |
72 ifstream configurationFile(configurationFilename.c_str()); | |
73 store(po::parse_config_file(configurationFile, cmdLineAndFile), vm); | |
74 notify(vm); | |
75 | |
76 parameterDescription = getParameterDescription(cmdLineAndFile, vm); | |
77 | |
70 if (vm.count("help")) { | 78 if (vm.count("help")) { |
71 cout << cmdLine << endl; | 79 cout << cmdLine << endl; |
72 // cout << "Positional options:"; | 80 // cout << "Positional options:"; |
73 // for (unsigned int i=0; i<p.max_total_count(); i++) | 81 // for (unsigned int i=0; i<p.max_total_count(); i++) |
74 // cout << " " << p.name_for_position(i); | 82 // cout << " " << p.name_for_position(i); |
75 // cout << endl; | 83 // cout << endl; |
76 exit(0); | 84 exit(0); |
77 } | 85 } |
78 cout << "Using configuration file " << configurationFilename << endl; | |
79 | |
80 ifstream configurationFile(configurationFilename.c_str()); | |
81 store(po::parse_config_file(configurationFile, cmdLineAndFile), vm); | |
82 notify(vm); | |
83 | |
84 parameterDescription = getParameterDescription(cmdLine, vm); | |
85 } catch(exception& e) { | 86 } catch(exception& e) { |
86 cout << e.what() << endl; | 87 cout << e.what() << endl; |
87 } | 88 } |
88 } | 89 } |
89 | 90 |
101 else if (value.type() == typeid(float)) | 102 else if (value.type() == typeid(float)) |
102 stream << boost::any_cast<float>(value) << separator; | 103 stream << boost::any_cast<float>(value) << separator; |
103 else if (value.type() == typeid(string)) | 104 else if (value.type() == typeid(string)) |
104 stream << boost::any_cast<string>(value) << separator; | 105 stream << boost::any_cast<string>(value) << separator; |
105 else | 106 else |
106 cerr << "the type of the option variable " << i << " is not int, float or string." << endl; | 107 cerr << "the type of the option " << optionsVec[i]->long_name() << " (" << i << ") is not int, float or string." << endl; |
107 } | 108 } |
108 | 109 |
109 return stream.str(); | 110 return stream.str(); |
110 } | 111 } |