Cinder + OpenCV + Librealsense

Hi,
I’m trying to use Cinder with Realsense and OpenCV4 on Raspberry Pi. I have managed to make both of them to work separately in a Cinder app. After that, I tried to use the librealsense2’s OpenCV imshow example inside cinder, but I got the error

TestApp.cpp:(.text+0x8e6): undefined reference to `cv::error(int, std::string const&, char const*, char const*, int)'

I believe the error is caused by the transformation of raw data into a cv::Mat, but it works outside Cinder:

Mat image(Size(w, h), CV_8UC3, (void*)depth.get_data(), Mat::AUTO_STEP);

I used cmake to complie and the CMakeLists.txt that I have:

cmake_minimum_required( VERSION 2.8 FATAL_ERROR )
set( CMAKE_VERBOSE_MAKEFILE ON )

project( TestApp )
find_package(OpenCV REQUIRED)
include_directories( ${OpenCV_INCLUDE_DIRS} )
find_package(realsense2 REQUIRED)


get_filename_component( CINDER_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../../Cinder" ABSOLUTE )
get_filename_component( APP_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../" ABSOLUTE )

include( "${CINDER_PATH}/proj/cmake/modules/cinderMakeApp.cmake" )

ci_make_app(
	SOURCES     ${APP_PATH}/src/TestApp.cpp
	CINDER_PATH ${CINDER_PATH}
	LIBRARIES   ${OpenCV_LIBS}
)

target_link_libraries(TestApp ${OpenCV_LIBS})
target_link_libraries(TestApp ${realsense2_LIBRARY})

I have look up anywhere and could not find a solution. Is there any advise? I would be thankful for any help.

(edit: fixed the formatting of this post ~Paul)

Hi,

Not sure if these are typos or actual errors in your CMake file since formatting is completely off but try smt like this:

cmake_minimum_required( VERSION 2.8 FATAL_ERROR )

project( TestApp )

get_filename_component( CINDER_PATH "{CMAKE_CURRENT_SOURCE_DIR}/../../../../Cinder" ABSOLUTE ) 
get_filename_component( APP_PATH "{CMAKE_CURRENT_SOURCE_DIR}/../../" ABSOLUTE )

include( "${CINDER_PATH}/proj/cmake/modules/cinderMakeApp.cmake" )

# OpenCV
# You might need to set OpenCV_DIR to point to the directory containing OpenCVConfig.cmake
# It should be located in the build/installation folder of OpenCV.

#set( OpenCV_DIR "/your/path/to/opencv/installation/dir"

find_package( OpenCV REQUIRED )

message(STATUS "OpenCV library status:")
message(STATUS "    config: ${OpenCV_DIR}")
message(STATUS "    version: ${OpenCV_VERSION}")
message(STATUS "    libraries: ${OpenCV_LIBS}")
message(STATUS "    include path: ${OpenCV_INCLUDE_DIRS}")

# realsense2
find_package( realsense2 REQUIRED )

ci_make_app(
   CINDER_PATH ${CINDER_PATH}
   SOURCES ${APP_PATH}/src/TestApp.cpp
   INCLUDES ${realsense_INCLUDE_DIR} ${OpenCV_INCLUDE_DIRS} )
   LIBRARIES ${OpenCV_Libs} ${realsense2_LIBRARY}
)

Note that this is untested so if it still does not work then you should post the full output from CMake during configuration and also the output of CMakeOutput.log and CMakeError.log that should be located in your build directory.

HTH,
Petros