CMAKE找不到OpenNI

时间:2011-10-20 13:54:36

标签: cmake rgb kinect openni

我一直在尝试使用Kinect库(http://nicolas.burrus.name/index.php/Research/KinectUseNestk)运行“入门教程”,但我偶然发现了一个错误。

当我在CLI中尝试以下行时:

cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ..

我收到以下错误:

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)

有谁知道我该如何解决这个问题?我安装了OpenNI,它安装在D:\ Program Files \ OpenNI。

4 个答案:

答案 0 :(得分:5)

要使用CMAKE对OpenNI项目进行生成,您可以在cmakelists中对此进行编辑。它工作正常。 (我还包括NITE2,但如果你不需要删除那些行)。

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 )

稍后您需要链接找到的目录和库:

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

答案 1 :(得分:2)

您可以尝试修改CMakeLists.txt文件并添加或修改以下行

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

否则,在二进制文件夹中查找名为CMakeCache.txt的文件。查找OPENNI_INCLUDE_DIR和OPENNI_LIB_DIR,设置正确的路径,然后再次运行cmake。

如果这些都不起作用,并且您可以运行cmake-gui,请尝试使用它而不是cli命令,并在GUI中手动指定这些路径。

我希望它有所帮助!

答案 2 :(得分:0)

确保OPEN_NI_BIN,OPEN_NI_INCLUDE,OPEN_NI_INSTALL_PATH环境变量都已设置且它们指向正确的位置,因为检查OPEN_NI的cmake模块会检查这些值。 我得到了同样的错误,但在我的情况下,混合64位和32位库是一个问题。我用32位编译器构建opencv,但OpenNI是64位。所以我卸载了所有64位版本并且只留下了32位版本,这使它运行起来。

亲切的问候, 丹尼尔

答案 3 :(得分:0)

典型的openni2发行版有以下文件/OpenNI-Linux-Arm-2.2/OpenNIDevEnvironment

它描述了编译和链接所需的所有变量:

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

因此,您需要导出这些变量,然后在启用OpenNI2的情况下运行cmake:

$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  ..

在cmake结果的某处你应该看到:

- OpenNI2:YES(版本2.2.0,版本33)