Add pinhole camera projection to reorder texture#11
Open
csparker247 wants to merge 7 commits into
Open
Conversation
Add a camera projection model to ReorderUnorganizedTexture alongside the existing orthographic "snapshot from above" sampling. ProjectionMode::Camera casts perspective rays from a pinhole camera center; the camera is either supplied explicitly (intrinsics + world-to-camera pose) or auto-derived to frame the mesh along its shortest OBB axis. Camera mode is exposed through the standard render graph: ReorderTextureNode gains projectionMode/projectionParams input ports (serialized for caching), so no separate computation path is needed. The rt_reorder_texture app parses the new --projection and --camera-file options and wires them onto the node; the camera-file parser lives in a dedicated ParseCameraFile() helper. Also adds a per-pixel 3D position map output (CV_32FC3) and documents the depth-map semantics for both projection modes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Branch the reorder-texture output node on the requested extension: an OBJ writes the textured mesh (MeshWriteNode); an image extension (jpg, png, tif) writes just the reordered texture via WriteImageNode. Restores the standalone-image output that the camera-projection path previously offered, now unified through the render graph for both projection modes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The output can now be a mesh or a standalone texture image, so the mesh-specific option name is misleading. Keeps the -o short flag. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
setProjectionParams() no longer forces ProjectionMode::Camera; it only stores the explicit camera. Callers set the mode explicitly via setProjectionMode(). Add clearProjectionParams() to drop an explicit camera and revert to auto-derivation. This removes the side effect that made ReorderTextureNode's cache (de)serialization fragile: deserialize now restores explicit params before the mode (so the serialized mode is authoritative) and clears stale params when none were cached. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add rt::ValidateProjectionParams(), which rejects non-positive/non-finite focal lengths and image sizes, non-finite principal points, and extrinsics whose rotation block is not a proper rotation (orthonormal + det == +1). create_texture_camera_() now validates the resolved camera (explicit or auto-derived) and throws on failure, replacing the size-only guard and covering the degenerate auto-camera case. ParseCameraFile() validates user camera files up front for a clean CLI error. Adds a GoogleTest covering the accept/reject cases. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Extract the per-hit UV->color sampling shared by the orthographic and camera paths into sample_surface_color_(). Each loop now hoists a single inputTexture_.empty() check and only samples color when a texture is present, so camera mode (and the orthographic path) no longer call getRectSubPix on an empty image; depth/position maps are still produced. Also document that CreateProjectiveUVMap does no near-plane clipping, so camera-straddling triangles map incorrectly. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Warn when --camera-file is supplied without --projection camera (instead of silently ignoring it), and note the dependency in the option help. Also note in --depth-map/--position-map help that their float output wants a float-capable format such as .tif. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Member
Author
|
Addressed the review findings in four focused commits:
On the float-map finding: Full build is clean and all 4 tests pass. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a pinhole camera projection model to
ReorderUnorganizedTexture, alongside the existing orthographic ("snapshot from above") sampling. Instead of casting parallel rays along the mesh's shortest axis,ProjectionMode::Cameracasts perspective rays from a camera center, rendering the textured mesh as if photographed through a pinhole camera.The camera is either:
--camera-file(intrinsicsfx/fy/cx/cy, outputwidth/height, and a world-to-camerapose), orPipeline integration
Camera mode runs through the standard render graph rather than a separate code path.
ReorderTextureNodegains two input ports:projectionMode→setProjectionMode()projectionParams→setProjectionParams()Both are serialized into the node cache (
NLOHMANN_JSON_SERIALIZE_ENUMfor the mode;to_json/from_jsonfor the params struct, with the 4x4 pose flattened to 16 doubles). Thert_reorder_textureapp parses the new options and wires them onto the node; the camera-file parsing lives in a dedicatedstatic ParseCameraFile()helper that returnsstd::optional<ProjectionParams>.Output handling
The output node branches on the requested file extension (works for both projection modes):
MeshWriteNode)jpg/jpeg/png/tif/tiff) → writes just the reordered texture (WriteImageNode)The
-ooption is renamed--output-mesh→--output-fileto reflect that it now accepts either.Additional outputs
CV_32FC3) output /--position-mapoption and node port. Camera-mode positions are in the mesh's world frame; orthographic positions are in the realigned sampling frame. Pixels with no intersection are NaN.Other
TextureDewarp: switch the dewarp sampling toOutputWidthat 8192 px for higher-resolution output.Notes
create_texture_camera_()is exercised through the node rather than an end-to-end render test.🤖 Generated with Claude Code