More granular build of Java API: it is now possible to build Java wrappers only for the subset of OpenCV modules

This commit is contained in:
Andrey Kamaev 2012-02-20 11:50:43 +00:00
parent 8dc28473c7
commit 00db5a69a2
6 changed files with 149 additions and 115 deletions

View File

@ -98,6 +98,8 @@ macro(ocv_add_module _name)
endif() endif()
set(OPENCV_MODULE_${the_module}_DESCRIPTION "${the_description}" CACHE INTERNAL "Brief description of ${the_module} module") set(OPENCV_MODULE_${the_module}_DESCRIPTION "${the_description}" CACHE INTERNAL "Brief description of ${the_module} module")
set(OPENCV_MODULE_${the_module}_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}" CACHE INTERNAL "Location of ${the_module} module sources") set(OPENCV_MODULE_${the_module}_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}" CACHE INTERNAL "Location of ${the_module} module sources")
unset(OPENCV_MODULE_${the_module}_REQ_DEPS CACHE)
unset(OPENCV_MODULE_${the_module}_OPT_DEPS CACHE)
#create option to enable/disable this module #create option to enable/disable this module
option(BUILD_${the_module} "Include ${the_module} module into the OpenCV build" ON) option(BUILD_${the_module} "Include ${the_module} module into the OpenCV build" ON)

View File

