publish or subscribe depth image with python cv2
Hello everyone!
I don not know how to publish or subscribe depth image with cv2 module.
For example, if I want to publish depth image, I load a .png
depth image in the computer. and the codes are below.
depth_image = cv2.imread(os.path.join(self.path,depth_image_name))
d_image = np.array(depth_image)
send_depth = Image()
send_depth.encoding = '32FC1'
...
But when I use rqtimageview to check the published image, it cannot show the image and occurs warns
ImageView.callback_image() while trying to convert image from '32FC1' to 'rgb8' an exception was thrown (Image is wrongly formed: height * step != size or 480 * 2560 != 921600)
I add cv2.CV_LOAD_IMAGE_UNCHANGED
in cv2.imread()
, but the problem is still here.
And when I want to subscribe the depth image with python, which type should I set in
cvimage = self.bridge.imgmsg_to_cv2(data,"32FC1")
(here is 32FC1)
Thanks first!
Asked by wsAndy on 2017-02-17 05:06:15 UTC
Comments