Repository navigation
Conversation
This branch was successfully deployed
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.
I thought this is a nice feature to help positioning work-pieces, giving just a bit more camera view...
Hoping you agree ;-)
Note: by playing around with this, I see my own camera calibration is a bit difficult / off.
AI suggested a new future PR I might look at, which is choosing some different lens calibration models.
For example my machine might be better suited with a fish-eye, or one with 8 instead of 5 coefficients.
Here an image of the result:
And here the raw camera image for above result:
PR Commit Description
feat: optional camera view outside the workspace
After lens calibration and image alignment, the work surface only shows
the part of the camera image inside the workspace. The camera usually sees
more. This PR adds an optional, semi-transparent border of camera image
around the workspace to help position workpieces, while keeping the
workspace clearly distinguishable.
Highlights
Workspace": an on/off switch (default off), a margin (0–100 mm, default
30, shown in the user's length unit) and a transparency slider (0–1,
default 0.65; higher is more visible, like the existing camera
transparency). Persisted with the camera; old configurations load with
the feature off.
clipped to the area outside the workspace (even-odd clip), so the
centre is never painted twice. With the feature off, the existing
render path runs and no extra warp is done.
cv2.undistortkeeps theframe size, so barrel correction pushes the frame edges out of the
corrected image. With lens calibration, the border is sampled from the
raw frame instead: world → corrected image (existing homography) →
raw frame (lens model), via cached
cv2.remaptables. Without lenscalibration it uses the same perspective warp as the workspace. The
border is rendered at the camera's own pixel density (capped at 2048
px), so window resizes never rebuild the tables.
black; real black objects stay visible. Where the 5-coefficient lens
model folds back (very wide lenses), pixels are masked, so the border
never shows mirrored content. The margin is clamped at render time to
what the camera actually covers; the stored value is never changed.
CameraController.get_work_surface_images(), snapshots the processedand raw frame once under the frame lock. The existing
get_work_surface_image()keeps its signature and output, so stockdetection and other consumers are unaffected.
stale (new frame, settings change, element removed). A cached border is
only drawn while it matches the current alignment, workspace size and
margin, so it disappears immediately when disabled or invalidated.
Transparency changes apply at paint time.
(
outside_view_supported=True); the sketch editor is unchanged.Calibration data, alignment, machine dimensions and job bounds are
untouched.
Files
rayforge/camera/models/camera.py: three settings with validation(clamped; NaN/inf rejected), signals and persistence.
rayforge/camera/outside_view.py(new): border geometry, coverageextent, lens fold limit, raw-frame remap tables.
rayforge/camera/controller.py: paired single-frame render and caches.rayforge/ui_gtk/canvas2d/elements/camera_image.py: outside pass,clipping, cache keys and stale-job checks;
surface.pyopts in.rayforge/ui_gtk/camera/outside_view_widget.py(new) andcamera_preferences_page.py: settings group in the Camera tab.rayforge/locale/*: 8 new strings, appended to the template and allcatalogs (additions only).
tests/camera/test_camera.py,tests/camera/test_controller.py,tests/ui_gtk/canvas2d/test_camera_image.py,tests/ui_gtk/camera/test_outside_view_widget.py.How to review / test
Settings → Camera, enable "Show Outside Workspace".
border lines up with it at the workspace edge (no seam or offset).
Toggle off: the border disappears immediately.
between cameras: no stale border remains.
pixi run pytest tests/cameraandpixi run pytest -m ui tests/ui_gtk/camera tests/ui_gtk/canvas2d.Known limitations
the bed (gantry, walls) show parallax.
to a certain distance from the image centre; beyond it the border is
cut (seen as a rounded or clipped outline at large margins). A follow-up
for selectable lens models (rational, fisheye) is planned.
smoothed when noise reduction is enabled.
calibration or margin change builds remap tables (~120 ms on a
1440x1080 camera); later frames and window resizes reuse them (~3-7 ms
per update). The tables are freed when the feature is turned off.
🤖 Generated with Claude Code