From c1b61aad155e43541e234306718a6125272dfcaf Mon Sep 17 00:00:00 2001 From: bkerbl Date: Mon, 10 Jul 2023 17:58:17 +0200 Subject: [PATCH] Clearer conversion explanation --- README.md | 72 ++++++++++++++++++++++++++++++++++++++++++++---------- convert.py | 42 ++++++++++++++++--------------- 2 files changed, 81 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 29ec3ec..01e698d 100644 --- a/README.md +++ b/README.md @@ -320,16 +320,16 @@ The network viewer allows you to connect to a running training process on the sa
Primary Command Line Arguments for Network Viewer - ### --path / -s + #### --path / -s Argument to override model's path to source dataset. - ### --ip + #### --ip IP to use for connection to a running training script. - ### --port + #### --port Port to use for connection to a running training script. - ### --rendering-size + #### --rendering-size Takes two space separated numbers to define the resolution at which network rendering occurs, ```1200``` width by default. Note that to enforce an aspect that differs from the input images, you need ```--force-aspect-ratio``` too. - ### --load_images + #### --load_images Flag to load source dataset images to be displayed in the top view for each camera.

@@ -359,28 +359,74 @@ SIBR has many other functionalities, please see the [documentation](https://sibr
Primary Command Line Arguments for Real-Time Viewer - ### --model-path / -m + #### --model-path / -m Path to trained model. - ### --iteration + #### --iteration Specifies which of state to load if multiple are available. Defaults to latest available iteration. - ### --path / -s + #### --path / -s Argument to override model's path to source dataset. - ### --rendering-size + #### --rendering-size Takes two space separated numbers to define the resolution at which real-time rendering occurs, ```1200``` width by default. Note that to enforce an aspect that differs from the input images, you need ```--force-aspect-ratio``` too. - ### --load_images + #### --load_images Flag to load source dataset images to be displayed in the top view for each camera. - ### --device + #### --device Index of CUDA device to use for rasterization if multiple are available, ```0``` by default.

## Preprocessing your own Scenes -We provide a converter script ```convert.py```, which uses COLMAP to extract SfM information. Optionally, you can use ImageMagick to resize the undistorted images. This rescaling is similar to MipNeRF360, i.e., it creates images with 1/2, 1/4 and 1/8 the original resolution in corresponding folders. To use them, please first install a recent version of COLMAP (ideally CUDA-powered) and ImageMagick. Put the images you want to use in a directory ```/input```. If you have COLMAP and ImageMagick on your system path, you can simply run +Our rasterization requires a SIMPLE_PINHOLE or PINHOLE camera model for COLMAP data. We provide a converter script ```convert.py```, to extract undistorted images and SfM information. Optionally, you can use ImageMagick to resize the undistorted images. This rescaling is similar to MipNeRF360, i.e., it creates images with 1/2, 1/4 and 1/8 the original resolution in corresponding folders. To use them, please first install a recent version of COLMAP (ideally CUDA-powered) and ImageMagick. Put the images you want to use in a directory ```/input```. +``` + +|---input +| |--- +| |--- +| |---... +``` + If you have COLMAP and ImageMagick on your system path, you can simply run ```shell python convert.py -s [--resize] #If not resizing, ImageMagick is not needed ``` -Alternatively, you can use the optional parameters ```--colmap_executable``` and ```--magick_executable``` to point to the respective paths. Please note that on Windows, the executable should point to the COLMAP ```.bat``` file that takes care of setting the execution environment. Once done, `````` will contain the expected COLMAP data set structure with undistorted, differently sized input images, in addition to your original images and temporary data in the directory ```distorted```. +Alternatively, you can use the optional parameters ```--colmap_executable``` and ```--magick_executable``` to point to the respective paths. Please note that on Windows, the executable should point to the COLMAP ```.bat``` file that takes care of setting the execution environment. Once done, `````` will contain the expected COLMAP data set structure with undistorted, resized input images, in addition to your original images and some temporary (distorted) data in the directory ```distorted```. + +If you have your own COLMAP dataset without undistortion (e.g., using ```OPENCV``` camera), you can try to just run the last part of the script: Put the images in ```input``` and the COLMAP info in a subdirectory ```distorted```: +``` + +|---input +| |--- +| |--- +| |---... +|---distorted +| |---sparse +| | |---0 +| |---database.db +``` +Then run +```shell +python convert.py -s --skip_matching [--resize] #If not resizing, ImageMagick is not needed +``` + +
+Command Line Arguments for convert.py + + #### --no_gpu + Flag to avoid using GPU in COLMAP. + #### --skip_matching + Flag to indicate that COLMAP info is available for images. + #### --source_path / -s + Location of the inputs. + #### --camera + Which camera model to use for the early matching steps, ```OPENCV``` by default. + #### --resize + Flag for creating resized versions of input images. + #### --colmap_executable + Path to the COLMAP executable (```.bat``` on Windows). + #### --magick_executable + Path to the ImageMagick executable. +
+
+ ## FAQ - *Where do I get data sets, e.g., those referenced in ```full_eval.py```?* The MipNeRF360 data set is provided by the authors of the original paper on the project site. Note that two of the data sets cannot be openly shared and require you to consult the authors directly. For Tanks&Temples and Deep Blending, please use the download links provided at the top of the page. diff --git a/convert.py b/convert.py index 0f386a4..333f875 100644 --- a/convert.py +++ b/convert.py @@ -16,6 +16,7 @@ import shutil # This Python script is based on the shell converter script provided in the MipNerF 360 repository. parser = ArgumentParser("Colmap converter") parser.add_argument("--no_gpu", action='store_true') +parser.add_argument("--skip_matching", action='store_true') parser.add_argument("--source_path", "-s", required=True, type=str) parser.add_argument("--camera", default="OPENCV", type=str) parser.add_argument("--colmap_executable", default="", type=str) @@ -26,29 +27,30 @@ colmap_command = '"{}"'.format(args.colmap_executable) if len(args.colmap_execut magick_command = '"{}"'.format(args.magick_executable) if len(args.magick_executable) > 0 else "magick" use_gpu = 1 if not args.no_gpu else 0 -os.makedirs(args.source_path + "/distorted/sparse", exist_ok=True) +if not args.skip_matching: + os.makedirs(args.source_path + "/distorted/sparse", exist_ok=True) -## Feature extraction -os.system(colmap_command + " feature_extractor "\ - "--database_path " + args.source_path + "/distorted/database.db \ - --image_path " + args.source_path + "/input \ - --ImageReader.single_camera 1 \ - --ImageReader.camera_model " + args.camera + " \ - --SiftExtraction.use_gpu " + str(use_gpu)) + ## Feature extraction + os.system(colmap_command + " feature_extractor "\ + "--database_path " + args.source_path + "/distorted/database.db \ + --image_path " + args.source_path + "/input \ + --ImageReader.single_camera 1 \ + --ImageReader.camera_model " + args.camera + " \ + --SiftExtraction.use_gpu " + str(use_gpu)) -## Feature matching -os.system(colmap_command + " exhaustive_matcher \ - --database_path " + args.source_path + "/distorted/database.db \ - --SiftMatching.use_gpu " + str(use_gpu)) + ## Feature matching + os.system(colmap_command + " exhaustive_matcher \ + --database_path " + args.source_path + "/distorted/database.db \ + --SiftMatching.use_gpu " + str(use_gpu)) -### Bundle adjustment -# The default Mapper tolerance is unnecessarily large, -# decreasing it speeds up bundle adjustment steps. -os.system(colmap_command + " mapper \ - --database_path " + args.source_path + "/distorted/database.db \ - --image_path " + args.source_path + "/input \ - --output_path " + args.source_path + "/distorted/sparse \ - --Mapper.ba_global_function_tolerance=0.000001") + ### Bundle adjustment + # The default Mapper tolerance is unnecessarily large, + # decreasing it speeds up bundle adjustment steps. + os.system(colmap_command + " mapper \ + --database_path " + args.source_path + "/distorted/database.db \ + --image_path " + args.source_path + "/input \ + --output_path " + args.source_path + "/distorted/sparse \ + --Mapper.ba_global_function_tolerance=0.000001") ### Image undistortion ## We need to undistort our images into ideal pinhole intrinsics.