Generate stream from raw data
I want to generate rs::frame. Code as follows:
std::vector<uint8_t> pixels_color(color_frames.x * color_frames.y * color_frames.bpp, 0);
std::vector<uint8_t> pixels_depth(depth_frames.x * depth_frames.y * depth_frames.bpp, 0);
memcpy(pixels_color.data(), color_frame_data + frame_number * color_frames.x * color_frames.y * color_frames.bpp, color_frames.x * color_frames.y * color_frames.bpp);
color_frames.frame = std::move(pixels_color);
memcpy(pixels_depth.data(), depth_frame_data + frame_number * depth_frames.x * depth_frames.y, depth_frames.x * depth_frames.y * depth_frames.bpp);
depth_frames.frame = std::move(pixels_depth);
rs2_time_t timestamp = (rs2_time_t)frame_number * 16;
auto domain = RS2_TIMESTAMP_DOMAIN_HARDWARE_CLOCK;
depth_sensor.on_video_frame({ depth_frames.frame.data(), // Frame pixels from capture API
[](void*) {}, // Custom deleter (if required)
depth_frames.x * depth_frames.bpp, // Stride
depth_frames.bpp,
timestamp, domain, frame_number,
depth_stream, 0.001f }); // depth unit
color_sensor.on_video_frame({ color_frames.frame.data(), // Frame pixels from capture API
[](void*) {}, // Custom deleter (if required)
color_frames.x* color_frames.bpp, // Stride
color_frames.bpp,
timestamp, domain, frame_number,
color_stream });
++frame_number;
// Using the align object, we block the application until a frameset is available
rs2::frameset frameset = sync.wait_for_frames();
rs2::depth_frame test_depth = frameset.get_depth_frame();
rs2::video_frame test_color = frameset.get_color_frame();
But the output depth_frame named test_depth is null. I'm sure the input of on_video_frame :depth_frames is not null.
I get the depth_stream_profile and color_stream_profile from D455 and set them to depth_sensor/color_sensor.add_video_stream.
-
Hi 531934599,
Thanks for reaching out to us.
Are you using the latest version of Intel® RealSense™ SDK 2.0?
To configure the camera for streaming and rendering Depth & RGB data to the screen, you may refer to rs-capture Sample in Sample Code for Intel® RealSense™ cameras.
Regards,
Wan
Please sign in to leave a comment.
Comments
1 comment