Nodes/comfyui_cv/CV Camera Pose To 3D View
ComfyUI Node

CV Camera Pose To 3D View

Adapts an OpenCV camera model to the LOAD3D_CAMERA dict the native 3D preview nodes take ('Preview 3D (Advanced)' / 'Preview Splat' / 'Preview Point Cloud' camera_info input), so a calibrated real camera drives the Three.js viewer camera. Feed the intrinsic matrix from 'Calibrate Camera (Chessboard)' or 'CV Load Camera Params (JSON)' and the extrinsics (rvec/tvec) from 'CV Solve PnP (Pose)': the viewer camera is placed at the physical camera's position relative to the board/object, looking down its optical axis. Coordinates are converted from OpenCV (right-handed, Y down, camera looks +Z) to Three.js (right-handed, Y up, camera looks -Z) by negating Y and Z. The orbit target is the point on the optical axis nearest orbit_anchor, so OrbitControls' lookAt reproduces the pose's viewing direction exactly (camera roll is lost - OrbitControls keeps +Y up). fov/aspect/quaternion are filled from the intrinsics per the LOAD3D_CAMERA spec, but the current frontend applies only position/target/zoom from a camera_info input - the viewer keeps its own FOV. Failure-tolerant: without rvec/tvec (or with the zero vectors Solve PnP emits on found=false) the camera falls back to a front view of orbit_anchor at 10*scale distance.

By bmad4ever·Created 3 months ago·Updated 2 days ago· 0
CV Camera Pose To 3D View
  • camera_matrix
  • rvec
  • tvec
  • orbit_anchor
  • dist_coeffs
  • camera_info
  • fov_y_deg
  • distance
image_width0
image_height0
scale1.00
Categoryimage/CV/low-level

Inputs (8)

NameTypeDefaultDescription
camera_matrixNPARRAY3x3 intrinsic matrix K ('Calibrate Camera', 'CV Load Camera Params' or 'CV Camera Matrix'). Sets the reported vertical FOV: fov_y = 2*atan(image_height / (2*fy)).
rvecoptNPARRAY3x1 Rodrigues rotation vector from 'CV Solve PnP (Pose)' (a 3x3 rotation matrix is also accepted). Leave unconnected for a frontal default view.
tvecoptNPARRAY3x1 translation vector from 'CV Solve PnP (Pose)'. Leave unconnected for a frontal default view.
orbit_anchoroptNPARRAY3D point (in the SAME object/world coordinates as the solve-PnP object points, e.g. the board centre from 'CV Points' [[4, 2.5, 0]]) that the orbit pivot should sit nearest to. The target is its projection onto the optical axis, so orbiting rotates around the observed object. Default: the object-space origin.
dist_coeffsoptNPARRAYLens distortion coefficients (k1, k2, p1, p2[, k3]) from 'Calibrate Camera' / 'CV Load Camera Params'. Rides along in the dict (_dist_coeffs) for viewers that can render distortion ('CV Preview 3D (Calibrated Camera)'); the core preview nodes ignore it.
image_widthoptINT00–100000Calibration image width in px, for the aspect ratio. 0 = estimate as 2*cx from the camera matrix.
image_heightoptINT00–100000Calibration image height in px, for the vertical FOV. 0 = estimate as 2*cy from the camera matrix.
scaleoptFLOAT1.000.000001–1000000Multiplier from object units (e.g. chessboard squares or mm) to 3D scene units, applied to the camera position and orbit target. Use it to size the camera distance to the previewed model.

Outputs (3)

NameTypeDescription
camera_infoLOAD3D_CAMERALOAD3D_CAMERA dict (position/target/zoom/cameraType + quaternion/fov/aspect/near/far) - wire into the camera_info input of 'Preview 3D (Advanced)', 'Preview Splat' or 'Preview Point Cloud'.
fov_y_degFLOATVertical field of view implied by the intrinsics, in degrees (2*atan(h/(2*fy))).
distanceFLOATCamera-to-target distance in scene units (after scale).