6 Replies Latest reply on Jul 13, 2018 1:47 PM by Leponzo

    Export rosbag content issues (frames drop or can't open with ROS API)

    baptiste-mnh

      Hi!

      Since de 2.12.0 release of the SDK, their is a tool (rs-convert) which can export the PNG images and the PLYs.

      But I got this issues : problems in rs_convert · Issue #1919 · IntelRealSense/librealsense · GitHub

      "Even with small bag files (~150MB), it drops frames. I was unable to extract all frames from a bag with 427 color and 430 depth frames. The number of frames dropped varies in each execution instance."

      So is there any way to get all the frames or may be another way (with ROS API) to get all of my images in my rosbag?

       

       

      I also tried some exemple based on ROS API but I often got this error when it try to open my rosbag file I got this error :

      [FATAL] [1529679163.359016032]: Character [ ] at element [32] is not valid in Graph Resource Name [/device_0/sensor_0/option/Enable Auto Exposure/value].  Valid characters are a-z, A-Z, 0-9, / and _.

       

      Thanks in advance for your help!

        • 1. Re: Export rosbag content issues (frames drop or can't open with ROS API)
          3DScanProduction

          No answer ? It looks to me like a bugg in the sdk. And it is a very blocking issue.

          • 2. Re: Export rosbag content issues (frames drop or can't open with ROS API)
            Intel Corporation
            This message was posted on behalf of Intel Corporation

            Hello bapriste-mnh,

            Thank you for your interest in the Intel RealSense Cameras.

            We will report this issue to the RealSense SDK team.
            We apologize for the inconvenience this may have caused.

            Thank you in advance,
            Eliza

            1 of 1 people found this helpful
            • 3. Re: Export rosbag content issues (frames drop or can't open with ROS API)
              Intel Corporation
              This message was posted on behalf of Intel Corporation

              Hello baptiste-mnh,

              The RealSense team is aware of this bug and is working on it.
              Unfortunately, we don't have a timeline yet for when it will be fixed. Please give us more details (how you created the ROS bag, which ROS example you are running, etc.) on how you got the second error when you tried to open the ROS bag so that we can reproduce your issue.

              Thank you,
              Eliza

              • 4. Re: Export rosbag content issues (frames drop or can't open with ROS API)
                baptiste-mnh

                Hi, I simply use the realsense viewer to create my rosbag and rs-convert to extract the content.

                I also tried to export with this code :

                import argparse
                
                import pyrealsense2 as rs
                import numpy as np
                import cv2
                import os
                
                
                LOAD_BAG = True
                SAVE_DEPTH = False
                SAVE_RGB = False
                SAVE_IRL = True
                SAVE_IRR = False
                
                
                def main():
                    if not os.path.exists(args.directory):
                        os.mkdir(args.directory)
                    if SAVE_DEPTH and not os.path.exists(args.directory+"/depth"):
                        os.mkdir(args.directory+"/depth")
                    if SAVE_RGB and not os.path.exists(args.directory+"/image"):
                        os.mkdir(args.directory+"/image")
                    if SAVE_IRL and not os.path.exists(args.directory+"/irl"):
                        os.mkdir(args.directory+"/irl")
                    if SAVE_IRR and not os.path.exists(args.directory+"/irr"):
                        os.mkdir(args.directory+"/irr")
                    try:
                        config = rs.config()
                        pipeline = rs.pipeline()
                        if LOAD_BAG:
                            rs.config.enable_device_from_file(config, args.input, False)
                        if SAVE_DEPTH:
                            config.enable_stream(rs.stream.depth, 1280, 720, rs.format.z16, 30)
                        if SAVE_RGB:
                            config.enable_stream(rs.stream.color, 1280, 720, rs.format.rgb8, 30)
                        if SAVE_IRL:
                            config.enable_stream(rs.stream.infrared, 1, 1280, 720, rs.format.y8, 30)
                        if SAVE_IRR:
                            config.enable_stream(rs.stream.infrared, 2, 1280, 720, rs.format.y8, 30)
                        pipeline.start(config)
                        i = 0
                        while True:
                            print("Saving frame:", i)
                            frames = pipeline.wait_for_frames()
                            if SAVE_DEPTH:
                                depth_frame = frames.get_depth_frame()
                                depth_image = np.asanyarray(depth_frame.get_data())
                                depth_image[np.where((depth_image > 3000))] = 0
                                cv2.imwrite(args.directory + "/depth/" + str(i).zfill(6) + ".png", depth_image)
                            if SAVE_RGB:
                                color_frame = frames.get_color_frame()
                                color_image = np.asanyarray(color_frame.get_data())
                                cv2.imwrite(args.directory + "/image/" + str(i).zfill(6) + ".png", color_image)
                            if SAVE_IRL:
                                irl_frame = frames.get_infrared_frame(1)
                                irl_image = np.asanyarray(irl_frame.get_data())
                                cv2.imwrite(args.directory + "/irl/" + str(i).zfill(6) + ".png", irl_image)
                            if SAVE_IRR:
                                irr_frame = frames.get_infrared_frame(2)
                                irr_image = np.asanyarray(irr_frame.get_data())
                                cv2.imwrite(args.directory + "/irr/" + str(i).zfill(6) + ".png", irr_image)
                            i += 1
                    except RuntimeError:
                        print("No more frames arrived, reached end of BAG file!")
                
                    finally:
                        pass
                
                
                if __name__ == "__main__":
                    parser = argparse.ArgumentParser()
                    parser.add_argument("-d", "--directory", type=str, help="Path to save the images")
                    parser.add_argument("-i", "--input", type=str, help="Bag file to read")
                    args = parser.parse_args()
                
                    main()
                
                • 5. Re: Export rosbag content issues (frames drop or can't open with ROS API)
                  Intel Corporation
                  This message was posted on behalf of Intel Corporation

                  Hello @baptiste-mnh,

                  I see that you have responded in this thread: https://github.com/IntelRealSense/librealsense/issues/1919. It is not clear whether you have resolved your issue. There is an open bug with the RealSense team where the rs-convert tool drops frames from ros bags.

                  Regards,
                  Jesus G.
                  Intel Customer Support