/usr/lib/python3/dist-packages/morse/middleware/yarp/video_camera.py is in python3-morse-simulator 1.4-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | import logging; logger = logging.getLogger("morse." + __name__)
from morse.middleware.yarp_datastream import YarpPort
import yarp
class YarpImagePublisher(YarpPort):
_type_name = "yarp::ImageRGBA"
def initialize(self):
YarpPort.initialize(self, yarp.BufferedPortImageRgba, False)
def default(self, ci):
# Wrap the data in a YARP image
img = self.port.prepare()
img.setQuantum(1)
# Get the image data from the camera instance
img_string = self.data['image']
img_x = self.component_instance.image_width
img_y = self.component_instance.image_height
# Check that an image exists:
if img_string is not None and img_string != '':
try:
data = img_string
img.setExternal(data, img_x, img_y)
except TypeError as detail:
logger.info("No image yet: %s" % detail)
# Write the image
self.port.write()
|