Work in progress: this documentation is still being written and reviewed. Check details against the source code.

Camera display

Display camera images and marker detections in the operator GUI.

mtc_gui.camera_panel · Source

Operator GUI · Guide · Symbol index

How it is used

Create CameraPanel with the window’s ROS2Bridge. The constructor connects image and detection signals to GUI-thread callbacks and routes its Capture and Detect Markers buttons to the bridge’s services. Those buttons request camera work; the panel does not perform detection itself.

on_image() displays BGR images. on_detection() draws marker outlines on a copy of the latest image and lists detected positions in metres. These are separate incoming signals, so the overlay uses the panel’s current image rather than matching a capture identifier.

Start here

Callable

Purpose

CameraPanel.__init__

Build capture/detection controls, an image viewport, and read-only detection text, then connect bridge signals.

CameraPanel.on_image

Cache a newly received BGR image, display it, and mark the feed as received.

CameraPanel.on_detection

Cache marker results, draw four-corner outlines and ID labels on the latest image, and list marker positions.

CameraPanel

A Qt widget that owns the camera viewport and detection text. It receives data from ROS2Bridge and forwards button requests to that bridge.

Inherits from: QWidget.

CameraPanel.__init__()

Build capture/detection controls, an image viewport, and read-only detection text, then connect bridge signals.

Lifecycle · Source

__init__(self, ros2_bridge, parent=None)

Parameter

Meaning

ros2_bridge

Bridge providing trigger_capture, trigger_marker_detection, image_received, and detection_received.

parent

Optional QWidget parent.

Errors: Qt construction/signal-connection errors propagate.

Side effects: Creates widgets, initializes image/detection caches, and wires button and bridge signals; does not itself capture an image.

Referenced in source (1)

CameraPanel.on_image()

Cache a newly received BGR image, display it, and mark the feed as received.

Callback · Source

on_image(self, cv_image)

Parameter

Meaning

cv_image

OpenCV/numpy image with shape (height, width, channels), expected to contain three-channel BGR pixels.

Returns: None.

Errors: Image-conversion and Qt errors propagate.

Side effects: Replaces current_image, renders its pixmap, and updates status text and success styling.

Referenced in source (1)

CameraPanel.on_detection()

Cache marker results, draw four-corner outlines and ID labels on the latest image, and list marker positions.

Callback · Source

on_detection(self, markers)

Parameter

Meaning

markers

List of marker objects exposing id, corners_in_pixel_coordinates (points with x/y), and pose.position.x/y/z in metres.

Returns: None.

Errors: Empty lists show a no-markers warning and return. Non-four-corner markers skip only the overlay; malformed attributes or drawing errors propagate.

Side effects: Updates current_detections, status, and detection text; overlays a copy of current_image without modifying the stored original.

Referenced in source (1)

Internal callbacks and helpers

CameraPanel._display_image()

Convert a BGR array to RGB888 and install a smoothly scaled, aspect-preserving QPixmap.

Internal helper · Source

_display_image(self, cv_image)

Parameter

Meaning

cv_image

Three-dimensional BGR numpy array; its channel count supplies QImage bytes-per-line.

Returns: None.

Errors: Invalid image shapes/formats, OpenCV conversion errors, and Qt failures propagate.

Side effects: Replaces the image label’s pixmap; no image data is saved.

Referenced in source (2)