Skip to content

Commit

Permalink
Merge pull request opencv#7004 from StevenPuttemans:cmd_parser_opencv…
Browse files Browse the repository at this point in the history
…_annotation
  • Loading branch information
alalek committed Jul 27, 2016
2 parents 328da25 + e0f19ec commit 6cff909
Showing 1 changed file with 17 additions and 21 deletions.
38 changes: 17 additions & 21 deletions apps/annotation/opencv_annotation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,28 +224,24 @@ vector<Rect> get_annotations(Mat input_image)

int main( int argc, const char** argv )
{
// If no arguments are given, then supply some information on how this tool works
if( argc == 1 ){
cout << "Usage: " << argv[0] << endl;
cout << " -images <folder_location> [example - /data/testimages/]" << endl;
cout << " -annotations <ouput_file> [example - /data/annotations.txt]" << endl;
cout << "TIP: Use absolute paths to avoid any problems with the software!" << endl;
return -1;
}

// Use the cmdlineparser to process input arguments
CommandLineParser parser(argc, argv,
"{ help h usage ? | | show this message }"
"{ images i | | (required) path to image folder [example - /data/testimages/] }"
"{ annotations a | | (required) path to annotations txt file [example - /data/annotations.txt] }"
);
// Read in the input arguments
string image_folder;
string annotations_file;
for(int i = 1; i < argc; ++i )
{
if( !strcmp( argv[i], "-images" ) )
{
image_folder = argv[++i];
}
else if( !strcmp( argv[i], "-annotations" ) )
{
annotations_file = argv[++i];
}
if (parser.has("help")){
parser.printMessage();
cerr << "TIP: Use absolute paths to avoid any problems with the software!" << endl;
return 0;
}
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
Expand Down

0 comments on commit 6cff909

Please sign in to comment.