@ -5,66 +5,72 @@ if(NOT ANDROID OR NOT PYTHON_EXECUTABLE)
ocv_module_disable(java) ocv_module_disable(java)
endif() endif()
set(the_description "The java bindings") set(OPENCV_MODULES_EXPORTED_TO_JAVA opencv_objdetect opencv_features2d opencv_video opencv_highgui opencv_ml opencv_calib3d CACHE STRING "List of modules exported to Java API")
ocv_add_module(java BINDINGS opencv_objdetect opencv_features2d opencv_imgproc opencv_video opencv_highgui opencv_ml opencv_core opencv_calib3d) mark_as_advanced(OPENCV_MODULES_EXPORTED_TO_JAVA)
string(REPLACE "opencv_" "" OPENCV_JAVA_MODULES "${OPENCV_MODULE_${the_module}_REQ_DEPS}") set(the_description "The java bindings")
ocv_add_module(java BINDINGS opencv_core opencv_imgproc OPTIONAL ${OPENCV_MODULES_EXPORTED_TO_JAVA})
string(REPLACE "opencv_" "" OPENCV_JAVA_MODULES "${OPENCV_MODULE_${the_module}_REQ_DEPS};${OPENCV_MODULE_${the_module}_OPT_DEPS}")
foreach(module ${OPENCV_JAVA_MODULES})
if(NOT HAVE_opencv_${module})
list(REMOVE_ITEM OPENCV_JAVA_MODULES ${module})
endif()
endforeach()
set(target ${the_module}) set(target ${the_module})
include_directories("${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/src/cpp") include_directories("${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/src/cpp")
SET(GEN_JAVA "${CMAKE_CURRENT_SOURCE_DIR}/gen_java.py") set(GEN_JAVA "${CMAKE_CURRENT_SOURCE_DIR}/gen_java.py")
SET(HDR_PARSER "${CMAKE_CURRENT_SOURCE_DIR}/../python/src2/hdr_parser.py") set(HDR_PARSER "${CMAKE_CURRENT_SOURCE_DIR}/../python/src2/hdr_parser.py")
SET(GEN_JAVADOC "${CMAKE_CURRENT_SOURCE_DIR}/gen_javadoc.py") set(GEN_JAVADOC "${CMAKE_CURRENT_SOURCE_DIR}/gen_javadoc.py")
SET(RST_PARSER "${CMAKE_CURRENT_SOURCE_DIR}/rst_parser.py") set(RST_PARSER "${CMAKE_CURRENT_SOURCE_DIR}/rst_parser.py")
SET(CHECK_TEST_COVERAGE "${CMAKE_CURRENT_SOURCE_DIR}/check-tests.py") set(CHECK_TEST_COVERAGE "${CMAKE_CURRENT_SOURCE_DIR}/check-tests.py")
# setup raw java and cpp files generation (without javadoc and at temporary location) # setup raw java and cpp files generation (without javadoc and at temporary location)
foreach(module ${OPENCV_JAVA_MODULES}) foreach(module ${OPENCV_JAVA_MODULES})
# get list of module headers # get list of module headers
IF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/config/${module}.filelist") if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/config/${module}.filelist")
FILE(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/config/${module}.filelist" headers_to_parse) file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/config/${module}.filelist" headers_to_parse)
SET (module_cheaders "") set(module_cheaders "")
SET (module_cppheaders "") set(module_cppheaders "")
foreach(header ${headers_to_parse}) foreach(header ${headers_to_parse})
list(APPEND module_cppheaders "${CMAKE_CURRENT_SOURCE_DIR}/../${module}/${header}") list(APPEND module_cppheaders "${CMAKE_CURRENT_SOURCE_DIR}/../${module}/${header}")
endforeach()
ELSE()
FILE(GLOB module_cheaders "${CMAKE_CURRENT_SOURCE_DIR}/../${module}/include/opencv2/${module}/*.h")
FILE(GLOB module_cppheaders "${CMAKE_CURRENT_SOURCE_DIR}/../${module}/include/opencv2/${module}/*.hpp")
list(SORT module_cheaders)
list(SORT module_cppheaders)
ENDIF()
# add dependencies to cmake (we should rerun cmake if any of these headers are modified)
foreach(header ${module_cheaders} ${module_cppheaders})
get_filename_component(header_name "${header}" NAME_WE)
configure_file("${header}" "${CMAKE_BINARY_DIR}/junk/${header_name}.junk" COPYONLY)
endforeach() endforeach()
else()
file(GLOB module_cheaders "${CMAKE_CURRENT_SOURCE_DIR}/../${module}/include/opencv2/${module}/*.h")
file(GLOB module_cppheaders "${CMAKE_CURRENT_SOURCE_DIR}/../${module}/include/opencv2/${module}/*.hpp")
list(SORT module_cheaders)
list(SORT module_cppheaders)
endif()
# the same about gen_java.py and hdr_parser.py # add dependencies to cmake (we should rerun cmake if any of these headers is modified)
configure_file("${GEN_JAVA}" "${CMAKE_BINARY_DIR}/junk/gen_java.junk" COPYONLY) foreach(header ${module_cheaders} ${module_cppheaders})
configure_file("${HDR_PARSER}" "${CMAKE_BINARY_DIR}/junk/hdr_parser.junk" COPYONLY) get_filename_component(header_name "${header}" NAME_WE)
configure_file("${header}" "${CMAKE_BINARY_DIR}/junk/${header_name}.junk" COPYONLY)
endforeach()
# the same about gen_java.py and hdr_parser.py
configure_file("${GEN_JAVA}" "${CMAKE_BINARY_DIR}/junk/gen_java.junk" COPYONLY)
configure_file("${HDR_PARSER}" "${CMAKE_BINARY_DIR}/junk/hdr_parser.junk" COPYONLY)
# first run (to get list of generated files) # first run (to get list of generated files)
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/gen_java_out") file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/gen_java_out")
execute_process(COMMAND ${PYTHON_EXECUTABLE} "${GEN_JAVA}" "${HDR_PARSER}" ${module} ${module_cheaders} ${module_cppheaders}
execute_process(COMMAND ${PYTHON_EXECUTABLE} "${GEN_JAVA}" "${HDR_PARSER}" ${module} ${module_cheaders} ${module_cppheaders}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/gen_java_out" WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/gen_java_out"
OUTPUT_QUIET ERROR_QUIET) OUTPUT_QUIET ERROR_QUIET)
# create list of generated files # create list of generated files
file(GLOB_RECURSE generated_java_sources RELATIVE "${CMAKE_CURRENT_BINARY_DIR}/gen_java_out/" "${CMAKE_CURRENT_BINARY_DIR}/gen_java_out/*.java") file(GLOB_RECURSE generated_java_sources RELATIVE "${CMAKE_CURRENT_BINARY_DIR}/gen_java_out/" "${CMAKE_CURRENT_BINARY_DIR}/gen_java_out/*.java")
file(REMOVE_RECURSE "${CMAKE_CURRENT_BINARY_DIR}/gen_java_out/") file(REMOVE_RECURSE "${CMAKE_CURRENT_BINARY_DIR}/gen_java_out/")
set(${module}_generated_java_sources) set(${module}_generated_java_sources)
foreach(f ${generated_java_sources}) foreach(f ${generated_java_sources})
list(APPEND ${module}_generated_java_sources "${CMAKE_CURRENT_BINARY_DIR}/${f}") list(APPEND ${module}_generated_java_sources "${CMAKE_CURRENT_BINARY_DIR}/${f}")
endforeach() endforeach()
# second run # second run
add_custom_command( add_custom_command(
OUTPUT ${${module}_generated_java_sources} OUTPUT ${${module}_generated_java_sources}
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${module}.cpp" OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${module}.cpp"
COMMAND ${PYTHON_EXECUTABLE} "${GEN_JAVA}" "${HDR_PARSER}" ${module} ${module_cheaders} ${module_cppheaders} COMMAND ${PYTHON_EXECUTABLE} "${GEN_JAVA}" "${HDR_PARSER}" ${module} ${module_cheaders} ${module_cppheaders}
@ -76,32 +82,39 @@ foreach(module ${OPENCV_JAVA_MODULES})
) )
endforeach() endforeach()
FILE(GLOB handwrittren_cpp_sources "${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/*.cpp") file(GLOB handwrittren_cpp_sources "${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/*.cpp")
FILE(GLOB handwrittren_h_sources "${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/*.h??") file(GLOB handwrittren_h_sources "${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/*.h" "${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/*.hpp")
FILE(GLOB handwrittren_java_sources "${CMAKE_CURRENT_SOURCE_DIR}/src/java/*.java") file(GLOB handwrittren_java_sources "${CMAKE_CURRENT_SOURCE_DIR}/src/java/*.java")
SET (generated_cpp_sources) set(generated_cpp_sources)
SET (generated_java_sources) set(generated_java_sources)
SET (documented_java_files) set(documented_java_files)
SET (undocumented_java_files) set(undocumented_java_files)
foreach(jfile ${handwrittren_java_sources})
string(REGEX REPLACE "^.*/([^+]+)\\+.*\\.java$" "\\1" jmodname "${jfile}")
if(DEFINED HAVE_opencv_${jmodname} AND NOT HAVE_opencv_${jmodname})
list(REMOVE_ITEM handwrittren_java_sources "${jfile}")
endif()
endforeach()
foreach(module ${OPENCV_JAVA_MODULES}) foreach(module ${OPENCV_JAVA_MODULES})
LIST(APPEND generated_cpp_sources "${CMAKE_CURRENT_BINARY_DIR}/${module}.cpp") list(APPEND generated_cpp_sources "${CMAKE_CURRENT_BINARY_DIR}/${module}.cpp")
LIST(APPEND generated_java_sources ${${module}_generated_java_sources}) list(APPEND generated_java_sources ${${module}_generated_java_sources})
endforeach() endforeach()
# all needed includes # all needed includes
foreach(module ${OPENCV_MODULE_${the_module}_DEPS}) foreach(module ${OPENCV_MODULE_${the_module}_DEPS})
string(REPLACE "opencv_" "" module "${module}") string(REPLACE "opencv_" "" module "${module}")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../${module}/include") include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../${module}/include")
endforeach() endforeach()
# created list of documented files targets # created list of documented files targets
foreach(java_file ${handwrittren_java_sources} ${generated_java_sources}) foreach(java_file ${handwrittren_java_sources} ${generated_java_sources})
get_filename_component(java_file_name "${java_file}" NAME_WE) get_filename_component(java_file_name "${java_file}" NAME_WE)
if (NOT java_file_name MATCHES ".*-jdoc$") if(NOT java_file_name MATCHES ".*-jdoc$")
list(APPEND documented_java_files "${CMAKE_CURRENT_BINARY_DIR}/${java_file_name}-jdoc.java") list(APPEND documented_java_files "${CMAKE_CURRENT_BINARY_DIR}/${java_file_name}-jdoc.java")
list(APPEND undocumented_java_files "${java_file}") list(APPEND undocumented_java_files "${java_file}")
endif() endif()
endforeach() endforeach()
# generate javadoc files # generate javadoc files
@ -117,31 +130,32 @@ add_custom_command(
) )
# copy generated java files to the final location # copy generated java files to the final location
SET(JAVA_OUTPUT_DIR "src/org/opencv") set(JAVA_OUTPUT_DIR "src/org/opencv")
set(java_files) set(java_files)
foreach(java_file ${documented_java_files}) foreach(java_file ${documented_java_files})
get_filename_component(java_file_name "${java_file}" NAME) get_filename_component(java_file_name "${java_file}" NAME)
string(REPLACE "-jdoc.java" ".java" java_file_name "${java_file_name}") string(REPLACE "-jdoc.java" ".java" java_file_name "${java_file_name}")
string(REPLACE "+" "/" java_file_name "${java_file_name}") string(REPLACE "+" "/" java_file_name "${java_file_name}")
add_custom_command( add_custom_command(
OUTPUT "${CMAKE_BINARY_DIR}/${JAVA_OUTPUT_DIR}/${java_file_name}" OUTPUT "${CMAKE_BINARY_DIR}/${JAVA_OUTPUT_DIR}/${java_file_name}"
COMMAND ${CMAKE_COMMAND} -E copy "${java_file}" "${CMAKE_BINARY_DIR}/${JAVA_OUTPUT_DIR}/${java_file_name}" COMMAND ${CMAKE_COMMAND} -E copy "${java_file}" "${CMAKE_BINARY_DIR}/${JAVA_OUTPUT_DIR}/${java_file_name}"
DEPENDS "${java_file}" DEPENDS "${java_file}"
COMMENT "Generating ${JAVA_OUTPUT_DIR}/${java_file_name}" COMMENT "Generating ${JAVA_OUTPUT_DIR}/${java_file_name}"
) )
list(APPEND java_files "${CMAKE_BINARY_DIR}/${JAVA_OUTPUT_DIR}/${java_file_name}") list(APPEND java_files "${CMAKE_BINARY_DIR}/${JAVA_OUTPUT_DIR}/${java_file_name}")
if(ANDROID) if(ANDROID)
get_filename_component(install_subdir "${java_file_name}" PATH) get_filename_component(install_subdir "${java_file_name}" PATH)
install(FILES "${CMAKE_BINARY_DIR}/${JAVA_OUTPUT_DIR}/${java_file_name}" DESTINATION ${JAVA_OUTPUT_DIR}/${install_subdir} COMPONENT main) install(FILES "${CMAKE_BINARY_DIR}/${JAVA_OUTPUT_DIR}/${java_file_name}" DESTINATION ${JAVA_OUTPUT_DIR}/${install_subdir} COMPONENT main)
endif() endif()
endforeach() endforeach()
# custom target for java API # custom target for java API
set(api_target ${target}_api) set(api_target ${target}_api)
ADD_CUSTOM_TARGET(${api_target} DEPENDS ${java_files}) add_custom_target(${api_target} DEPENDS ${java_files})
# add opencv_java library # add opencv_java library
@ -160,78 +174,78 @@ set_target_properties(${target} PROPERTIES
install(TARGETS ${target} LIBRARY DESTINATION ${OPENCV_LIB_INSTALL_PATH} COMPONENT main) install(TARGETS ${target} LIBRARY DESTINATION ${OPENCV_LIB_INSTALL_PATH} COMPONENT main)
if(ANDROID) if(ANDROID)
target_link_libraries(${target} jnigraphics) target_link_libraries(${target} jnigraphics)
# force strip library after build command # force strip library after build command
# because samples and tests will make a copy of library before install # because samples and tests will make a copy of library before install
ADD_CUSTOM_COMMAND( add_custom_command(
TARGET ${target} TARGET ${target}
POST_BUILD POST_BUILD
COMMAND ${CMAKE_STRIP} "${LIBRARY_OUTPUT_PATH}/lib${target}.so" COMMAND ${CMAKE_STRIP} "${LIBRARY_OUTPUT_PATH}/lib${target}.so"
) )
set(lib_proj_files) set(lib_proj_files "")
# library project blank # library project blank
file(GLOB_RECURSE android_lib_project_files "${CMAKE_CURRENT_SOURCE_DIR}/android/*") file(GLOB_RECURSE android_lib_project_files "${CMAKE_CURRENT_SOURCE_DIR}/android/*")
foreach(file ${android_lib_project_files}) foreach(file ${android_lib_project_files})
if(NOT file MATCHES "\\.svn") if(NOT file MATCHES "\\.svn")
file(RELATIVE_PATH file_rel "${CMAKE_CURRENT_SOURCE_DIR}/android/" "${file}") file(RELATIVE_PATH file_rel "${CMAKE_CURRENT_SOURCE_DIR}/android/" "${file}")
add_custom_command( add_custom_command(
OUTPUT "${CMAKE_BINARY_DIR}/${file_rel}" OUTPUT "${CMAKE_BINARY_DIR}/${file_rel}"
COMMAND ${CMAKE_COMMAND} -E copy "${file}" "${CMAKE_BINARY_DIR}/${file_rel}" COMMAND ${CMAKE_COMMAND} -E copy "${file}" "${CMAKE_BINARY_DIR}/${file_rel}"
DEPENDS "${file}" DEPENDS "${file}"
COMMENT "Generating ${file_rel}" COMMENT "Generating ${file_rel}"
) )
list(APPEND lib_proj_files "${CMAKE_BINARY_DIR}/${file_rel}") list(APPEND lib_proj_files "${CMAKE_BINARY_DIR}/${file_rel}")
if(NOT file_rel MATCHES "jni/.+") if(NOT file_rel MATCHES "jni/.+")
install(FILES "${CMAKE_BINARY_DIR}/${file_rel}" DESTINATION . COMPONENT main) install(FILES "${CMAKE_BINARY_DIR}/${file_rel}" DESTINATION . COMPONENT main)
endif() endif()
endif() endif()
endforeach() endforeach()
# library project jni sources # library project jni sources
foreach(jni_file ${handwrittren_cpp_sources} ${handwrittren_h_sources} ${generated_cpp_sources}) foreach(jni_file ${handwrittren_cpp_sources} ${handwrittren_h_sources} ${generated_cpp_sources})
get_filename_component(jni_file_name "${jni_file}" NAME) get_filename_component(jni_file_name "${jni_file}" NAME)
add_custom_command( add_custom_command(
OUTPUT "${CMAKE_BINARY_DIR}/jni/${jni_file_name}" OUTPUT "${CMAKE_BINARY_DIR}/jni/${jni_file_name}"
COMMAND ${CMAKE_COMMAND} -E copy "${jni_file}" "${CMAKE_BINARY_DIR}/jni/${jni_file_name}" COMMAND ${CMAKE_COMMAND} -E copy "${jni_file}" "${CMAKE_BINARY_DIR}/jni/${jni_file_name}"
COMMAND ${CMAKE_COMMAND} -E touch "${CMAKE_BINARY_DIR}/jni/${jni_file_name}" COMMAND ${CMAKE_COMMAND} -E touch "${CMAKE_BINARY_DIR}/jni/${jni_file_name}"
DEPENDS "${jni_file}" DEPENDS "${jni_file}"
COMMENT "Generating jni/${jni_file_name}" COMMENT "Generating jni/${jni_file_name}"
) )
list(APPEND lib_proj_files "${CMAKE_BINARY_DIR}/jni/${jni_file_name}") list(APPEND lib_proj_files "${CMAKE_BINARY_DIR}/jni/${jni_file_name}")
endforeach() endforeach()
# create Android library project in build folder # create Android library project in build folder
set(lib_target ${target}_android_library) set(lib_target ${target}_android_library)
ADD_CUSTOM_TARGET(${lib_target} add_custom_target(${lib_target}
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/res" COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/res"
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/gen" COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/gen"
DEPENDS ${lib_proj_files} DEPENDS ${lib_proj_files}
) )
if (ANT_EXECUTABLE AND ANDROID_EXECUTABLE AND ANDROID_TOOLS_Pkg_Revision GREATER 13) if(ANT_EXECUTABLE AND ANDROID_EXECUTABLE AND ANDROID_TOOLS_Pkg_Revision GREATER 13)
add_custom_command( add_custom_command(TARGET ${target}
TARGET ${target}
COMMAND ${ANDROID_EXECUTABLE} update lib-project --target "${ANDROID_SDK_TARGET}" --path "${CMAKE_BINARY_DIR}" COMMAND ${ANDROID_EXECUTABLE} update lib-project --target "${ANDROID_SDK_TARGET}" --path "${CMAKE_BINARY_DIR}"
COMMAND ${ANT_EXECUTABLE} debug COMMAND ${ANT_EXECUTABLE} debug
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
DEPENDS ${lib_target} DEPENDS ${lib_target}
) )
endif() endif()
add_dependencies(${lib_target} ${api_target})
add_dependencies(${target} ${lib_target})
add_dependencies(${lib_target} ${api_target})
add_dependencies(${target} ${lib_target})
endif(ANDROID) endif(ANDROID)
#android test project #android test project
if(BUILD_TESTS) ocv_check_dependencies(${OPENCV_MODULE_${the_module}_OPT_DEPS})
add_android_project(opencv_test_java "${CMAKE_CURRENT_SOURCE_DIR}/android_test") if(BUILD_TESTS AND OCV_DEPENDENCIES_FOUND)
add_android_project(opencv_test_java "${CMAKE_CURRENT_SOURCE_DIR}/android_test")
add_custom_command( add_custom_command(
TARGET opencv_test_java_android_project POST_BUILD TARGET opencv_test_java_android_project POST_BUILD
COMMAND ${PYTHON_EXECUTABLE} ${CHECK_TEST_COVERAGE} "${CMAKE_CURRENT_SOURCE_DIR}/android_test/src" "${CMAKE_BINARY_DIR}/src" > "${CMAKE_CURRENT_BINARY_DIR}/tests_coverage.log" COMMAND ${PYTHON_EXECUTABLE} ${CHECK_TEST_COVERAGE} "${CMAKE_CURRENT_SOURCE_DIR}/android_test/src" "${CMAKE_BINARY_DIR}/src" > "${CMAKE_CURRENT_BINARY_DIR}/tests_coverage.log"
) )
endif() endif()

View File

@ -1,7 +1,3 @@
//
// This file is auto-generated, please don't edit!
//
#include <jni.h> #include <jni.h>
#ifdef DEBUG #ifdef DEBUG
@ -10,6 +6,9 @@
#define LOGD(...) ((void)__android_log_print(ANDROID_LOG_DEBUG, MODULE_LOG_TAG, __VA_ARGS__)) #define LOGD(...) ((void)__android_log_print(ANDROID_LOG_DEBUG, MODULE_LOG_TAG, __VA_ARGS__))
#endif // DEBUG #endif // DEBUG
#include "opencv2/opencv_modules.hpp"
#ifdef HAVE_OPENCV_HIGHGUI
#include "opencv2/highgui/highgui_c.h" #include "opencv2/highgui/highgui_c.h"
#include "opencv2/highgui/highgui.hpp" #include "opencv2/highgui/highgui.hpp"
using namespace cv; using namespace cv;
@ -452,3 +451,4 @@ JNIEXPORT void JNICALL Java_org_opencv_highgui_VideoCapture_n_1delete
} // extern "C" } // extern "C"
#endif // HAVE_OPENCV_HIGHGUI

