2011-10-20 172 views
6

我一直在嘗試使用Kinect庫(http://nicolas.burrus.name/index.php/Research/KinectUseNestk)運行「開始使用教程」,但是我偶然發現一個錯誤。CMAKE找不到OpenNI

當我嘗試在命令行下面一行:

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上。

回答

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中手動指定這些路徑。

我希望它有幫助!

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}) 
0

確保OPEN_NI_BIN,OPEN_NI_INCLUDE,OPEN_NI_INSTALL_PATH環境變量都設置以及它們指向正確的地方,因爲cmake的檢查OPEN_NI的模塊檢查這些值。 我得到了同樣的錯誤,但在我的情況下,這是一個混合64位和32位庫的問題。我用32位編譯器構建opencv,但OpenNI是64位。所以我卸載了所有的64位,只剩下32位版本,這使得它工作。

親切的問候, 丹尼爾

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)