Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I've made some progress in resolving this issue but not sure if this is the right approach or not. Seems like the problem is related to the way how include paths are configured in CMake for java module. The following changes are leading to successful compilation:

In the file /opencv_contrib/modules/dnn/cmake/OpenCVFindLibProtobuf.cmake, the following line:

set(PROTOBUF_INCLUDE_DIR "${PROTOBUF_CPP_ROOT}/src")

is to be replaced with

set(PROTOBUF_INCLUDE_DIR "${PROTOBUF_CPP_ROOT}/src" PARENT_SCOPE)

The purpose of this change is to make the PROTOBUF_INCLUDE_DIR variable visible for the CMake script in the main repository.

The next step is to locate the following line in the /opencv_contrib/modules/dnn/3rdparty/protobuf/CMakeLists.txt:

ocv_module_include_directories("${OpenCV_SOURCE_DIR}/include")

and insert the following code below this line:

if(BUILD_PROTOBUF)
    message(STATUS "PROTOBUF_INCLUDE_DIR=${PROTOBUF_INCLUDE_DIR}")
    ocv_module_include_directories("${PROTOBUF_INCLUDE_DIR}")
endif()

After these changes java wrappers are generated successfully for dnn module.

I've made some progress in resolving this issue but not sure if this is the right approach or not. Seems like the problem is related to the way how include paths are configured in CMake for java module. The following changes are leading to successful compilation:

In the file /opencv_contrib/modules/dnn/cmake/OpenCVFindLibProtobuf.cmake, the following line:

set(PROTOBUF_INCLUDE_DIR "${PROTOBUF_CPP_ROOT}/src")

is to be replaced with

set(PROTOBUF_INCLUDE_DIR "${PROTOBUF_CPP_ROOT}/src" PARENT_SCOPE)

The purpose of this change is to make the PROTOBUF_INCLUDE_DIR variable visible for the CMake script in the main repository.

The next step is to locate the following line in the /opencv_contrib/modules/dnn/3rdparty/protobuf/CMakeLists.txt:/opencv/modules/java/CMakeLists.txt:

ocv_module_include_directories("${OpenCV_SOURCE_DIR}/include")

and insert the following code below this line:

if(BUILD_PROTOBUF)
    message(STATUS "PROTOBUF_INCLUDE_DIR=${PROTOBUF_INCLUDE_DIR}")
    ocv_module_include_directories("${PROTOBUF_INCLUDE_DIR}")
endif()

After these changes java wrappers are generated successfully for dnn module.