View File

@ -180,7 +180,7 @@ void vector_Point3d_to_Mat(vector<Point3d>& v_point, Mat& mat)
mat = Mat(v_point, true); mat = Mat(v_point, true);
} }
#ifdef HAVE_OPENCV_FEATURES2D
//vector_KeyPoint //vector_KeyPoint
void Mat_to_vector_KeyPoint(Mat& mat, vector<KeyPoint>& v_kp) void Mat_to_vector_KeyPoint(Mat& mat, vector<KeyPoint>& v_kp)
{ {
@ -206,6 +206,7 @@ void vector_KeyPoint_to_Mat(vector<KeyPoint>& v_kp, Mat& mat)
mat.at< Vec<double, 7> >(i, 0) = Vec<double, 7>(kp.pt.x, kp.pt.y, kp.size, kp.angle, kp.response, kp.octave, kp.class_id); mat.at< Vec<double, 7> >(i, 0) = Vec<double, 7>(kp.pt.x, kp.pt.y, kp.size, kp.angle, kp.response, kp.octave, kp.class_id);
} }
} }
#endif
//vector_Mat //vector_Mat
@ -239,6 +240,7 @@ void vector_Mat_to_Mat(std::vector<cv::Mat>& v_mat, cv::Mat& mat)
} }
} }
#ifdef HAVE_OPENCV_FEATURES2D
//vector_DMatch //vector_DMatch
void Mat_to_vector_DMatch(Mat& mat, vector<DMatch>& v_dm) void Mat_to_vector_DMatch(Mat& mat, vector<DMatch>& v_dm)
{ {
@ -264,6 +266,7 @@ void vector_DMatch_to_Mat(vector<DMatch>& v_dm, Mat& mat)
mat.at< Vec<double, 4> >(i, 0) = Vec<double, 4>(dm.queryIdx, dm.trainIdx, dm.imgIdx, dm.distance); mat.at< Vec<double, 4> >(i, 0) = Vec<double, 4>(dm.queryIdx, dm.trainIdx, dm.imgIdx, dm.distance);
} }
} }
#endif
void Mat_to_vector_vector_Point(Mat& mat, vector< vector< Point > >& vv_pt) void Mat_to_vector_vector_Point(Mat& mat, vector< vector< Point > >& vv_pt)
{ {
@ -278,6 +281,7 @@ void Mat_to_vector_vector_Point(Mat& mat, vector< vector< Point > >& vv_pt)
} }
} }
#ifdef HAVE_OPENCV_FEATURES2D
void Mat_to_vector_vector_KeyPoint(Mat& mat, vector< vector< KeyPoint > >& vv_kp) void Mat_to_vector_vector_KeyPoint(Mat& mat, vector< vector< KeyPoint > >& vv_kp)
{ {
vector<Mat> vm; vector<Mat> vm;
@ -329,6 +333,7 @@ void vector_vector_DMatch_to_Mat(vector< vector< DMatch > >& vv_dm, Mat& mat)
} }
vector_Mat_to_Mat(vm, mat); vector_Mat_to_Mat(vm, mat);
} }
#endif
void Mat_to_vector_vector_char(Mat& mat, vector< vector< char > >& vv_ch) void Mat_to_vector_vector_char(Mat& mat, vector< vector< char > >& vv_ch)
{ {

View File

@ -1,10 +1,9 @@
#include <jni.h> #include <jni.h>
#include "opencv2/opencv_modules.hpp"
#include "opencv2/core/core.hpp" #include "opencv2/core/core.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "features2d_manual.hpp" #include "features2d_manual.hpp"
void Mat_to_vector_int(cv::Mat& mat, std::vector<int>& v_int); void Mat_to_vector_int(cv::Mat& mat, std::vector<int>& v_int);
void vector_int_to_Mat(std::vector<int>& v_int, cv::Mat& mat); void vector_int_to_Mat(std::vector<int>& v_int, cv::Mat& mat);
@ -41,12 +40,15 @@ void vector_Point3d_to_Mat(std::vector<cv::Point3d>& v_point, cv::Mat& mat);
void vector_Vec4f_to_Mat(std::vector<cv::Vec4f>& v_vec, cv::Mat& mat); void vector_Vec4f_to_Mat(std::vector<cv::Vec4f>& v_vec, cv::Mat& mat);
void vector_Vec6f_to_Mat(std::vector<cv::Vec6f>& v_vec, cv::Mat& mat); void vector_Vec6f_to_Mat(std::vector<cv::Vec6f>& v_vec, cv::Mat& mat);
#ifdef HAVE_OPENCV_FEATURES2D
void Mat_to_vector_KeyPoint(cv::Mat& mat, std::vector<cv::KeyPoint>& v_kp); void Mat_to_vector_KeyPoint(cv::Mat& mat, std::vector<cv::KeyPoint>& v_kp);
void vector_KeyPoint_to_Mat(std::vector<cv::KeyPoint>& v_kp, cv::Mat& mat); void vector_KeyPoint_to_Mat(std::vector<cv::KeyPoint>& v_kp, cv::Mat& mat);
#endif
void Mat_to_vector_Mat(cv::Mat& mat, std::vector<cv::Mat>& v_mat); void Mat_to_vector_Mat(cv::Mat& mat, std::vector<cv::Mat>& v_mat);
void vector_Mat_to_Mat(std::vector<cv::Mat>& v_mat, cv::Mat& mat); void vector_Mat_to_Mat(std::vector<cv::Mat>& v_mat, cv::Mat& mat);
#ifdef HAVE_OPENCV_FEATURES2D
void Mat_to_vector_DMatch(cv::Mat& mat, std::vector<cv::DMatch>& v_dm); void Mat_to_vector_DMatch(cv::Mat& mat, std::vector<cv::DMatch>& v_dm);
void vector_DMatch_to_Mat(std::vector<cv::DMatch>& v_dm, cv::Mat& mat); void vector_DMatch_to_Mat(std::vector<cv::DMatch>& v_dm, cv::Mat& mat);
@ -55,6 +57,7 @@ void vector_vector_KeyPoint_to_Mat(std::vector< std::vector< cv::KeyPoint > >& v
void Mat_to_vector_vector_DMatch(cv::Mat& mat, std::vector< std::vector< cv::DMatch > >& vv_dm); void Mat_to_vector_vector_DMatch(cv::Mat& mat, std::vector< std::vector< cv::DMatch > >& vv_dm);
void vector_vector_DMatch_to_Mat(std::vector< std::vector< cv::DMatch > >& vv_dm, cv::Mat& mat); void vector_vector_DMatch_to_Mat(std::vector< std::vector< cv::DMatch > >& vv_dm, cv::Mat& mat);
#endif
void Mat_to_vector_vector_char(cv::Mat& mat, std::vector< std::vector< char > >& vv_ch); void Mat_to_vector_vector_char(cv::Mat& mat, std::vector< std::vector< char > >& vv_ch);
void vector_vector_char_to_Mat(std::vector< std::vector< char > >& vv_ch, cv::Mat& mat); void vector_vector_char_to_Mat(std::vector< std::vector< char > >& vv_ch, cv::Mat& mat);

View File

@ -1,6 +1,9 @@
#ifndef __OPENCV_FEATURES_2D_MANUAL_HPP__ #ifndef __OPENCV_FEATURES_2D_MANUAL_HPP__
#define __OPENCV_FEATURES_2D_MANUAL_HPP__ #define __OPENCV_FEATURES_2D_MANUAL_HPP__
#include "opencv2/opencv_modules.hpp"
#ifdef HAVE_OPENCV_FEATURES2D
#include "opencv2/features2d/features2d.hpp" #include "opencv2/features2d/features2d.hpp"
namespace cv namespace cv
@ -10,6 +13,7 @@ class CV_EXPORTS_AS(FeatureDetector) javaFeatureDetector : public FeatureDetecto
{ {
public: public:
#if 0 #if 0
//DO NOT REMOVE! The block is required for sources parser
CV_WRAP void detect( const Mat& image, CV_OUT vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const; CV_WRAP void detect( const Mat& image, CV_OUT vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const;
CV_WRAP void detect( const vector<Mat>& images, CV_OUT vector<vector<KeyPoint> >& keypoints, const vector<Mat>& masks=vector<Mat>() ) const; CV_WRAP void detect( const vector<Mat>& images, CV_OUT vector<vector<KeyPoint> >& keypoints, const vector<Mat>& masks=vector<Mat>() ) const;
CV_WRAP virtual bool empty() const; CV_WRAP virtual bool empty() const;
@ -152,6 +156,7 @@ class CV_EXPORTS_AS(DescriptorMatcher) javaDescriptorMatcher : public Descriptor
{ {
public: public:
#if 0 #if 0
//DO NOT REMOVE! The block is required for sources parser
CV_WRAP virtual bool isMaskSupported() const; CV_WRAP virtual bool isMaskSupported() const;
CV_WRAP virtual void add( const vector<Mat>& descriptors ); CV_WRAP virtual void add( const vector<Mat>& descriptors );
CV_WRAP const vector<Mat>& getTrainDescriptors() const; CV_WRAP const vector<Mat>& getTrainDescriptors() const;
@ -245,6 +250,7 @@ class CV_EXPORTS_AS(DescriptorExtractor) javaDescriptorExtractor : public Descri
{ {
public: public:
#if 0 #if 0
//DO NOT REMOVE! The block is required for sources parser
CV_WRAP void compute( const Mat& image, vector<KeyPoint>& keypoints, Mat& descriptors ) const; CV_WRAP void compute( const Mat& image, vector<KeyPoint>& keypoints, Mat& descriptors ) const;
CV_WRAP void compute( const vector<Mat>& images, vector<vector<KeyPoint> >& keypoints, CV_OUT vector<Mat>& descriptors ) const; CV_WRAP void compute( const vector<Mat>& images, vector<vector<KeyPoint> >& keypoints, CV_OUT vector<Mat>& descriptors ) const;
CV_WRAP virtual int descriptorSize() const; CV_WRAP virtual int descriptorSize() const;
@ -326,6 +332,7 @@ class CV_EXPORTS_AS(GenericDescriptorMatcher) javaGenericDescriptorMatcher : pub
{ {
public: public:
#if 0 #if 0
//DO NOT REMOVE! The block is required for sources parser
CV_WRAP virtual void add( const vector<Mat>& images, CV_WRAP virtual void add( const vector<Mat>& images,
vector<vector<KeyPoint> >& keypoints ); vector<vector<KeyPoint> >& keypoints );
CV_WRAP const vector<Mat>& getTrainImages() const; CV_WRAP const vector<Mat>& getTrainImages() const;
@ -411,6 +418,7 @@ public:
}; };
#if 0 #if 0
//DO NOT REMOVE! The block is required for sources parser
enum enum
{ {
DRAW_OVER_OUTIMG = 1, // Output image matrix will not be created (Mat::create). DRAW_OVER_OUTIMG = 1, // Output image matrix will not be created (Mat::create).
@ -441,4 +449,6 @@ CV_EXPORTS_AS(drawMatches2) void drawMatches( const Mat& img1, const vector<KeyP
} //cv } //cv
#endif // HAVE_OPENCV_FEATURES2D
#endif // __OPENCV_FEATURES_2D_MANUAL_HPP__ #endif // __OPENCV_FEATURES_2D_MANUAL_HPP__