-
-
Notifications
You must be signed in to change notification settings - Fork 56.5k
OpenCV does not track correctly libOpenNI2.so #23579
Description
System Information
This issue is architecture agnostic. Anyway:
OpenCV version: 4.6.0 SHA1 3f371fe
Operating System / Platform: Ubuntu 20.04
Compiler & compiler version: x86_64 with g++
Compiler & compiler version: x86_64 with cross-compiler ARM i.MX 8
Detailed description
My issue is in two points. A minor: some issues inside the documentation (out of date). I should have created a dedicated ticket, but this linked with my major issue: OpenCV does not track libOpenNI2.so to OpenCV_LIBS and it should do it.
Concerning the documentation
-
the link to Orbbec is broken:
This tutorial is devoted to the Astra Series of Orbbec 3D cameras (https://orbbec3d.com/product-astra-pro/). -
the link to the SDK 2.3 is broken:
-# Download the latest version of Orbbec OpenNI SDK (from here <https://orbbec3d.com/develop/>).
This last can be found here https://orbbec3d.com/index/download.html "Orbbec OpenNI SDK for Linux". With a wget command, I downloaded it and compiled OpenCV against it (x86_64 and arm imx8).
Issue 1
- Since version 2.3, they have changed their install.sh. The creation of the
OpenNIDevEnvironmentfile is not made. So the following commands in the tutorial are useless:
| $ source OpenNIDevEnvironment |
| $ echo $OPENNI2_INCLUDE |
- Since version 2.3 folders inside the SDK have changed. The following line shall be updated:
| PATH_SUFFIXES "Redist" "Lib" |
It is "libs" now. If I update detect_openni2.cmake and the set OPENNI2_DIR="$OPENNI_PATH/sdk" to the cmake command for compiling OpenCV, it does not find my local libOpenNI2.so but only the one installed in my operating system (with apt-get install I guess).
- As consequence, to compile OpenCV against OpenNI, I had to do:
cmake ... -DWITH_OPENNI=ON -DWITH_OPENNI2=ON
-DOPENNI2_INCLUDE="$OPENNI_PATH/sdk/Include"
-DOPENNI2_DIR="$OPENNI_PATH/sdk"
-DOPENNI2_LIBRARY="$OPENNI_PATH/sdk/libs/libOpenNI2.so"
I see:
-- OpenNI2: YES (2.3.0)
The next issue is my main concern for this ticket.
Issue 2
while OPENNI2_LIBRARIES is set in
| set(OPENNI2_LIBRARIES "${OPENNI2_SYS_LIBRARY}") |
When linking my project against OpenCV in my CMakeLists.txt:
message(${OpenCV_LIBS})
target_link_libraries(myapplication ${OpenCV_LIBS})
I have a linkage issue:
warning: libOpenNI2.so, needed by /home/xxx/yyy/build/armimx8/opencv/lib/libopencv_videoio.so.4.6.0, not found (try using -rpath or -rpath-link)
/home/xxxxxx/depend/build/armimx8/opencv/lib/libopencv_videoio.so.4.6.0: undefined reference to `oniDeviceEnableDepthColorSync'
/home/xxxxxx/depend/build/armimx8/opencv/lib/libopencv_videoio.so.4.6.0: undefined reference to `oniStreamGetSensorInfo'
/home/xxxxxx/depend/build/armimx8/opencv/lib/libopencv_videoio.so.4.6.0: undefined reference to `oniFrameRelease'
Because OpenCV_LIBS does not contain libOpenNI2.so. This can be solved if I choose one of the following solution:
- Install libOpenNI2.so on my system (apt-get or in the cross-compiler lib/ folder).
- Do
target_link_libraries(myapplication ${OpenCV_LIBS} /xxx/libOpenNI2.so)
The first solution is not possible for me (not admin, CI ...). The second solution works, but my project depends on third part libraries using the OpenCV compiled locally will fail because they also need libOpenNI2.so (and I cannot modify their CMake files). The LD_LIBRARY_PATH does not work (cross compilation, I don't know why).
As general issue: When linking to external third parts libs such OpenNI, OpenCV shall set them in the CMake variable OpenCV_LIBS (same thing for library paths) and shall do not depend on the presence of installed system libraries. Therefore:
message(${OpenCV_LIBS})
shall display ... libopencv_videoio.so ... libOpenNI2.so
Steps to reproduce
- Compile OpenCV against OpenNI2 locally downloaded (with -DWITH_OPENNI ... as explained previously).
- libOpenNI2.so shall not be installed on the operating system (no apt-get install, no cp commands to /usr/lib).
- Compile an application linking against OpenCV (target_link_libraries(myapplication ${OpenCV_LIBS}))
- A linkage issue shall appear (libOpenNI2.so needed by libopencv_videoio.so)
- You do not even need an Orbbec camera.
What desired ?
To include OPENNI2_LIBRARY inside the OpenCV_LIBS variable as well for lib folder paths.
Issue submission checklist
- I report the issue, it's not a question
- I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
- I updated to the latest OpenCV version and the issue is still there
- There is reproducer code and related data files (videos, images, onnx, etc)
Update
- I'm on SHA1 3f371fe. On the HEAD of 4.X branch, I reached in fact an assert.
- The tutorial says
colorStream.set(CAP_PROP_FRAME_WIDTH, 640)but this function is failing (return false). We cannot change the resolution. The get() function returns correctly the resolution and FPS (et least for with Mini Astra).