Как я могу разделить два cfg.enable_streams в камере D435?
Я хочу увидеть две части видео с камеры IntelRealsence D435.
один RGB
в 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());
Я буду запускать этот код, чтобы получить цвет изображения Mat (Размер (640, 480), CV_8UC3, (void *) color_frame.get_data (), Mat:: AUTO_STEP); const IplImage image_frame_show = новый IplImage (цвет); namedWindow ("Цвет дисплея", WINDOW_AUTOSIZE); cvShowImage ("Цвет дисплея", image_frame_show); Мат глубины_шоу (Размер (1280, 720), CV_8UC3, (void) deep_frame.get_data(), Mat::AUTO_STEP); const IplImage *deep_frame_show = новый IplImage (глубина_шоу); namedWindow("Глубина отображения", WINDOW_AUTOSIZE); cvShowImage("Отображать глубину", глубину_кадра_шоу);
waitKey(10);
}
return 0;
}
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);