CMAKE can't find OpenNI
Asked Answered
C

4

6

I’ve been trying to run the “tutorial to get started” with the Kinect libraries (http://nicolas.burrus.name/index.php/Research/KinectUseNestk) but I stumbled 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 have any idea how I have to solve this? I’ve installed OpenNI, it’s installed at D:\Program Files\OpenNI.

Cirrhosis answered 20/10, 2011 at 13:54 Comment(0)
B
6

For biulding an OpenNI project with CMAKE you can wirte this in your cmakelists. It works fine. (I also included NITE2, but if you don't needed just delete those 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 directories and libs found:

link_directories( ${OPENNI2_LIBRARY} ${NITE2_LIBRARY} )
INCLUDE_DIRECTORIES( ${OPENNI2_INCLUDE_DIR} ${NITE2_INCLUDE_DIR} )
target_link_libraries( project ${OPENNI2_LIBRARY} ${NITE2_LIBRARY} )
Battleplane answered 11/4, 2013 at 8:22 Comment(0)
S
2

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

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

Otherwise, look for a file named CMakeCache.txt inside the binaries folder. Look for OPENNI_INCLUDE_DIR and OPENNI_LIB_DIR, set the right path, and run cmake again.

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

I hope it helps!

Supernormal answered 27/10, 2011 at 11:2 Comment(0)
B
0

Make sure OPEN_NI_BIN, OPEN_NI_INCLUDE, OPEN_NI_INSTALL_PATH environment variables are all set and that they point to the right place, because the cmake module that checks for OPEN_NI checks those values. I was getting the same error, but in my case, it was a problem mixing 64 and 32 bit libraries. I was building opencv with 32 bit compilers, but OpenNI was 64 bit. So I uninstalled all 64bit and left only 32 bit versions, which made it work.

Kind regards, Daniel

Bary answered 6/3, 2014 at 21:37 Comment(0)
H
0

Typical openni2 distribution has following file /OpenNI-Linux-Arm-2.2/OpenNIDevEnvironment

It has described all necessary variables to compile and link:

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 the 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 in cmake result you should see:

-- OpenNI2: YES (ver 2.2.0, build 33)

Homorganic answered 9/6, 2017 at 11:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.