提交 2c9547e3 编写于 作者: V Vadim Pisarevsky

Merge pull request #3747 from StevenPuttemans:fix_annotationtool_extras

......@@ -2,3 +2,4 @@ link_libraries(${OPENCV_LINKER_LIBS})
add_subdirectory(haartraining)
add_subdirectory(traincascade)
add_subdirectory(annotation)
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()
......@@ -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
// <ESC> = 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]);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册