Re: Can I use a bag taken using zed2i? (I used compression.)

Posted by beginner123 on
URL: http://official-rtab-map-forum.206.s1.nabble.com/Can-I-use-a-bag-taken-using-zed2i-I-used-compression-tp9395p9457.html

Sorry for my belated reply!!!
I can't solve it no matter what...
I decided not to use compressed images. So, /zed2i/zed_node/left/image_rect_color/compressed was decompressed and saved using the following code.


##################################################################################################



import rosbag
from sensor_msgs.msg import Image, CameraInfo

input_bag = '/home/minsoo/catkin_ws/src/open3d/scripts/output1.bag'
output_bag = '/home/minsoo/bagfiles/result1.bag'

with rosbag.Bag(output_bag, 'w') as outbag:
    for topic, msg, t in rosbag.Bag(input_bag).read_messages():
        if topic == '/zed2i/zed_node/left/image_rect_color/compressed':
            # Decompress the compressed image message
            from io import BytesIO
            from PIL import Image as PILImage
            import numpy as np
            import cv2

            pil_img = PILImage.open(BytesIO(msg.data))
            cv_img = np.array(pil_img)
            img = cv2.cvtColor(cv_img, cv2.COLOR_RGB2BGR)

            # Create an image message with the uncompressed image
            img_msg = Image()
            img_msg.header = msg.header
            img_msg.encoding = 'bgr8'
            img_msg.width = img.shape[1]
            img_msg.height = img.shape[0]
            img_msg.step = img.shape[1] * 3
            img_msg.data = img.tostring()

            # Write the uncompressed image and its corresponding camera info to the output bag file
            outbag.write('/zed2i/zed_node/left/image_rect_color', img_msg, t)
            outbag.write('/zed2i/zed_node/left/camera_info', msg.header, t)

        elif topic in ['/zed2i/zed_node/depth/depth_registered',
                       '/zed2i/zed_node/depth/camera_info',
                       '/zed2i/zed_node/imu/data'
                       '//tf_static']:
            # Write these topics as is to the output bag file
            outbag.write(topic, msg, t)


###########################################################################################


And when I ran the rtabmap command you said, I got the following result. I searched for this error and it says that I need to fix the tf tree, but I don't know what to do. I would appreciate it if you could let me know.











The picture below is the error content and hz. If possible, can you run my bag file directly? Sorry for asking too many questions. I will definitely do my best to become an advanced person. thank you