赞
踩
#include <librealsense2/rs.hpp> // Include RealSense Cross Platform API #include "example.hpp" // Include short list of convenience functions for rendering #include <opencv2/opencv.hpp> int main(int argc, char * argv[]) { 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); rs2::device selected_device = pipeline_profile.get_device(); auto depth_sensor = selected_device.first<rs2::depth_sensor>(); if (depth_sensor.supports(RS2_OPTION_EMITTER_ENABLED)) { // depth_sensor.set_option(RS2_OPTION_EMITTER_ENABLED, 1.f); // Enable emitter depth_sensor.set_option(RS2_OPTION_EMITTER_ENABLED, 0.f); // Disable emitter } auto ir1_stream = pipeline_profile.get_stream(RS2_STREAM_INFRARED, 1); auto ir2_stream = pipeline_profile.get_stream(RS2_STREAM_INFRARED, 2); rs2_intrinsics intrinsics_1 = ir1_stream.as<rs2::video_stream_profile>().get_intrinsics(); rs2_intrinsics intrinsics_2 = ir2_stream.as<rs2::video_stream_profile>().get_intrinsics(); std::cout<<intrinsics_1.fx<<std::endl; rs2_extrinsics e = ir1_stream.get_extrinsics_to(ir2_stream); auto baseline = e.translation[0]; int count = 0; 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(30); cv::imwrite("/media/yqs/_dde_data/dataset/l/"+std::to_string(count)+".png",dMat_left); cv::imwrite("/media/yqs/_dde_data/dataset/r/"+std::to_string(count)+".png",dMat_right); count++; } return EXIT_SUCCESS; }
https://github.com/IntelRealSense/librealsense/wiki/API-How-To
https://github.com/IntelRealSense/librealsense/issues/1140
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。