I wish to see two parts of a video by IntelRealsence D435 camera.
one is RGB in 640x480, another is IR(depth camera) in 1280x720.
the following code got error, maybe cfg.enable_stream can't be divided by size.
how can I divide them? Here is my code:
#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());
I will run this code to get picture Mat color(Size(640, 480), CV_8UC3, (void*)color_frame.get_data(), Mat::AUTO_STEP); const IplImage image_frame_show = new IplImage(color); namedWindow("Display color", WINDOW_AUTOSIZE); cvShowImage("Display color", image_frame_show); Mat depth_show(Size(1280, 720), CV_8UC3, (void)depth_frame.get_data(), Mat::AUTO_STEP); const IplImage *depth_frame_show = new IplImage(depth_show); namedWindow("Display depth", WINDOW_AUTOSIZE); cvShowImage("Display depth", depth_frame_show);
waitKey(10);
}
return 0;
}