CMake編譯好OpenMVG然後運行tutorial_demo.py,報錯如下:
CleanGraph_KeepLargestBiEdge_Nodes():: => connected Component: 0
Invalid input image graph for global SfM
5. Colorize Structure
The input SfM_Data file "D:\OpenCV_SFM_Dependency\openMVG\build\software\SfM\tutorial_out\reconstruction_global/sfm_data.bin" cannot be read.
4. Structure from Known Poses (robust triangulation)
Compute Structure from the provided poses
The input SfM_Data file "D:\OpenCV_SFM_Dependency\openMVG\build\software\SfM\tutorial_out\reconstruction_global/sfm_data.bin" cannot be read.
問題是我們沒有設置相機焦距參數,需要修改一下tutorial_demo.py的這部分代碼:
修改前:
pIntrisics = subprocess.Popen( [os.path.join(OPENMVG_SFM_BIN, "openMVG_main_SfMInit_ImageListing"),
"-i", input_dir, "-o", matches_dir, "-d", camera_file_params, "-c", "3"] )
修改後:
pIntrisics = subprocess.Popen( [os.path.join(OPENMVG_SFM_BIN, "openMVG_main_SfMInit_ImageListing"), "-i", input_dir,\
"-o", matches_dir, "-d", camera_file_params, "-f", "1228.8"]);
注意這裏焦距f的設置github說明 f = max(Width, Height) * 1.2,也就是圖像寬高中的最大值乘以1.2,我的圖像寬高是1024*768,
所以1024 * 1.2 = 1228.8
更改之後,設置直接的重建圖片路徑,就可以生成sfm_data.bin,接下來就參考這篇文章繼續往下做吧https://blog.csdn.net/X_kh_2001/article/details/83690094