Linking Nuitrack and OpenCV

I am building an application that needs to save nuitrack skeleton data as well as raw image data.
Using DepthSensor and ColorSensor from Nuitrack API I can get the image data, and I want to save it using cv::imwrite() function from OpenCV.

I noticed that nuitrack installation comes with opencv (2.4.8) shared libraries in /usr/local/lib/nuitrack, so I downloaded the opencv2.4 include headers from github and wrote CMakeLists.txt as:

target_link_libraries(skeleton_face
	nuitrack
	:libopencv_highgui.so.2.4
	:libopencv_core.so.2.4
)

It compiles fine but linking throws the following error:

undefined reference to `cv::imwrite(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&, std::vector<int, std::allocator<int> > const&)'
collect2: error: ld returned 1 exit status

I have also tried to compile my own opencv library, tried even different versions (2.4.8, 2.4.13, 3.x) instead of utilizing the ones bundled with nuitrack, but I still get all kinds of linking errors.

This is very strange, because if I don’t link with nuitrack, opencv linking works perfectly. It seems as if libnuitrack.so is disturbing proper linking of standard opencv functions.

Any ideas?

Hi dorin,

Please provide us with the version of your compiler.
Besides, try to add the following line to the CMakeLists.txt:

add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)

1 Like

Compiler is g++ 5.4.0.
GLIBCXX_USE_CXX11_ABI=0 solved the opencv linking prolem, but the default is 1 and I had switched it back to 1 because otherwise I would get linking errors from other libraries I am using. I will probably try compiling
the other libraries with the same flag to avoid problems…

Thank you for the right pointer!

I updated to SDK 0.28.0 and this issue came back…

Why is this happening? I also updated CMakelists.txt to link libopencv_core.so.3.4 and libopencv_highgui.so.3.4 but there are the same undefined reference errors.

Hi dorin,

please try to use latest Nuitrack SDK v1.4.0, you can download it here https://nuitrack.com/#api (as previous version is incompatible with Nuitrack v0.28.0 runtime component).

Do you mean the include headers are different for v0.28.0?
Otherwise, all the sdk binaries (.so) are included and updated along with the .deb package.

I have a suggestion, why not pack the include headers in the .deb installer as well, it would make it so much easier for everyone. Right now we have to add the include headers to our own repository code.

I will try to update the headers although I’m not sure it will solve the linking with opencv.

Okay I solved it, it was due to old opencv 2.4 headers which had imwrite in module highgui, while in 3.4 this function was moved to module imgcodecs.
I updated to opencv 3.4 headers and it’s fine.