librealsense icon indicating copy to clipboard operation
librealsense copied to clipboard

Cannot modify stream resolution with pipeline configuration

Open visez opened this issue 8 years ago • 12 comments

Required Info
Camera Model D400
Firmware Version 05.08.15.00
Operating System & Version MacOS
Kernel Version (Linux Only)
Platform Mac
SDK Version { 2.2.11 }

Issue Description

I am trying to set the rgb and depth resolution by passing a rs2::config object to the pipeline object. However, when I launch the program, I get the following error:

libc++abi.dylib: terminating with uncaught exception of type std::runtime_error: Frame format is not supported yet!

Here is the minimal code to reproduce the problem:

    //realsense configuration options
    rs2::colorizer color_map;
    rs2::config cfg;
    cfg.enable_stream(RS2_STREAM_COLOR, 640, 360);
    cfg.enable_stream(RS2_STREAM_DEPTH, 640, 360);
    
    rs2::pipeline pipe;
    pipe.start(cfg);
    cv::Size rgbSize, depthSize;
    
    const auto depthWindowName = "Depth";
    const auto rgbWindowName = "RGB";
    cv::namedWindow(depthWindowName, cv::WINDOW_AUTOSIZE);
    cv::namedWindow(rgbWindowName, cv::WINDOW_AUTOSIZE);
    
    while (cv::waitKey(1) < 0 && cvGetWindowHandle(depthWindowName) && cvGetWindowHandle(rgbWindowName))
    {
        //get frames and align
        rs2::frameset data = pipe.wait_for_frames();
        rs2::frame depth = data.get_depth_frame();
        rs2::frame rgb = data.get_color_frame();
        if (!depth)
            continue;
        
        //get opencv matrices
        cv::Mat depthMat = frame_to_mat(color_map(depth));
        cv::Mat rgbMat = frame_to_mat(rgb);
        
        // show images
        imshow(depthWindowName, depthMat);
        imshow(rgbWindowName, rgbMat);
    }

visez avatar May 10 '18 06:05 visez

Hi @visez You can most likely work around this problem by using the full overload of enable_stream with rest of the parameters. That said, this seems suspicious behavior and likely to be a bug, we will reproduce and update.

dorodnic avatar May 10 '18 08:05 dorodnic

@dorodnic thank you - just tried with the following code but I get the same problem unfortunately:

    rs2::config cfg;
    cfg.enable_stream(RS2_STREAM_COLOR, -1, 640, 360, rs2_format::RS2_FORMAT_ANY, 0);
    cfg.enable_stream(RS2_STREAM_DEPTH, -1, 640, 360, rs2_format::RS2_FORMAT_ANY, 0);

    rs2::pipeline pipe;
    pipe.start(cfg);

visez avatar May 10 '18 09:05 visez

@dorodnic Just checked the firmware version - 05.08.15.00. Could that be the reason? Are there any ways to update the firmware from macos?

visez avatar May 10 '18 09:05 visez

Could you please check using the Viewer if the camera is detected as USB3? I tried the original code locally and everything worked. I suspect the problem can be USB connection, or perhaps the firmware version. Unfortunately, we still don't have Mac OS firmware update tool (only for Windows and now also Ubuntu I believe)

dorodnic avatar May 10 '18 11:05 dorodnic

Updated the firmware to 5.9.9.2 from a windows PC, and the realsense is detected as usb3.0, the problem however still persists screen shot 2018-05-11 at 11 59 46

visez avatar May 11 '18 03:05 visez

Could you please make sure that you can manually select 640x360 from the RealSense Viewer?

dorodnic avatar May 13 '18 07:05 dorodnic

Silly mistake - by putting RS2_FORMAT_ANY in the call for the color stream it got automatically assigned to Y16 that gave an error when frame_to_mat() was called. Switching the code to the following solved the problem. Do however check the bug that requires to use the full overload of the function. Thank you

cfg.enable_stream(RS2_STREAM_COLOR, -1, 640, 360, rs2_format::RS2_FORMAT_RGB8, 0);

visez avatar May 15 '18 12:05 visez

I took a look into this, and it appears this is a side effect of the code we use to order the stream_profiles internally. When the stream, height, width, and fps are all the same, the code resorts to sorting based on the format. Since this is an enum, the order is rather arbitrary, resulting in Y16 being above RGB in the list. The pipeline/config setup then checks these sequentially, causing the Y16 profile to be selected before the RGB one can be checked

lramati avatar May 21 '18 15:05 lramati

[Realsense Customer Engineering Team Comment] hi @lramati, so your problem is solved?

You should ask @visez. It's their issue :)

lramati avatar May 25 '18 09:05 lramati

[Realsense Customer Engineering Team Comment] that's right, thanks @lramati.

hi @visez,

would like to confirm if your problem is solved? thanks.

Thank you, mark it as solved.

visez avatar May 29 '18 02:05 visez