Skip to content

feat: add ICameraProjector.TryProjectToPixel (base-frame point → pixel)#10

Merged
DanielKow merged 1 commit into
masterfrom
feature/camera-project-to-pixel
May 29, 2026
Merged

feat: add ICameraProjector.TryProjectToPixel (base-frame point → pixel)#10
DanielKow merged 1 commit into
masterfrom
feature/camera-project-to-pixel

Conversation

@DanielKow
Copy link
Copy Markdown
Contributor

What

Adds bool TryProjectToPixel(Point3<double> basePoint, out Point<double> pixel) to ICameraProjector / CameraProjector — the inverse of the existing ProjectPoint (pixel → 3D).

public bool TryProjectToPixel(Point3d basePoint, out Pointd pixel)
{
    var cameraToBase = _getCurrentPosition() * _cameraToGripper;
    var pointInCamera = cameraToBase.Inverse().TransformPoint(basePoint);
    if (pointInCamera.Z <= 0) { pixel = default; return false; } // behind/on image plane
    pixel = _intrinsics.PointToPixel(pointInCamera);
    return true;
}

Why

Programs need to draw a known robot-base 3D point (e.g. a teaching point) onto the live camera overlay. The projector already held intrinsics + hand-eye + current pose privately, and CameraIntrinsics.PointToPixel (pinhole + Brown-Conrady) was public, but there was no public base→pixel entry point. This surfaces it without exposing intrinsics.

Returns false when the point is on or behind the image plane (camera-frame Z ≤ 0), where a pinhole projection would otherwise yield a misleading in-front pixel. Callers clip the returned pixel to their actual viewport bounds.

Tests

CameraProjectorTryProjectToPixelTests — 20 strict cases:

  • optical-axis point → principal point (exact)
  • off-axis points vs. hand-derived pinhole formula (exact, 1e-9)
  • on/behind image plane (Z = 0, -0.001, -500) → false + default pixel
  • un-project → re-project round trip, no distortion (1e-6) and with distortion (1e-3)
  • non-identity gripper pose + non-identity hand-eye vs. independently hand-computed ground truth
  • behind-camera under a non-identity pose chain → false
  • projection tracks the live gripper pose (camera moves +100mm X → pixel shifts left by exactly Fx·100/Z)

Full RocketWelder.SDK.Automation.Tests: 25/25 green.

🤖 Generated with Claude Code

@DanielKow DanielKow merged commit 9b05568 into master May 29, 2026
3 checks passed
@DanielKow DanielKow deleted the feature/camera-project-to-pixel branch May 29, 2026 08:29
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.

1 participant