To send/receive image frames over ROS2, you need to use a resource known as CvBridge
First you need to import one of the standard message types for image data as follows:
from sensor_msgs.msg import Image
from cv_bridge import CvBridge
import cv2
#
From the perspective of the GUI, you need to first instantiate a CvBridge member variable within the init() function of GUI node. For each sensor, you will need subscriber that in also instantiate within the init() function. That could look something like this:
#
Then, you can then display the frame held within UV_img variable within to show the images as they come in to the GUI
To show the image, you will need to do something to the effect of what listed below. Do note that this implementation below creates a new window, which we don't necessarily want. Ideally this would be called in the same callback funciton listed above, and would only display within the windows specifically made for UV image frames:
cv2.show(img) # not sure exactly how to get this to display in a RQt window that's already open
To send/receive image frames over ROS2, you need to use a resource known as CvBridge
First you need to import one of the standard message types for image data as follows:
from sensor_msgs.msg import Image from cv_bridge import CvBridge import cv2
# From the perspective of the GUI, you need to first instantiate a CvBridge member variable within the init() function of GUI node. For each sensor, you will need subscriber that in also instantiate within the init() function. That could look something like this:
def init (): self.bridge = CvBridge() self.UV_sub = self.create_subscriber(Image, "UV_images", UV_image_callback)
# For the UV images you can use the following example within the callback function of your UV image topic to access the images from the ROS2 messages:
def UV_image_callback(self, data): UV_img = self.bridge(data, "bgr8")
# Then, you can then display the frame held within UV_img variable within to show the images as they come in to the GUI
To show the image, you will need to do something to the effect of what listed below. Do note that this implementation below creates a new window, which we don't necessarily want. Ideally this would be called in the same callback funciton listed above, and would only display within the windows specifically made for UV image frames:
cv2.show(img) # not sure exactly how to get this to display in a RQt window that's already open