配置環境如題,顯卡是TITAN X
安裝流程:
1.安裝vs2013
2.安裝cuda8.0
3.安裝DirectX SDK June 2010
4.安裝Kinect SDK 2.0
5.從github裏把bundlefusion下載下來https://github.com/niessner/BundleFusion
6.下載mLibExtrernal,放在與bundlefusion同級文件夾下:http://kaldir.vc.in.tum.de/mLib/mLibExternal.zip
7.下載mLib,放在BundleFusion-master/external/mLib裏面:https://github.com/niessner/mLib
8.此時的文件位置是這樣的:
BundleFusion-master/
external/
mLib/ # this is the submodule you replaced
data/
src/
[...]
FriedLiver/
[...]
FriedLiver.sln
[...]
mLibExternal/ # you downloaded this from Dropbox
include
libsWindows
[...]
9.用vs2013打開FriedLiver.sln,會報錯找不到cuda7.0,這時只需從vs2013裏面編輯FriedLiver.vcxproj,將所有的CUDA 7.0.props都變成CUDA 8.0.props即可,修改後重新加載項目。
10.然後就開始編譯了
先編譯離線方法:
將GlobalAppState.h中這樣修改:
//#define KINECT
//#define KINECT_ONE
//#define OPEN_NI
#define BINARY_DUMP_READER
//#define INTEL_SENSOR
//#define REAL_SENSE
//#define STRUCTURE_SENSOR
#define SENSOR_DATA_READER
#define RUN_MULTITHREADED
然後用Release編譯(debug會報dll缺失的錯),編譯成功。
如果想要用debug編譯,需要將mLibExternal/libsWindows/dll64裏的FreeImage.dll放入C:\Windows\System32和C:\Windows\SysWOW64即可。
將zParametersDefault.txt中的s_sensorIdx 設爲8,使用離線模式。
下載數據集:http://graphics.stanford.edu/projects/bundlefusion/
將s_binaryDumpSensorFile = "../data/apt0.sens";設置爲你自己的數據集路徑。
回到程序裏直接ctrl+f5運行即可。注意此時可能會出現一些GPU原因導致的程序運行一段時間就退出的現象:可以嘗試調節zParametersDefault.txt裏的以下幾個參數:s_SDFVoxelSize = 0.010f;s_hashNumSDFBlocks = 200000;或者更新一下驅動。我是用上述的參數值可以完整重建離線數據的。此外,如果你在最終保存時出現超出最大面片數的提示,並且保存的模型上面有很多孔洞,可以調節這個參數:s_marchingCubesMaxNumTriangles = 6000000;
Kinect V2 實時重建:
將GlobalAppState.h中這樣修改:
//#define KINECT
#define KINECT_ONE
//#define OPEN_NI
#define BINARY_DUMP_READER
//#define INTEL_SENSOR
//#define REAL_SENSE
//#define STRUCTURE_SENSOR
#define SENSOR_DATA_READER
#define RUN_MULTITHREADED
然後對 DepthSensing.cpp 做如下修改:
將987行的
bGotDepth = g_CudaImageManager->process()
替換爲
bool bGotDepth;
while (!(bGotDepth = g_CudaImageManager->process()));
用Release編譯,編譯成功。
將zParametersDefault.txt中的s_sensorIdx 設爲2,使用KinectOne進行數據採集。
接入kinect v2,回到程序裏直接ctrl+f5運行即可。
但是,值得注意的是,Kinect V2 的sdk採集的圖像是個鏡像,就像我們的手機前置鏡頭拍攝的圖像一樣,是左右顛倒的,因此我們重建出的場景模型也是左右顛倒的。
這時我們需要在KinectOneSensor.cpp中的setupUndistortion()函數裏進行如下修改:
將
CameraSpacePoint cameraFrameCorners[4] = //at 1 meter distance. Take into account that depth frame is mirrored
{
{ -principalPointX / focalLengthX, principalPointY / focalLengthY, 1.f }, // LT
{ (1.f - principalPointX) / focalLengthX, principalPointY / focalLengthY, 1.f }, // RT
{ -principalPointX / focalLengthX, (principalPointY - 1.f) / focalLengthY, 1.f }, // LB
{ (1.f - principalPointX) / focalLengthX, (principalPointY - 1.f) / focalLengthY, 1.f } // RB
};
中每個點的x分量取反,取反後代碼如下:
CameraSpacePoint cameraFrameCorners[4] = //at 1 meter distance. Take into account that depth frame is mirrored
{
{ principalPointX / focalLengthX, principalPointY / focalLengthY, 1.f }, // LT
{ -(1.f - principalPointX) / focalLengthX, principalPointY / focalLengthY, 1.f }, // RT
{ principalPointX / focalLengthX, (principalPointY - 1.f) / focalLengthY, 1.f }, // LB
{ -(1.f - principalPointX) / focalLengthX, (principalPointY - 1.f) / focalLengthY, 1.f } // RB
};
再運行,則模型不在有鏡像問題~
成功~~~
參考方法:
https://bericht.neopostmodern.com/posts/artist-guide-to-bundlefusion
https://blog.csdn.net/forever__1234/article/details/86645567