# OpenMVG/OpenMVS User Manual
###### tags: `OpenMVG` `OpenMVS` `point clouds`
Create Date: August 31, 2022
Latest Update: August 31, 2022
Tags: OpenMVG, OpenMVS, Ubuntu
<aside>
⚠️ Make sure you’ve completed all the installation, both OpenMVG and OpenMVS.
If not, below’s link will lead you to the “Installation Guide” page.
[OpenMVG/OpenMVS Installation Guide](https://www.notion.so/OpenMVG-OpenMVS-Installation-Guide-56afeb47a61c4bb4902fcaa2fd73a2cd?pvs=21)
</aside>
### OpenMVG
openMVG 實現的功能是將二維圖像轉換為point cloud
### OpenMVS
openMVS 是將點雲upsampling成dense cloud稠密點雲,和重建surface(mesh網格)和textured(紋理映射)
# 前置作業
---
[OpenMVG on your image dataset · openMVG/openMVG Wiki](https://github.com/openMVG/openMVG/wiki/OpenMVG-on-your-image-dataset)
準備好照片檔案資料夾後,就可以run以下指令
```
cd openMVG_Build/software/SfM/
python SfM_GlobalPipeline.py [full path image directory] [resulting directory]
e.g. python SfM_GlobalPipeline.py /home/user/data/ImageDataset_SceauxCastle/images /home/user/data/ImageDataset_SceauxCastle/Castle_Incremental_Reconstruction
```
run完之後在[resulting directory]資料夾中可以找到”reconstruction_global的資料夾
裡面有各種最原始的點雲資料,如`cloud_and_poses.ply`
也可以找到OpenMVS需要的`sfm_data.bin`
[Usage · cdcseacave/openMVS Wiki](https://github.com/cdcseacave/openMVS/wiki/Usage)
要先run過,準備好檔案`sfm_data.bin`
```
openMVG_main_openMVG2openMVS -i sfm_data.bin -o scene.mvs -d scene_undistorted_images
```
要有`scene.mvs` & scene_undistorted_images(一個資料夾)才有辦法進行之後的動作
# 使用OpenMVS的Modules
---
[https://github.com/cdcseacave/openMVS/issues/338](https://github.com/cdcseacave/openMVS/issues/338)
所有的功能可以在/home/user/openMVS_build/bin資料夾裡面找到
建立一個新資料夾(e.g. dense_scene)
將`scene.mvs` & scene_undistorted_images複製進該資料夾
將要用的功能(資料夾bin中)也複製進該資料夾(e.g. DensifyPointCloud)
進入該資料夾後,開啟Terminal輸入
```
./{要使用的功能} scene.mvs
e.g. ./DensifyPointCloud scence.mvs
```
Output的資料中重要的是.mvs和.ply結尾的檔案
- .ply檔可以使用MeshLab開啟來查看output結果
- .mvs檔案可以再丟入其他優化功能進行優化
- .dmap是每一張照片的深度圖
- .glb檔 是以 GL 傳輸格式 (glTF) 保存的 3D 模型的二進製文件格式表示。有關 3D 模型的信息,例如二進制格式的節點層次結構、相機、材質、動畫和網格。
先後順序
| Order | Modules | Input | Output |
| --- | --- | --- | --- |
| 1 | Viewer | scene.mvs
(folder)scene_undistorted_images | n/a |
| 2 | DensifyPointCloud | scene.mvs
(folder)scene_undistorted_images | scene_dense.mvs
scene_dense.ply
depthXXXX.dmap |
| 3 | ReconstructMesh | scene_dense.mvs
(folder)scene_undistorted_images | scene_dense_mesh.mvs
scene_dense_mesh.ply |
| 4 | RefineMesh | scene_dense_mesh.mvs
(folder)scene_undistorted_images | scene_dense_mesh_refine.mvs
scene_dense_mesh_refine.ply |
| 5 | TextureMesh | scene_dense_mesh_refine.mvs
(folder)scene_undistorted_images | scene_dense_mesh_refine_texture.glb
scene_dense_mesh_refine_texture.mvs
scene_dense_mesh_refine_texture.png
|
<aside>
💡 Viewer 使用
Mouse Usage:
- hold left mouse button and drag to rotate
- hold middle mouse button and drag to move
- scroll wheel zooms the view
- left click to select/unselect faces and print their vertexes to stdout.
Keyboard Usage:
- *ESC* close window (but still need *ctrl-C* to kill program)
- *left arrow* move through POV from camera positions to left
- *right arrow* move through POV from camera positions to the right
- *c* hide/show camera positions
- *e* export to .ply file in current directory
- *r* reset view
- *w* toggle render as solid
</aside>
# Output Scene
---
### Viewer

### DensifyPointCloud

### ReconstructMesh

### RefineMesh
```jsx
./RefineMesh scene_dense_mesh.mvs --max-face-area 16
```

### TextureMesh
用viewer開啟scene_dense_mesh_refine_texture.mvs
橘色的地方表示單單只從目前輸入的照片的話,沒有辦法觀察到該地方,預設是橘色
