【问题标题】:How can I divide two cfg.enable_streams in D435 camera?如何在 D435 相机中划分两个 cfg.enable_streams?
【发布时间】:2018-04-17 05:13:44
【问题描述】:

我希望看到 IntelRealsence D435 摄像头的视频的两个部分。

一个是RGB in 640x480,另一个是IR(深度相机)在1280x720

以下代码出错,可能是cfg.enable_stream 不能除以大小。

我该如何划分它们? 这是我的代码:

#include <opencv2/opencv.hpp>
#include "example.hpp"

#include <stdio.h>

using namespace std;
using namespace cv;


int main()
{
    rs2::pipeline pipe;
rs2::config cfg;

//Add desired streams to configuration
cfg.enable_stream(RS2_STREAM_COLOR, RS2_FORMAT_BGR8, 30);
//for infrared
//cfg.enable_stream(RS2_STREAM_INFRARED, 1280, 720, RS2_FORMAT_Y8, 30);
cfg.enable_stream(RS2_STREAM_DEPTH, RS2_FORMAT_Z16, 30);

pipe.start(cfg);

texture depth_image;

rs2::align align_to(RS2_STREAM_DEPTH);

rs2::decimation_filter dec;

dec.set_option(RS2_OPTION_FILTER_MAGNITUDE, 2);

rs2::disparity_transform depth2disparity;

// Define spatial filter (edge-preserving)
rs2::spatial_filter spat;

spat.set_option(RS2_OPTION_HOLES_FILL, 5);
rs2::temporal_filter temp;

rs2::disparity_transform disparity2depth(false);

rs2::frame_queue postprocessed_frames;

CvSize size = cvSize(1280, 720);

for (;;)
{
    rs2::frameset frames = pipe.wait_for_frames();
    rs2::frame color_frame = frames.get_color_frame();

    rs2::colorizer color_map;
    rs2::frame depth_frame = color_map(frames.get_depth_frame());

我将运行这段代码来获取图片 垫颜色(尺寸(640, 480),CV_8UC3,(void*)color_frame.get_data(),垫::AUTO_STEP); const IplImage image_frame_show = new IplImage(color); namedWindow("显示颜色", WINDOW_AUTOSIZE); cvShowImage("显示颜色", image_frame_show); Mat depth_show(Size(1280, 720), CV_8UC3, (void)depth_frame.get_data(), Mat::AUTO_STEP); 常量 IplImage *depth_frame_show = new IplImage(depth_show); namedWindow("显示深度", WINDOW_AUTOSIZE); cvShowImage("显示深度", depth_frame_show);

    waitKey(10);

}

return 0;

}

【问题讨论】:

    标签: realsense


    【解决方案1】:

    流可以单独配置,请尝试下面的代码进行管道内的配置。

    rs2::pipeline pipe;
    rs2::config cfg;
    cfg.enable_stream(RS2_STREAM_COLOR, 640, 480, RS2_FORMAT_RGB8, 30);
    cfg.enable_stream(RS2_STREAM_DEPTH, 1280, 720, RS2_FORMAT_Z16, 30);
    pipe.start(cfg);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-06-10
      • 2015-06-12
      • 2016-06-29
      • 1970-01-01
      • 1970-01-01
      • 2016-10-31
      • 1970-01-01
      相关资源
      最近更新 更多