colmap / glomap

GLOMAP - Global Structured-from-Motion Revisited
BSD 3-Clause "New" or "Revised" License
1.5k stars 98 forks source link

Cube-shaped false results after Glomap processing #76

Open JohannesKrueger opened 3 months ago

JohannesKrueger commented 3 months ago

Hello, thank you very much for the excellent project. However, I am having problems processing with Glomap, when I map a certain dataset with the Glomap Mapper, I get an incorrect result (points3D, images). These are arranged one after the other in a square. As cameras I get:

image

`# Camera list with one line of data per camera:

CAMERA_ID, MODEL, WIDTH, HEIGHT, PARAMS[]

Number of cameras: 1

1 OPENCV 1440 1440 723.66942759451433 723.66942759451433 720 720 0 0 0 0`

Here is my current processing workflow. According to my assumptions, the error only occurs when the cameras are recognized as OPENCV. For other datasets with e.g. PINHOLE cameras it works perfectly without any bad results.

` os.makedirs(args.source_path + "/distorted/sparse", exist_ok=True)

## Feature extraction
feat_extracton_cmd = 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)
exit_code = os.system(feat_extracton_cmd)
if exit_code != 0:
    logging.error(f"Feature extraction failed with code {exit_code}. Exiting.")
    exit(exit_code)

## Feature matching
feat_matching_cmd = colmap_command + " exhaustive_matcher \
    --database_path " + args.source_path + "/distorted/database.db \
    --SiftMatching.use_gpu " + str(use_gpu)
exit_code = os.system(feat_matching_cmd)
if exit_code != 0:
    logging.error(f"Feature matching failed with code {exit_code}. Exiting.")
    exit(exit_code)

### Bundle adjustment using GLOMAP
# Replace the COLMAP mapper with GLOMAP mapper
mapper_cmd = (glomap_command + " mapper \
    --database_path " + args.source_path + "/distorted/database.db \
    --image_path "  + args.source_path + "/input \
    --output_path "  + args.source_path + "/distorted/sparse")
exit_code = os.system(mapper_cmd)
if exit_code != 0:
    logging.error(f"GLOMAP mapper failed with code {exit_code}. Exiting.")
    exit(exit_code)

Image undistortion

We need to undistort our images into ideal pinhole intrinsics.

img_undist_cmd = (colmap_command + " image_undistorter \ --image_path " + args.source_path + "/input \ --input_path " + args.source_path + "/distorted/sparse/0 \ --output_path " + args.source_path + "\ --output_type COLMAP") exit_code = os.system(img_undist_cmd) if exit_code != 0: logging.error(f"Image undistortion failed with code {exit_code}. Exiting.") exit(exit_code)`

Am I making a processing error? Or maybe I have an older version of COLMAP installed that doesn't yet support OPENCV?

Many thanks in advance

hnzhw commented 3 months ago

Same problem

https://github.com/colmap/glomap/issues/73 https://github.com/colmap/glomap/discussions/69

ichsan2895 commented 3 months ago

Somehow, I got mixed result. This case (south-building) gives good result, while this dataset was failed https://github.com/colmap/glomap/discussions/69

image Left = colmap 3.8 compiled with CUDA Right = glomap, commit 816e06fcc8beaac13255cc996131f64e543b11a5

Additional info:

MXLinux KDE 19.4
Ceres-solver 2.1.0 (manually build with CUDA 11.4)
Cmake 3.28.4

Here is command that I use.

mkdir distorted

colmap feature_extractor \
    --image_path    input/ \
    --database_path distorted/database.db \
    --ImageReader.single_camera_per_folder 1

colmap exhaustive_matcher \
    --database_path distorted/database.db 

mkdir distorted/colmap
mkdir distorted/glomap

colmap mapper --database_path distorted/database.db \
    --image_path input/ \
    --output_path distorted/colmap

glomap mapper --database_path distorted/database.db \
    --image_path input/ \
    --output_path distorted/glomap

colmap model_converter \
  --input_path distorted/colmap/0 \
  --output_path distorted/colmap/0 \
  --output_type TXT

colmap model_converter \
  --input_path distorted/glomap/0 \
  --output_path distorted/glomap/0 \
  --output_type TXT

colmap image_undistorter \
  --image_path input \
  --input_path distorted/colmap/0 \
  --output_path distorted/colmap

colmap image_undistorter \
  --image_path input \
  --input_path distorted/glomap/0 \
  --output_path distorted/glomap

colmap model_converter \
  --input_path distorted/colmap/sparse \
  --output_path distorted/colmap/sparse \
  --output_type TXT

colmap model_converter \
  --input_path distorted/glomap/sparse \
  --output_path distorted/glomap/sparse \
  --output_type TXT
ahojnnes commented 3 months ago

Would it be possible to share the database + images for debugging? Thanks.

JohannesKrueger commented 3 months ago

Yes, of course, here is the Google Drive link to the completely processed dataset including database, images, etc. The error described clearly occurs in this dataset. I also upload the console log.

Complete Dataset (database + images, etc.): https://drive.google.com/file/d/1LEYZBh9or4KUbYs5UnjYR1SUhM0zGd6p/view?usp=sharing Console Log: https://drive.google.com/file/d/1tGnHz1T8JfbPycR1yYNXCF-1Aydh61eE/view?usp=sharing

Thanks for the troubleshooting!

ichsan2895 commented 3 months ago

I have downloaded your dataset, but I don't know which one is better. image

Left = Colmap (version 3.11-dev0, commit 66fd8e56) Right = Glomap (version 1.0)

Command used:

mkdir distorted

colmap feature_extractor \
    --image_path    input/ \
    --database_path distorted/database.db \
    --ImageReader.single_camera_per_folder 1

colmap exhaustive_matcher \
    --database_path distorted/database.db 

mkdir distorted/colmap
mkdir distorted/glomap

colmap mapper --database_path distorted/database.db \
    --image_path input/ \
    --output_path distorted/colmap

glomap mapper --database_path distorted/database.db \
    --image_path input/ \
    --output_path distorted/glomap

colmap model_converter \
  --input_path distorted/colmap/1 \
  --output_path distorted/colmap/1 \
  --output_type TXT

colmap model_converter \
  --input_path distorted/glomap/0 \
  --output_path distorted/glomap/0 \
  --output_type TXT

colmap image_undistorter \
  --image_path input \
  --input_path distorted/colmap/1 \
  --output_path distorted/colmap

colmap image_undistorter \
  --image_path input \
  --input_path distorted/glomap/0 \
  --output_path distorted/glomap

colmap model_converter \
  --input_path distorted/colmap/sparse \
  --output_path distorted/colmap/sparse \
  --output_type TXT

colmap model_converter \
  --input_path distorted/glomap/sparse \
  --output_path distorted/glomap/sparse \
  --output_type TXT