Mercurial Hosting > traffic-intelligence
comparison c/Parameters.cpp @ 614:5e09583275a4
Merged Nicolas/trafficintelligence into default
author | Mohamed Gomaa <eng.m.gom3a@gmail.com> |
---|---|
date | Fri, 05 Dec 2014 12:13:53 -0500 |
parents | 935430b1d408 |
children | 045d05cef9d0 |
comparison
equal
deleted
inserted
replaced
598:11f96bd08552 | 614:5e09583275a4 |
---|---|
16 // configuration filename | 16 // configuration filename |
17 onlyCmdLine.add_options() | 17 onlyCmdLine.add_options() |
18 ("help,h", "displays this help message") | 18 ("help,h", "displays this help message") |
19 ("tf", "tracks features") | 19 ("tf", "tracks features") |
20 ("gf", "groups features") | 20 ("gf", "groups features") |
21 ("config-file", po::value<string>(&configurationFilename)->default_value("tracking.cfg"), "configuration file") | 21 ("config-file", po::value<string>(&configurationFilename), "configuration file") |
22 ; | 22 ; |
23 | 23 |
24 po::positional_options_description p; | 24 po::positional_options_description p; |
25 p.add("config-file", 1); | 25 p.add("config-file", 1); |
26 | 26 |
27 // common to cnnfiguration and command line | 27 // common to cnnfiguration and command line |
28 cmdLineAndFile.add_options() | 28 cmdLineAndFile.add_options() |
29 ("video-filename", po::value<string>(&videoFilename), "filename of the video to process") | 29 ("video-filename", po::value<string>(&videoFilename), "filename of the video to process") |
30 ("database-filename", po::value<string>(&databaseFilename), "filename of the database where results are saved") | 30 ("database-filename", po::value<string>(&databaseFilename), "filename of the database where results are saved") |
31 ("homography-filename", po::value<string>(&homographyFilename), "filename of the homography matrix") | 31 ("homography-filename", po::value<string>(&homographyFilename), "filename of the homography matrix") |
32 ("intrinsic-camera-filename", po::value<string>(&intrinsicCameraFilename), "filename of the homography matrix") | |
33 ("distortion-coefficients", po::value<std::vector<float> >(&distortionCoefficients)->multitoken(), "") | |
34 ("undistorted-size-multiplication", po::value<float>(&undistortedImageMultiplication), "undistorted image multiplication") | |
35 ("interpolation-method", po::value<int>(&interpolationMethod), "Interpolation method for remapping image when correcting for distortion: 0 for INTER_NEAREST - a nearest-neighbor interpolation; 1 for INTER_LINEAR - a bilinear interpolation (used by default); 2 for INTER_CUBIC - a bicubic interpolation over 4x4 pixel neighborhood; 3 for INTER_LANCZOS4") | |
32 ("mask-filename", po::value<string>(&maskFilename), "filename of the mask image (where features are detected)") | 36 ("mask-filename", po::value<string>(&maskFilename), "filename of the mask image (where features are detected)") |
37 ("undistort", po::value<bool>(&undistort), "undistort the video for feature tracking") | |
33 ("load-features", po::value<bool>(&loadFeatures), "load features from database") | 38 ("load-features", po::value<bool>(&loadFeatures), "load features from database") |
34 ("display", po::value<bool>(&display), "display trajectories on the video") | 39 ("display", po::value<bool>(&display), "display trajectories on the video") |
35 ("video-fps", po::value<float>(&videoFPS), "original video frame rate") | 40 ("video-fps", po::value<float>(&videoFPS), "original video frame rate") |
36 ("frame1", po::value<unsigned int>(&frame1), "first frame to process") | 41 ("frame1", po::value<unsigned int>(&frame1), "first frame to process") |
37 ("nframes", po::value<int>(&nFrames), "number of frame to process") | 42 ("nframes", po::value<int>(&nFrames), "number of frame to process") |
38 // feature tracking | 43 // feature tracking |
39 ("max-nfeatures", po::value<int>(&maxNFeatures), "maximum number of features added at each frame") | 44 ("max-nfeatures", po::value<int>(&maxNFeatures), "maximum number of features added at each frame (1000s)") |
40 ("feature-quality", po::value<float>(&featureQuality), "quality level of the good features to track") | 45 ("feature-quality", po::value<float>(&featureQuality), "quality level of the good features to track (]0. 1?])") |
41 ("min-feature-distanceklt", po::value<float>(&minFeatureDistanceKLT), "minimum distance between features") | 46 ("min-feature-distanceklt", po::value<float>(&minFeatureDistanceKLT), "minimum distance between features (]0. 10?])") |
42 ("window-size", po::value<int>(&windowSize), "size of the search window at each pyramid level") | 47 ("block-size", po::value<int>(&blockSize), "size of the block for feature characteristics ([1 ?])") |
43 ("use-harris-detector", po::value<bool>(&useHarrisDetector), "use of Harris corner detector") | 48 ("use-harris-detector", po::value<bool>(&useHarrisDetector), "use of Harris corner detector") |
44 ("k", po::value<float>(&k), "k parameter to detect good features to track (OpenCV)") | 49 ("k", po::value<float>(&k), "k parameter to detect good features to track (OpenCV)") |
45 ("pyramid-level", po::value<int>(&pyramidLevel), "maximal pyramid level in the feature tracking algorithm") | 50 ("window-size", po::value<int>(&windowSize), "size of the search window at each pyramid level ([1 ?])") |
46 ("ndisplacements", po::value<unsigned int>(&nDisplacements), "number of displacement to test minimum feature motion") | 51 ("pyramid-level", po::value<int>(&pyramidLevel), "maximal pyramid level in the feature tracking algorithm ([0 maxLevel=5?])") |
47 ("min-feature-displacement", po::value<float>(&minFeatureDisplacement), "minimum displacement to keep features") | 52 ("ndisplacements", po::value<unsigned int>(&nDisplacements), "number of displacements to test minimum feature motion ([2 4])") |
48 ("acceleration-bound", po::value<float>(&accelerationBound), "maximum feature acceleration") | 53 ("min-feature-displacement", po::value<float>(&minFeatureDisplacement), "minimum displacement per frame (in world space) to keep features (]0. 0.1?])") |
49 ("deviation-bound", po::value<float>(&deviationBound), "maximum feature deviation") | 54 ("acceleration-bound", po::value<float>(&accelerationBound), "maximum feature acceleration (]1 3+])") |
50 ("smoothing-halfwidth", po::value<int>(&nFramesSmoothing), "number of frames to smooth positions (half window)") | 55 ("deviation-bound", po::value<float>(&deviationBound), "maximum feature deviation (on cosine) (]0 1])") |
51 ("max-number-iterations", po::value<int>(&maxNumberTrackingIterations), "maximum number of iterations to stop feature tracking") | 56 ("smoothing-halfwidth", po::value<int>(&nFramesSmoothing), "number of frames to smooth positions (half window) ([0 inf[") |
52 ("min-tracking-error", po::value<float>(&minTrackingError), "minimum error to reach to stop feature tracking") | 57 ("max-number-iterations", po::value<int>(&maxNumberTrackingIterations), "maximum number of iterations to stop optical flow (20-30?)") |
53 ("min-feature-time", po::value<unsigned int>(&minFeatureTime), "minimum length of a feature (number of frames) to consider a feature for grouping") | 58 ("min-tracking-error", po::value<float>(&minTrackingError), "minimum error to reach to stop optical flow (0.3-0.01)") |
54 ("mm-connection-distance", po::value<float>(&mmConnectionDistance), "connection distance in feature grouping") | 59 ("min-feature-eig-threshold", po::value<float>(&minFeatureEigThreshold)->default_value(1e-4), "minimum eigen value of a 2x2 normal matrix of optical flow equations (10^-4)") |
55 ("mm-segmentation-distance", po::value<float>(&mmSegmentationDistance), "segmentation distance in feature grouping") | 60 ("min-feature-time", po::value<unsigned int>(&minFeatureTime), "minimum length of a feature (number of frames) to consider a feature for grouping [5 20+]") |
56 ("max-distance", po::value<float>(&maxDistance), "maximum distance between features for grouping") | 61 ("mm-connection-distance", po::value<float>(&mmConnectionDistance), "connection distance in feature grouping (in world space) (ped: [0.5m 2m+], cars: [1.7m 4m+])") |
57 ("min-velocity-cosine", po::value<float>(&minVelocityCosine), "minimum cosine of the angle between the velocity vectors for grouping") | 62 ("mm-segmentation-distance", po::value<float>(&mmSegmentationDistance), "segmentation distance in feature grouping (in world space) (< mm-connection-distance, empirically ~ mm-connection-distance / 2.5)") |
58 ("min-nfeatures-group", po::value<float>(&minNFeaturesPerGroup), "minimum average number of features per frame to create a vehicle hypothesis") | 63 ("max-distance", po::value<float>(&maxDistance), "maximum distance between features for grouping (in world space) (unused)") |
59 ; | 64 ("min-velocity-cosine", po::value<float>(&minVelocityCosine), "minimum cosine of the angle between the velocity vectors for grouping (unused)") |
65 ("min-nfeatures-group", po::value<float>(&minNFeaturesPerGroup), "minimum average number of features per frame to create a vehicle hypothesis (]1 3+])") | |
60 // ("max-uturn-cosine", po::value<float>(&maxUTurnCosine), "maximum cosine value to detect U-turn") | 66 // ("max-uturn-cosine", po::value<float>(&maxUTurnCosine), "maximum cosine value to detect U-turn") |
61 // ("nframes-avoid-uturn", po::value<int>(&nFramesAvoidUTurn), "number of frames over which a feature should not make a U-turn") | 67 // ("nframes-avoid-uturn", po::value<int>(&nFramesAvoidUTurn), "number of frames over which a feature should not make a U-turn") |
62 | 68 // Safety Analysis |
63 | 69 ("max-predicted-speed", po::value<float>(&maxPredictedSpeed)->default_value(50.), "maximum speed when predicting future motion (km/h)") |
70 ("prediction-time-horizon", po::value<float>(&predictionTimeHorizon)->default_value(5.), "time horizon for collision prediction (s)") | |
71 ("collision-distance", po::value<float>(&collisionDistance)->default_value(1.8), "collision distance threshold (m)") | |
72 ("crossing-zones", po::value<bool>(&crossingZones)->default_value(false), "option to compute crossing zones and predicted PET") | |
73 ("prediction-method", po::value<string>(&predictionMethod)->default_value("na"), "prediction method") | |
74 ("npredicted-trajectories", po::value<int>(&nPredictedTrajectories)->default_value(1), "number of predicted trajectories (use depends on prediction method)") | |
75 ("min-acceleration", po::value<float>(&minAcceleration)->default_value(-9.1), "minimum acceleration for input distribution (m/s2) (used only for evasive action distributions)") | |
76 ("max-acceleration", po::value<float>(&maxAcceleration)->default_value(2.), "maximum acceleration for input distribution (m/s2)") | |
77 ("max-steering", po::value<float>(&maxSteering)->default_value(0.5), "maximum steering for input distribution (rad/s)") | |
78 ("use-features-prediction", po::value<bool>(&useFeaturesForPrediction)->default_value(false), "use feature positions and velocities for prediction") | |
79 ; | |
80 | |
64 po::options_description cmdLine; | 81 po::options_description cmdLine; |
65 cmdLine.add(onlyCmdLine).add(cmdLineAndFile); | 82 cmdLine.add(onlyCmdLine).add(cmdLineAndFile); |
66 try { | 83 try { |
67 po::variables_map vm; | 84 po::variables_map vm; |
68 store(po::command_line_parser(argc, argv). | 85 store(po::command_line_parser(argc, argv). |
69 options(cmdLine).positional(p).allow_unregistered().run(), vm); | 86 options(cmdLine).positional(p).allow_unregistered().run(), vm); |
70 notify(vm); | 87 notify(vm); |
71 | 88 |
89 if (vm.count("config-file") == 0) { | |
90 cout << "Missing configuration file" << endl; | |
91 cout << cmdLine << endl; | |
92 exit(0); | |
93 } | |
94 | |
72 cout << "Using configuration file " << configurationFilename << endl; | 95 cout << "Using configuration file " << configurationFilename << endl; |
73 | 96 |
74 ifstream configurationFile(configurationFilename.c_str()); | 97 ifstream configurationFile(configurationFilename.c_str()); |
75 store(po::parse_config_file(configurationFile, cmdLineAndFile), vm); | 98 store(po::parse_config_file(configurationFile, cmdLineAndFile, true), vm); |
76 notify(vm); | 99 notify(vm); |
77 | 100 |
78 parameterDescription = getParameterDescription(cmdLineAndFile, vm); | 101 parameterDescription = getParameterDescription(cmdLineAndFile, vm); |
79 | 102 |
80 trackFeatures = vm.count("tf")>0; | 103 trackFeatures = vm.count("tf")>0; |
106 stream << boost::any_cast<unsigned int>(value) << separator; | 129 stream << boost::any_cast<unsigned int>(value) << separator; |
107 else if (value.type() == typeid(float)) | 130 else if (value.type() == typeid(float)) |
108 stream << boost::any_cast<float>(value) << separator; | 131 stream << boost::any_cast<float>(value) << separator; |
109 else if (value.type() == typeid(string)) | 132 else if (value.type() == typeid(string)) |
110 stream << boost::any_cast<string>(value) << separator; | 133 stream << boost::any_cast<string>(value) << separator; |
111 else | 134 else if (value.type() == typeid(vector<float>)) { |
135 for (unsigned int j=0; j<boost::any_cast<vector<float> >(value).size(); j++) | |
136 stream << boost::any_cast<vector<float> >(value)[j] << separator; | |
137 } else | |
112 cerr << "the type of the option " << optionsVec[i]->long_name() << " (" << i << ") is not int, float or string." << endl; | 138 cerr << "the type of the option " << optionsVec[i]->long_name() << " (" << i << ") is not int, float or string." << endl; |
113 } | 139 } |
114 | 140 |
115 return stream.str(); | 141 return stream.str(); |
116 } | 142 } |