From 387a0f26fbebb44972bdbc062946de28782ae008 Mon Sep 17 00:00:00 2001 From: StevenPuttemans Date: Tue, 24 Feb 2015 16:02:15 +0100 Subject: [PATCH] fix annotation tool, add auto make of tool --- apps/CMakeLists.txt | 1 + apps/annotation/CMakeLists.txt | 35 +++++++++++++++++++++++++++++++++++ apps/annotation/opencv_annotation.cpp | 11 ++++++++--- 3 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 apps/annotation/CMakeLists.txt diff --git a/apps/CMakeLists.txt b/apps/CMakeLists.txt index 347dbac..f928aa7 100644 --- a/apps/CMakeLists.txt +++ b/apps/CMakeLists.txt @@ -2,3 +2,4 @@ link_libraries(${OPENCV_LINKER_LIBS}) add_subdirectory(haartraining) add_subdirectory(traincascade) +add_subdirectory(annotation) diff --git a/apps/annotation/CMakeLists.txt b/apps/annotation/CMakeLists.txt new file mode 100644 index 0000000..778ecbf --- /dev/null +++ b/apps/annotation/CMakeLists.txt @@ -0,0 +1,35 @@ +SET(deps opencv_core opencv_highgui opencv_imgproc) +ocv_check_dependencies(${deps}) + +if(NOT OCV_DEPENDENCIES_FOUND) + return() +endif() + +project(annotation) + +ocv_include_directories("${CMAKE_CURRENT_SOURCE_DIR}" "${OpenCV_SOURCE_DIR}/include/opencv") +ocv_include_modules(${deps}) + +set(the_target opencv_annotation) + +add_executable(${the_target} opencv_annotation.cpp) +target_link_libraries(${the_target} ${deps}) + +set_target_properties(${the_target} PROPERTIES + DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}" + ARCHIVE_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH} + RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} + INSTALL_NAME_DIR lib + OUTPUT_NAME "opencv_annotation") + +if(ENABLE_SOLUTION_FOLDERS) + set_target_properties(${the_target} PROPERTIES FOLDER "applications") +endif() + +if(INSTALL_CREATE_DISTRIB) + if(BUILD_SHARED_LIBS) + install(TARGETS ${the_target} RUNTIME DESTINATION ${OPENCV_BIN_INSTALL_PATH} CONFIGURATIONS Release COMPONENT dev) + endif() +else() + install(TARGETS ${the_target} RUNTIME DESTINATION ${OPENCV_BIN_INSTALL_PATH} COMPONENT dev) +endif() diff --git a/apps/annotation/opencv_annotation.cpp b/apps/annotation/opencv_annotation.cpp index fac1aeb..605c957 100644 --- a/apps/annotation/opencv_annotation.cpp +++ b/apps/annotation/opencv_annotation.cpp @@ -15,6 +15,11 @@ Created by: Puttemans Steven using namespace std; using namespace cv; +// Function prototypes +void on_mouse(int, int, int, int, void*); +string int2string(int); +void get_annotations(Mat, stringstream*); + // Public parameters Mat image; int roi_x0 = 0, roi_y0 = 0, roi_x1 = 0, roi_y1 = 0, num_of_rec = 0; @@ -26,7 +31,7 @@ const string window_name="OpenCV Based Annotation Tool"; // FUNCTION : Mouse response for selecting objects in images // If left button is clicked, start drawing a rectangle as long as mouse moves // Stop drawing once a new left click is detected by the on_mouse function -void on_mouse(int event, int x, int y, int flag, void* param) +void on_mouse(int event, int x, int y, int , void * ) { // Action when left button is clicked if(event == CV_EVENT_LBUTTONDOWN) @@ -90,7 +95,7 @@ void get_annotations(Mat input_image, stringstream* output_stream) // c = 99 add rectangle to current image // n = 110 save added rectangles and show next image // = 27 exit program - key_pressed = waitKey(0); + key_pressed = 0xFF & waitKey(0); switch( key_pressed ) { case 27: @@ -173,7 +178,7 @@ int main( int argc, const char** argv ) // Loop through each image stored in the images folder // Create and temporarily store the annotations // At the end write everything to the annotations file - for (int i = 0; i < filenames.size(); i++){ + for (size_t i = 0; i < filenames.size(); i++){ // Read in an image Mat current_image = imread(filenames[i]); -- 2.7.4