Color video resolution change in saved bag file using pyrealsense2
-
Before opening a new issue, we wanted to provide you with some useful suggestions (Click "Preview" above for a better view):
- Consider checking out SDK examples.
- Have you looked in our documentations?
- Is you question a frequently asked one?
- Try searching our GitHub Issues (open and closed) for a similar issue.
-
All users are welcomed to report bugs, ask questions, suggest or request enhancements and generally feel free to open new issue, even if they haven't followed any of the suggestions above :)
| Required Info | |
|---|---|
| Camera Model | D400 |
| Firmware Version | 05.11.06.200 |
| Operating System & Version | Linux (Ubuntu 16 |
| Kernel Version (Linux Only) | 4.4.0-146 |
| Platform | PC |
| SDK Version | 2.21.0 |
| Language | python |
| Segment |
Issue Description
I'm running into a strange issue with the resolution of images recorded from a D435 camera using Pyrealsense2. I am recording both depth and color streams at the same resolution and saving them into bag files. However, when I open the saved bag files using the realsense viewer the resolution of the color stream is cut in half (320 x 240 instead of 640 x 480) whereas the depth stream is correct at 640 x 480. What is odd is that the information on the left hand panel for the RGB camera says it should be 640 x 480, but the output of the info button over the displayed video says 320 x 240:

Here is the code that is used for streaming and saving the data. The resolution variable is defined as:
resolution = {'x':640,'y':480}
I can provide any of the other default values if you think it's important.
def record_and_display_video(camera_pair, resolution, video_length,
fps, output_filename, recording_camera_laser):
"""
Inputs:
Camera pair - pair of cameras to use for recording/laser emitting
resolution - resolution of recorded video
video_length - length of video in seconds
start_time - time program initiated to be used for timestamp of video
fps - frames per second for the recorded video
filename - prefix to be used for saving bag file (date and time are appended)
record_camera_laser - whether or not to turn on the laser of the recording camera
Outputs:
Saves a bag file named filename_date_time
"""
#Get camera pair serial numbers
#camera_pair_SNs = get_camera_pair(camera_pair)
#Turn on emitting camera
pipeline_emit = rs.pipeline()
config_emit = rs.config()
config_emit.enable_device(SN_D415[camera_pair])
pipeline_emit.start(config_emit)
#Fire up recording camera
pipeline_record = rs.pipeline()
config_record = rs.config()
config_record.enable_device(SN_D435[camera_pair])
#Setup streaming and recording
config_record.enable_stream(rs.stream.depth, resolution['x'],
resolution['y'], rs.format.z16, fps)
config_record.enable_stream(rs.stream.color, resolution['x'],
resolution['y'], rs.format.bgr8, fps)
bag_filename = output_filename + ".bag"
config_record.enable_record_to_file(bag_filename)
#Turn on recording pipeline
pipeline_record_profile = pipeline_record.start(config_record)
#Turn off laser from recording camera
device_record = pipeline_record_profile.get_device()
if recording_camera_laser.lower() == 'n':
depth_sensor_record = device_record.query_sensors()[0]
depth_sensor_record.set_option(rs.option.emitter_enabled, 0)
elif recording_camera_laser.lower() == 'y':
depth_sensor_record = device_record.query_sensors()[0]
depth_sensor_record.set_option(rs.option.emitter_enabled, 1)
#Start recording!
try:
#For colorizing the depth frame
colorizer = rs.colorizer()
start=time.time()
while time.time() - start < int(video_length):
frames = pipeline_record.wait_for_frames()
#Get color and depth frames for display
color_frame = frames.get_color_frame()
depth_frame = frames.get_depth_frame()
color_frame = np.asanyarray(color_frame.get_data())
depth_frame = np.asanyarray(colorizer.colorize(depth_frame).get_data())
#Stack color and depth frames vertically for display
camera_images = np.vstack((color_frame, depth_frame))
#Display images
cv2.namedWindow('Camera ' + str(camera_pair), cv2.WINDOW_AUTOSIZE)
cv2.imshow('Camera ' + str(camera_pair), camera_images)
cv2.waitKey(5)
finally:
pipeline_record.stop()
pipeline_emit.stop()
cv2.destroyAllWindows()
return(bag_filename)
Any insight would be much appreciated!
Thanks!
@jkenney9a , you seem to have the RGB post-processing turned on in the viewer - verify that the decimation filter is switched off.
Thank you!