PCL Kinect Fusion その1
『KINECT for Windows SDKプログラミングKinect for Windows v2センサー対応版』
の320ページ、7.1.3(Kinect Fusion関連のやつ)を試そうと思った、、けど、
まずは検索でヒットしたqiitaの記事を試した時のメモ。
Kinect v2のKinectFusionから色付きの3次元点群と自己位置を得る方法(Visual Studio 2013, OpenCV, C++, Kinect v2) - Qiita
手順
自分で書いたメモを見つつ、Visual Studio 2013でサンプルプロジェクト作成。
Point Cloud Libraryのインストールと設定 - kubotti’s memo
Point Cloud Libraryのビューワーでkinectのデータを表示 - kubotti’s memo
プロジェクト名は、PclFusion1とかPclFusion2にした。
https://github.com/UnaNancyOwen/Kinect2Sample/tree/master/Sample/Fusion
にある、
Fusion.cpp
KinectFusionHelper.cpp
KinectFusionHelper.h
を自分のVSプロジェクトにコピペ。
エラーその1
cannot open source file opencv2/opencv.hpp
Solution Explorerで、PclViewerSample1(プロジェクト名)を右クリック。
Release Property Pagesの
Configuration: で、All Configurations を選択。
Configuration Properties > C/C++ > General > Additional Include Directories
で、
C:\opencv\build\include
を追加。
エラーその2
Error 1 error LNK1181: cannot open input file 'C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\\lib\x64.obj'
Configuration Properties > Linker > Input > Additional Dependencies
で、
$(KINECTSDK20_DIR)\lib\x64
を追加するとこのエラーが出るようになる。
Configuration Properties > Linker > General > Additional Library Directories
に追加すべき、
$(KINECTSDK20_DIR)\lib\x64
を
Configuration Properties > Linker > Input > Additional Dependencies
に追加していたのが原因だった。
Configuration Properties > Linker > General > Additional Library Directories
に
Kinect20.lib
を間違って追加していた。
エラーその3
Error 1 error LNK2001: unresolved external symbol "public: void __cdecl cv::Mat::create(int,int const *,int)" (?create@Mat@cv@@QEAAXHPEBHH@Z)
OpenCVの設定が足りなかった。
c++ - error LNK2019: unresolved external symbol opencv - Stack Overflow
エラーその4
error lnk1181: cannot open input file opencv_core246d.lib
StackOverflowからコピーしたファイル名が自分のPCのファイル名と違っていた。(246dじゃなくて249d)
opencv_core249d.lib opencv_imgproc249d.lib opencv_highgui249d.lib opencv_ml249d.lib opencv_video249d.lib opencv_features2d249d.lib opencv_calib3d249d.lib opencv_objdetect249d.lib opencv_contrib249d.lib opencv_legacy249d.lib opencv_flann249d.lib
エラーその5
Error 1 error LNK2001: unresolved external symbol GetDefaultKinectSensor Error 2 error LNK2001: unresolved external symbol __imp_NuiFusionCreateReconstruction Error 3 error LNK2001: unresolved external symbol __imp_NuiFusionCreateImageFrame Error 4 error LNK2001: unresolved external symbol __imp_NuiFusionShadePointCloud Error 5 error LNK2001: unresolved external symbol __imp_NuiFusionReleaseImageFrame Error 6 error LNK1120: 5 unresolved externals
Configuration Properties > Linker > Input > Additional Dependencies
で、
Kinect20.lib
以外に
Kinect20.Fusion.lib
を足したら、エラー解消。
エラーその6
実行したら、以下のエラー。
コンピューターに Kinect20.Fusion.dll がないため、プログラムを開始できません。この問題を解決するには、プログラムを再インストールしてみてください。
システム環境変数に、
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\bin
を足した。
エラーその7
実行したら途中でエラー。
Unhandled exception at 0x00007FFAACCDD48E (opencv_highgui249d.dll) in PclFusion2.exe: 0xC0000005: Access violation reading location 0x00000000402C0062.
c++ - OpenCV 2.2 VS2010 - Get an "Access violation reading" in a very simple code - Stack Overflow
the solution is to use libraries with 'd' suffix such as "opencv_core244d.lib" for debug, and use normal libraries such as "opencv_core244.lib" for release. it just works. Good luck
OpenCV関連の.libで249dのdを取ったら、エラー解消。
opencv_core249.lib opencv_imgproc249.lib opencv_highgui249.lib opencv_ml249.lib opencv_video249.lib opencv_features2d249.lib opencv_calib3d249.lib opencv_objdetect249.lib opencv_contrib249.lib opencv_legacy249.lib opencv_flann249.lib
画面が表示された!
キャプチャ画像