CMAKE cannot find OpenNI

I am trying to run a “tutorial to start” with the Kinect libraries (http://nicolas.burrus.name/index.php/Research/KinectUseNestk), but I came across an error.

When I try the following line in the CLI:

cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo .. 

I get the following error:

 CMake Error at D:/Program Files/CMake 2.8/share/cmake-2.8/Modules/FindPackageHan dleStandardArgs.cmake:91 (MESSAGE): Could NOT find OpenNI (missing: OPENNI_LIBRARY OPENNI_INCLUDE_DIR) Call Stack (most recent call first): D:/Program Files/CMake 2.8/share/cmake-2.8/Modules/FindPackageHandleStandardAr gs.cmake:252 (_FPHSA_FAILURE_MESSAGE) nestk/cmake/FindOpenNI.cmake:51 (find_package_handle_standard_args) nestk/cmake/find_nestk_deps.cmake:77 (FIND_PACKAGE) build/nestk/UseEmbeddedNestk.cmake:23 (INCLUDE) nestk/CMakeLists.txt:67 (INCLUDE) 

Does anyone know how to solve this? Ive installed OpenNI, it was installed in D: \ Program Files \ OpenNI.

+6
source share
4 answers

To create an OpenNI project using CMAKE, you can use this in your cmakelists. It is working fine. (I also included NITE2, but unless you just need to delete these lines).

 OPTION (ENABLE_OPENNI2_NITE2 ON) IF( ENABLE_OPENNI2_NITE2 ) set(OPENNI2_DEFINITIONS ${PC_OPENNI_CFLAGS_OTHER}) FIND_LIBRARY( OPENNI2_LIBRARY NAMES OpenNI2 HINTS ${PC_OPENNI2_LIBDIR} ${PC_OPENNI2_LIBRARY_DIRS} /usr/lib PATHS "$ENV{PROGRAMFILES}/OpenNI2/Lib${OPENNI2_SUFFIX}" "$ENV{PROGRAMW6432}/OpenNI2/Lib${OPENNI2_SUFFIX}" "$ENV{PROGRAMW6432}/OpenNI2" PATH_SUFFIXES lib lib64 ) FIND_PATH( OPENNI2_INCLUDE_DIR OpenNI.h HINTS ${PC_OPENNI2_INCLUDEDIR} ${PC_OPENNI2_INCLUDE_DIRS} /usr/include/openni2 /usr/include/ni2 PATHS "$ENV{PROGRAMFILES}/OpenNI2/include" "$ENV{PROGRAMW6432}/OpenNI2/include" PATH_SUFFIXES openni2 ni2) FIND_LIBRARY( NITE2_LIBRARY NAMES NiTE2 HINTS ${PC_OPENNI2_LIBDIR} ${PC_OPENNI2_LIBRARY_DIRS} /usr/lib PATHS "$ENV{PROGRAMFILES}/PrimeSense/NiTE2/lib${OPENNI2_SUFFIX}" "$ENV{PROGRAMW6432}/PrimeSense/NiTE2/lib${OPENNI2_SUFFIX}" PATH_SUFFIXES lib ) FIND_PATH( NITE2_INCLUDE_DIR NiTE.h HINTS ${PC_OPENNI2_INCLUDEDIR} ${PC_OPENNI2_INCLUDE_DIRS} /usr/include/openni2 /usr/include/nite2 PATHS "$ENV{PROGRAMFILES}/PrimeSense/NiTE2/include" "$ENV{PROGRAMW6432}/PrimeSense/NiTE2/include" PATH_SUFFIXES openni2 ) ENDIF( ENABLE_OPENNI2_NITE2 ) 

And later you need to link the found directories and libraries:

 link_directories( ${OPENNI2_LIBRARY} ${NITE2_LIBRARY} ) INCLUDE_DIRECTORIES( ${OPENNI2_INCLUDE_DIR} ${NITE2_INCLUDE_DIR} ) target_link_libraries( project ${OPENNI2_LIBRARY} ${NITE2_LIBRARY} ) 
+5
source

You can try to modify the CMakeLists.txt file and add or change the following lines

 set(OPENNI_INCLUDE_DIR "D:/Program Files/OpenNI/Include") set(OPENNI_LIB_DIR "D:/Program Files/OpenNI/Lib") 

Otherwise, find the file named CMakeCache.txt inside the binary folder. Find OPENNI_INCLUDE_DIR and OPENNI_LIB_DIR, set the correct path and run cmake again.

If none of them work, and you can run cmake-gui, try using it instead of the cli command and manually specify these paths in the GUI.

Hope this helps!

+2
source

Make sure that all environment variables OPEN_NI_BIN, OPEN_NI_INCLUDE, OPEN_NI_INSTALL_PATH are configured and point to the right place, because the cmake module that checks OPEN_NI checks these values. I was getting the same error, but in my case it was a problem with mixing 64-bit and 32-bit libraries. I built opencv with 32 bit compilers, but OpenNI was 64 bit. Therefore, I deleted all 64-bit and left only 32-bit versions, which made it work.

Regards, Daniel

0
source

A typical openni2 distribution has the following file / OpenNI -Linux-Arm-2.2 / OpenNIDevEnvironment

He described all the necessary variables for compilation and reference:

 export OPENNI2_INCLUDE=/opt/cbox/OpenNI-Linux-Arm-2.2/Include export OPENNI2_REDIST=/opt/cbox/OpenNI-Linux-Arm-2.2/Redist 

So, you need to export these variables, and then run cmake with OpenNI2 enabled:

 $export OPENNI2_INCLUDE=/opt/cbox/OpenNI-Linux-Arm-2.2/Include $export OPENNI2_REDIST=/opt/cbox/OpenNI-Linux-Arm-2.2/Redist $cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_OPENNI2=ON .. 

Somewhere as a result of cmake you should see:

- OpenNI2: YES (version 2.2.0, build 33)

0
source

Source: https://habr.com/ru/post/899701/


All Articles