Merge pull request #7004 from StevenPuttemans:cmd_parser_opencv_annotation

This commit is contained in:
Alexander Alekhin 2016-07-27 18:24:17 +00:00
commit 6cff909bc8

View File

@ -224,28 +224,24 @@ vector<Rect> get_annotations(Mat input_image)
int main( int argc, const char** argv ) int main( int argc, const char** argv )
{ {
// If no arguments are given, then supply some information on how this tool works // Use the cmdlineparser to process input arguments
if( argc == 1 ){ CommandLineParser parser(argc, argv,
cout << "Usage: " << argv[0] << endl; "{ help h usage ? | | show this message }"
cout << " -images <folder_location> [example - /data/testimages/]" << endl; "{ images i | | (required) path to image folder [example - /data/testimages/] }"
cout << " -annotations <ouput_file> [example - /data/annotations.txt]" << endl; "{ annotations a | | (required) path to annotations txt file [example - /data/annotations.txt] }"
cout << "TIP: Use absolute paths to avoid any problems with the software!" << endl; );
return -1;
}
// Read in the input arguments // Read in the input arguments
string image_folder; if (parser.has("help")){
string annotations_file; parser.printMessage();
for(int i = 1; i < argc; ++i ) cerr << "TIP: Use absolute paths to avoid any problems with the software!" << endl;
{ return 0;
if( !strcmp( argv[i], "-images" ) )
{
image_folder = argv[++i];
}
else if( !strcmp( argv[i], "-annotations" ) )
{
annotations_file = argv[++i];
} }
string image_folder(parser.get<string>("images"));
string annotations_file(parser.get<string>("annotations"));
if (image_folder.empty() || annotations_file.empty()){
parser.printMessage();
cerr << "TIP: Use absolute paths to avoid any problems with the software!" << endl;
return -1;
} }
// Check if the folder actually exists // Check if the folder actually exists