|
|
|
@ -229,6 +229,8 @@ int main( int argc, const char** 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] }" |
|
|
|
|
"{ maxWindowHeight m | -1 | (optional) images larger in height than this value will be scaled down }" |
|
|
|
|
"{ resizeFactor r | 2 | (optional) factor for scaling down [default = half the size] }" |
|
|
|
|
); |
|
|
|
|
// Read in the input arguments
|
|
|
|
|
if (parser.has("help")){ |
|
|
|
@ -244,6 +246,9 @@ int main( int argc, const char** argv ) |
|
|
|
|
return -1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int resizeFactor = parser.get<int>("resizeFactor"); |
|
|
|
|
int const maxWindowHeight = parser.get<int>("maxWindowHeight") > 0 ? parser.get<int>("maxWindowHeight") : -1; |
|
|
|
|
|
|
|
|
|
// Check if the folder actually exists
|
|
|
|
|
// If -1 is returned then the folder actually exists, and thus you can continue
|
|
|
|
|
// In all other cases there was a folder creation and thus the folder did not exist
|
|
|
|
@ -278,6 +283,7 @@ int main( int argc, const char** argv ) |
|
|
|
|
for (size_t i = 0; i < filenames.size(); i++){ |
|
|
|
|
// Read in an image
|
|
|
|
|
Mat current_image = imread(filenames[i]); |
|
|
|
|
bool const resize_bool = (maxWindowHeight > 0) && (current_image.rows > maxWindowHeight); |
|
|
|
|
|
|
|
|
|
// Check if the image is actually read - avoid other files in the folder, because glob() takes them all
|
|
|
|
|
// If not then simply skip this iteration
|
|
|
|
@ -285,8 +291,21 @@ int main( int argc, const char** argv ) |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(resize_bool){ |
|
|
|
|
resize(current_image, current_image, Size(current_image.cols/resizeFactor, current_image.rows/resizeFactor)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Perform annotations & store the result inside the vectorized structure
|
|
|
|
|
// If the image was resized before, then resize the found annotations back to original dimensions
|
|
|
|
|
vector<Rect> current_annotations = get_annotations(current_image); |
|
|
|
|
if(resize_bool){ |
|
|
|
|
for(int j =0; j < (int)current_annotations.size(); j++){ |
|
|
|
|
current_annotations[j].x = current_annotations[j].x * resizeFactor; |
|
|
|
|
current_annotations[j].y = current_annotations[j].y * resizeFactor; |
|
|
|
|
current_annotations[j].width = current_annotations[j].width * resizeFactor; |
|
|
|
|
current_annotations[j].height = current_annotations[j].height * resizeFactor; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
annotations.push_back(current_annotations); |
|
|
|
|
|
|
|
|
|
// Check if the ESC key was hit, then exit earlier then expected
|
|
|
|
|