# Cinder + OpenCV + Librealsense

**URL:** <https://discourse.libcinder.org/t/cinder-opencv-librealsense/1490>\
**Category:** Using Cinder\
**Created:** [April 21, 2019, 3:59pm UTC](https://discourse.libcinder.org/t/cinder-opencv-librealsense/1490 "2019-04-21T15:59:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![howw](https://avatars.discourse-cdn.com/v4/letter/h/f0a364/32.png) [@howw](https://discourse.libcinder.org/u/howw)\
**Post date:** [April 21, 2019, 3:59pm UTC](https://discourse.libcinder.org/t/cinder-opencv-librealsense/1490/1 "2019-04-21T15:59:49Z")

</div>

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:

```auto
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)_

---

<div class="post-metadata">

**Author:** ![petros](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/petros/32/26_2.png) [@petros](https://discourse.libcinder.org/u/petros)\
**Post date:** [April 22, 2019, 6:42am UTC](https://discourse.libcinder.org/t/cinder-opencv-librealsense/1490/2 "2019-04-22T06:42:01Z")

</div>

Hi,

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

```auto
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
