int D435_IR()
{
int width = 1280;
int height = 720;
int fps = 30;
rs2::config config;
config.enable_stream(RS2_STREAM_INFRARED, 1, width, height, RS2_FORMAT_Y8, fps);
config.enable_stream(RS2_STREAM_INFRARED, 2, width, height, RS2_FORMAT_Y8, fps);
// start pipeline
rs2::pipeline pipeline;
rs2::pipeline_profile pipeline_profile = pipeline.start(config);
while (1) // Application still alive?
{
// wait for frames and get frameset
rs2::frameset frameset = pipeline.wait_for_frames();
// get single infrared frame from frameset
//rs2::video_frame ir_frame = frameset.get_infrared_frame();
// get left and right infrared frames from frameset
rs2::video_frame ir_frame_left = frameset.get_infrared_frame(1);
rs2::video_frame ir_frame_right = frameset.get_infrared_frame(2);
cv::Mat dMat_left = cv::Mat(cv::Size(width, height), CV_8UC1, (void*)ir_frame_left.get_data());
cv::Mat dMat_right = cv::Mat(cv::Size(width, height), CV_8UC1, (void*)ir_frame_right.get_data());
cv::imshow("img_l", dMat_left);
cv::imshow("img_r", dMat_right);
char c = cv::waitKey(1);
if (c == 's')
{
}
else if (c == 'q')
break;
}
return EXIT_SUCCESS;
{
int width = 1280;
int height = 720;
int fps = 30;
rs2::config config;
config.enable_stream(RS2_STREAM_INFRARED, 1, width, height, RS2_FORMAT_Y8, fps);
config.enable_stream(RS2_STREAM_INFRARED, 2, width, height, RS2_FORMAT_Y8, fps);
// start pipeline
rs2::pipeline pipeline;
rs2::pipeline_profile pipeline_profile = pipeline.start(config);
while (1) // Application still alive?
{
// wait for frames and get frameset
rs2::frameset frameset = pipeline.wait_for_frames();
// get single infrared frame from frameset
//rs2::video_frame ir_frame = frameset.get_infrared_frame();
// get left and right infrared frames from frameset
rs2::video_frame ir_frame_left = frameset.get_infrared_frame(1);
rs2::video_frame ir_frame_right = frameset.get_infrared_frame(2);
cv::Mat dMat_left = cv::Mat(cv::Size(width, height), CV_8UC1, (void*)ir_frame_left.get_data());
cv::Mat dMat_right = cv::Mat(cv::Size(width, height), CV_8UC1, (void*)ir_frame_right.get_data());
cv::imshow("img_l", dMat_left);
cv::imshow("img_r", dMat_right);
char c = cv::waitKey(1);
if (c == 's')
{
}
else if (c == 'q')
break;
}
return EXIT_SUCCESS;
}
来源:https://github.com/IntelRealSense/librealsense/issues/1140#issue-295126900
https://github.com/IntelRealSense/librealsense/wiki/API-How-To#start-streaming-with-default-configuration