您當前的位置:首頁 > 舞蹈

在伺服器上使用meshroom進行3D重建

作者:由 李霖燁 發表于 舞蹈時間:2019-09-15

本文將介紹如何在有Nvidia GPU的伺服器上使用meshroom進行3D重建,伺服器沒有GUI介面,但可以使用命令列。本教程不需要你有伺服器的root許可權。

參考教程

原教程中的一些檔案需要科學上網才能看到,並且不靈活

環境搭建

你需要一臺有Nvidia顯示卡的伺服器,並且已經配置好了CUDA,一般用於

深度學習

的伺服器即可。

在伺服器上使用meshroom進行3D重建

一、下載meshroom

wget -N https://github。com/alicevision/meshroom/releases/download/v2019。1。0/Meshroom-2019。1。0-linux。tar。gz

tar xzfv Meshroom-2019。1。0-linux。tar。gz

二、下載meshroom提供的圖片

先用官方示例中的圖片進行測試,如果重建成功了說明環境搭建成功了,我已經把圖片準備好了,你們可以從百度網盤進行下載,有三個資料夾,可以先選mini3裡面的圖片進行測試。

三、執行指令碼進行重建

import

os

import

argparse

parser

=

argparse

ArgumentParser

description

=

‘Meshroom command line script’

parser

add_argument

‘——project’

default

=

‘project。mg’

type

=

str

help

=

‘project name’

parser

add_argument

‘——input’

default

=

‘input’

type

=

str

help

=

‘directory contains all rgb images’

parser

add_argument

‘——output’

default

=

‘output’

type

=

str

help

=

‘directory to save output obj file,mtl file ’

‘and texture file’

args

=

parser

parse_args

()

if

not

os

path

exists

args

project

):

if

not

os

path

exists

args

output

):

os

makedirs

args

output

os

system

“/home/lilinye/reconstruct/Meshroom-2019。1。0/meshroom_photogrammetry ”

f

“——input

{args。input}

——output

{args。output}

——save

{args。project}

os

system

f

“/home/lilinye/reconstruct/Meshroom-2019。1。0/meshroom_compute

{args。project}

——toNode Publish_1 ——forceStatus”

新建一個script。py檔案,將上面的程式碼複製進行,程式碼中的一些需要注意的地方:

/home/lilinye/reconstruct/Meshroom-2019。1。0/ 需要更改為你自己伺服器上Meshroom的路徑

input引數為你需要重建的圖片的目錄

output引數為重建結束後儲存obj檔案、

mtl檔案

和紋理圖片的路徑

在終端輸入下面命令來執行,如果你的伺服器上有多個GPU,請使用CUDA_VISIBLE

_

DEVICES來設定還有視訊記憶體的那個GPU來計算深度。

python script。py ——input=mini3 ——output=output ——project=project。mg

重建的時間根據伺服器的效能而決定,在我使用的Tesla V100 16G視訊記憶體、Intel(R) Xeon(R) Gold 6148 CPU @ 2。40GHz 40核CPU的伺服器上,mini3的重建耗時10分鐘左右,full的重建估計要一天多

在伺服器上使用meshroom進行3D重建

四、將重建結果下載回本地進行檢視

在伺服器上使用meshroom進行3D重建

重建結果一共有三個檔案,用meshlab開啟texturedMesh。obj來檢視重建結果

在伺服器上使用meshroom進行3D重建

標簽: output  args  Project  伺服器  Meshroom