| 1 |
"""Run Structure-from-Motion on 360-degree panorama images.""" |
| 2 |
|
| 3 |
import argparse |
| 4 |
from pathlib import Path |
| 5 |
|
| 6 |
from pycolmap.panorama import ( |
| 7 |
Mapper, |
| 8 |
Matcher, |
| 9 |
PanoramaReconstructionOptions, |
| 10 |
PanoRenderType, |
| 11 |
reconstruct, |
| 12 |
) |
| 13 |
|
| 14 |
|
| 15 |
def main() -> None: |
| 16 |
parser = argparse.ArgumentParser(description=__doc__) |
| 17 |
parser.add_argument("--input_image_path", type=Path, required=True) |
| 18 |
parser.add_argument("--output_path", type=Path, required=True) |
| 19 |
parser.add_argument( |
| 20 |
"--matcher", |
| 21 |
type=Matcher, |
| 22 |
default=Matcher.SEQUENTIAL, |
| 23 |
choices=list(Matcher), |
| 24 |
) |
| 25 |
parser.add_argument( |
| 26 |
"--mapper", |
| 27 |
type=Mapper, |
| 28 |
default=Mapper.INCREMENTAL, |
| 29 |
choices=list(Mapper), |
| 30 |
) |
| 31 |
parser.add_argument( |
| 32 |
"--pano_render_type", |
| 33 |
type=PanoRenderType, |
| 34 |
default=PanoRenderType.PERSPECTIVE_OVERLAPPING, |
| 35 |
choices=list(PanoRenderType), |
| 36 |
) |
| 37 |
parser.add_argument("--random_seed", type=int, default=0) |
| 38 |
parser.add_argument("--num_threads", type=int, default=-1) |
| 39 |
parser.add_argument("--gpu_index", default="-1") |
| 40 |
parser.add_argument("--use_gpu", default=True, action="store_true") |
| 41 |
parser.add_argument("--use_cpu", dest="use_gpu", action="store_false") |
| 42 |
args = parser.parse_args() |
| 43 |
|
| 44 |
reconstruct( |
| 45 |
args.input_image_path, |
| 46 |
args.output_path, |
| 47 |
PanoramaReconstructionOptions( |
| 48 |
matcher=args.matcher, |
| 49 |
mapper=args.mapper, |
| 50 |
render_type=args.pano_render_type, |
| 51 |
random_seed=args.random_seed, |
| 52 |
num_threads=args.num_threads, |
| 53 |
gpu_index=args.gpu_index, |
| 54 |
use_gpu=args.use_gpu, |
| 55 |
), |
| 56 |
) |
| 57 |
|
| 58 |
|
| 59 |
if __name__ == "__main__": |
| 60 |
main() |