7 import pyrealsense2
as rs
18 parser = argparse.ArgumentParser(description=
"Read recorded bag file and display depth stream in jet colormap.\ 19 Remember to change the stream fps and format to match the recorded.")
21 parser.add_argument(
"-i",
"--input", type=str, help=
"Path to the bag file")
23 args = parser.parse_args()
26 print(
"No input paramater have been given.")
27 print(
"For help type --help")
30 if os.path.splitext(args.input)[1] !=
".bag":
31 print(
"The given file is not of correct file format.")
32 print(
"Only .bag files are accepted")
36 pipeline = rs.pipeline()
42 rs.config.enable_device_from_file(config, args.input)
46 config.enable_stream(rs.stream.depth, rs.format.z16, 30)
49 pipeline.start(config)
52 cv2.namedWindow(
"Depth Stream", cv2.WINDOW_AUTOSIZE)
55 colorizer = rs.colorizer()
60 frames = pipeline.wait_for_frames()
63 depth_frame = frames.get_depth_frame()
66 depth_color_frame = colorizer.colorize(depth_frame)
69 depth_color_image = np.asanyarray(depth_color_frame.get_data())
72 cv2.imshow(
"Depth Stream", depth_color_image)
76 cv2.destroyAllWindows()
static std::string print(const transformation &tf)
static const textual_icon exit