ImageTransport

Seeing what the robot sees is one of the most important features of any user interface. To enable this, this library provides the ImageTransportSubscription. It allows easy subscription of camera messages and provides them in a QML native format as a VideoSource.

Example:

ImageTransportSubscription {
  id: imageSubscription
  // Enter a valid image topic here
  topic: "/front_rgbd_cam/color/image_rect_color"
  // This is the default transport, change if compressed is not available
  defaultTransport: "compressed"
}

VideoOutput {
  anchors.fill: parent
  // Can be used in increments of 90 to rotate the video
  orientation: 90
  source: imageSubscription
}

The ImageTransportSubscription can be used as the source of a VideoOutput to display the camera images as they are received. Additionally, it can be configured to show a blank image after x milliseconds using the timeout property which is set to 3000ms (3s) by default. This can be disabled by setting the timeout to 0.

The QML ROS2 plugin internally keeps track of all image transport subscriptions and will only create one shared subscription per topic to avoid unnecessary computation and bandwidth overhead.

API

class ImageTransportSubscription : public QObjectRos2

Properties

QAbstractVideoSurface * videoSurface

Interface for QML. This is the surface the images are passed to.

QString topic

The image base topic (without image_raw etc.). This value may change once the subscriber is connected and private topic names or remappings were evaluated.

QString defaultTransport

The default transport passed as transport hint. May be overridden by a parameter. (Default: compressed)

bool subscribed

Whether or not this ImageTransportSubscriber is subscribed to the given topic (readonly)

int networkLatency

The latency from the sender to the received time in ms not including the conversion latency before displaying. (readonly) This is computed based on the timestamp and relies on your system clock being synchronized with the camera host.

int processingLatency

The latency (in ms) from the reception of the image until it is in a displayable format. (readonly)

int latency

The full latency (in ms) from the camera to your display excluding drawing time. (readonly) This is computed based on the timestamp and relies on your system clock being synchronized with the camera host.

double framerate

The framerate of the received camera frames in frames per second. (readonly)

int timeout

The timeout when no image is received until a blank frame is served. Set to 0 to disable and always show last frame. Default is 3000 ms.

bool enabled

Whether the subscriber is active or not. Setting to false will shut down subscribers.

QString encoding

The encoding of the received image. (readonly)

bool hasAlpha

Whether the received image has an alpha channel. (readonly)

bool isColor

Whether the received image is a color image. (readonly)