Skip to content

Validate stereo fusion output path before running fusion - #4530

Open
behnamasadi wants to merge 1 commit into
colmap:mainfrom
behnamasadi:fix/3117-stereo-fusion-validate-output-path
Open

Validate stereo fusion output path before running fusion#4530
behnamasadi wants to merge 1 commit into
colmap:mainfrom
behnamasadi:fix/3117-stereo-fusion-validate-output-path

Conversation

@behnamasadi

@behnamasadi behnamasadi commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

RunStereoFuserImpl validated workspace_format, input_type and output_type up front, but never checked output_path until the results were written by WriteBinaryPlyPoints / Reconstruction::Write* after fusion completed. On large datasets fusion can run for hours, so a misspecified output_path (e.g. an existing directory when output_type is PLY, or a non-existent parent directory) aborted the whole run at the very end with a deferred THROW_CHECK_FILE_OPEN, discarding all the fusion work (issue #3117).

Add an early, output-type-aware validation of output_path in RunStereoFuserImpl before constructing the fuser:

  • PLY writes a single file, so reject an existing directory and require the parent directory to exist.
  • BIN/TXT write a directory of files, so require it to already exist (matching the THROW_CHECK_DIR_EXISTS in Reconstruction::Write*).

Also add a ply_test case asserting that WriteTextPlyPoints / WriteBinaryPlyPoints on a directory path fail cleanly, documenting the underlying deferred-failure behavior the early check guards against.

Fixes #3117

@behnamasadi
behnamasadi force-pushed the fix/3117-stereo-fusion-validate-output-path branch 3 times, most recently from 5043441 to c01e129 Compare July 17, 2026 09:00
@behnamasadi
behnamasadi force-pushed the fix/3117-stereo-fusion-validate-output-path branch from c01e129 to 71267bf Compare September 1, 2026 20:15
RunStereoFuserImpl validated workspace_format, input_type and output_type
up front, but never checked output_path until the results were written
after fusion completed. On large datasets fusion can run for hours, so a
misspecified output_path (an existing directory when output_type is PLY,
or a non-existent parent directory) aborted the whole run at the very end
with a deferred THROW_CHECK_FILE_OPEN, discarding all the fusion work.

Validate output_path alongside the other options before fusion starts,
and add a regression test covering the directory-as-output-path case.

Fixes colmap#3117

Claude-Session: https://claude.ai/code/session_01YPpmtwKEKPKSqYEG8uqKTL
@behnamasadi
behnamasadi force-pushed the fix/3117-stereo-fusion-validate-output-path branch from 71267bf to 4027812 Compare September 2, 2026 07:40
@behnamasadi

Copy link
Copy Markdown
Contributor Author

Flagging an overlap I should have caught earlier: #4519 by @alsolex predates this PR by about a week and fixes the same issue (#3117) with essentially the same up-front validation. Two open PRs for one bug is probably part of why neither has moved, so to make the choice easy:

I've just added the THROW_CHECK_HAS_FILE_EXTENSION(output_path, ".ply") check from #4519, which mine was missing. This branch is now a strict superset of #4519:

  • same up-front validation of output_path before fusion starts,
  • plus the .ply extension check from Handle directory output_path for stereo_fusion PLY output #4519,
  • plus a directory-vs-file distinction for the bin/txt output types,
  • plus a regression test in src/colmap/util/ply_test.cc covering the directory-as-output-path case,
  • plus error messages that name the offending option.

@alsolex — no ownership claim here, you got there first. I'm equally happy for #4519 to be merged and to send my test as a follow-up PR on top of it; whichever the maintainers prefer. @ahojnnes, either path closes #3117, so this just needs a pick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

stereo_fusion crash if folder is used as output_path, rather than creating a file inside the directory

1 participant