Skip to content

Disable cursor-pixel readout in CameraDisplay#1748

Open
abaeyens wants to merge 1 commit into
ros2:rollingfrom
abaeyens:abaeyens/rolling/fix-camera-display-showing-wrong-pixel-values
Open

Disable cursor-pixel readout in CameraDisplay#1748
abaeyens wants to merge 1 commit into
ros2:rollingfrom
abaeyens:abaeyens/rolling/fix-camera-display-showing-wrong-pixel-values

Conversation

@abaeyens
Copy link
Copy Markdown
Contributor

Description

The pixel-value readout added in e6813d8 ("Show pixel co-ordinate with their pixel value in image", #1716) lives in ImageDisplay and maps cursor position to image pixel coordinates assuming the image fills the panel with plain aspect-preserving letterboxing. CameraDisplay inherits this mapping but lays out its background image rectangle differently — via calculateScreenCorners(), which scales the rectangle by the user-controlled "Zoom Factor", applies a FOV-derived (not pixel-derived) aspect ratio, and honors CameraInfo.roi. None of that is taken into account by the inherited mapping, so the reported pixel value is wrong whenever the zoom factor is not 1 (and slightly off in some other cases too).

Rather than duplicate or generalize the mapping for CameraDisplay, disable the readout there by no longer populating last_msg_ in CameraDisplay::processMessage(). With last_msg_ left unset, mapWidgetPosToImagePixel() short-circuits and the tooltip/status stay empty — silence is better than a plausible-looking but incorrect value. ImageDisplay itself is unaffected.

Fixes #1747

Is this user-facing behavior change?

Yes, this fixes a user-facing bug.

Did you use Generative AI?

Claude Opus 4.7

The pixel-value readout added in e6813d8 ("Show pixel co-ordinate
with their pixel value in image", ros2#1716) lives in ImageDisplay and
maps cursor position to image pixel coordinates assuming the image
fills the panel with plain aspect-preserving letterboxing.
CameraDisplay inherits this mapping but lays out its background
image rectangle differently — via calculateScreenCorners(), which
scales the rectangle by the user-controlled "Zoom Factor", applies a
FOV-derived (not pixel-derived) aspect ratio, and honors
CameraInfo.roi. None of that is taken into account by the inherited
mapping, so the reported pixel value is wrong whenever the zoom
factor is not 1 (and slightly off in some other cases too).

Rather than duplicate or generalize the mapping for CameraDisplay,
disable the readout there by no longer populating last_msg_ in
CameraDisplay::processMessage(). With last_msg_ left unset,
mapWidgetPosToImagePixel() short-circuits and the tooltip/status
stay empty — silence is better than a plausible-looking but
incorrect value. ImageDisplay itself is unaffected.

Fixes ros2#1747

Signed-off-by: Arne Baeyens <mail@arnebaeyens.com>
@abaeyens abaeyens marked this pull request as ready for review May 24, 2026 08:49
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.

CameraDisplay shows incorrect pixel values

1 participant