luxonis / depthai

DepthAI Python API utilities, examples, and tutorials.
https://docs.luxonis.com
MIT License
938 stars 232 forks source link

Fatal error. Log: 'OsDrvOV9282' '1320' when trying to use color + rgb with THE_1200_P resolution #1193

Open cesarpgouveia opened 3 months ago

cesarpgouveia commented 3 months ago

Hi,

I'm relatively new to the DepthAI OAK-D camera, so I developed a simple C++ script that opens both RGB and depth streams and displays them on the screen using OpenCV. You can see the code below.

The issue I'm encountering is that when I try to open both depth and color streams with THE_1200_P resolution for both, I receive the following error message:

[1944301041DF982E00] [1.13] [0.871] [system] [critical] Fatal error. Please report to developers. Log: 'OsDrvOV9282' '1320'

However, if I use other resolutions (such as THE_720_P for both), the program works fine. Can you help me with this?

Thanks, César

Code:

#include <iostream>

// Includes common necessary includes for development using depthai library
#include "depthai/depthai.hpp"

// Closer-in minimum depth, disparity range is doubled (from 95 to 190):
static std::atomic<bool> extended_disparity{ false };
// Better accuracy for longer distance, fractional disparity 32-levels:
static std::atomic<bool> subpixel{ false };
// Better handling for occlusions:
static std::atomic<bool> lr_check{ true };

// Custom parameters:
// Color camera sensor resolution
auto colorCameraResolution = dai::ColorCameraProperties::SensorResolution::THE_1200_P;
// Color camera color order
auto colorCameraColorOrder = dai::ColorCameraProperties::ColorOrder::BGR;
// Depth camera sensor resolution
auto depthCameraResolution = dai::MonoCameraProperties::SensorResolution::THE_1200_P;
// Depth stereo preset mode
auto depthPresetMode = dai::node::StereoDepth::PresetMode::HIGH_ACCURACY;

int main() {
    // Create pipeline
    dai::Pipeline pipeline;

    // Define sources and outputs

    // Initialize color camera
    auto camRgb = pipeline.create<dai::node::ColorCamera>();
    // Initialize depth camera
    auto monoLeft = pipeline.create<dai::node::MonoCamera>();
    auto monoRight = pipeline.create<dai::node::MonoCamera>();
    auto depth = pipeline.create<dai::node::StereoDepth>();
    // Set two xout for two streams (color and depth)
    auto xoutColor = pipeline.create<dai::node::XLinkOut>();
    auto xoutDepth = pipeline.create<dai::node::XLinkOut>();
    xoutColor->setStreamName("color");
    xoutDepth->setStreamName("depth");

    // Set color camera properties
    camRgb->setPreviewSize(300, 300);
    camRgb->setBoardSocket(dai::CameraBoardSocket::CAM_A);
    camRgb->setResolution(colorCameraResolution);
    camRgb->setInterleaved(true);
    camRgb->setColorOrder(colorCameraColorOrder);

    // Set depth camera properties
    monoLeft->setResolution(depthCameraResolution);
    monoLeft->setCamera("left");
    monoRight->setResolution(depthCameraResolution);
    monoRight->setCamera("right");

    std::cout << camRgb->getResolutionHeight() << std::endl;
    std::cout << camRgb->getResolutionWidth() << std::endl;

    // Create a node that will produce the depth map (using disparity output as it's easier to visualize depth this way)
    depth->setDefaultProfilePreset(depthPresetMode);
    // Options: MEDIAN_OFF, KERNEL_3x3, KERNEL_5x5, KERNEL_7x7 (default)
    depth->initialConfig.setMedianFilter(dai::MedianFilter::KERNEL_7x7);
    depth->setLeftRightCheck(lr_check);
    depth->setExtendedDisparity(extended_disparity);
    depth->setSubpixel(subpixel);

    // Linking Color
    camRgb->video.link(xoutColor->input);
    // Linking Depth
    monoLeft->out.link(depth->left);
    monoRight->out.link(depth->right);
    depth->disparity.link(xoutDepth->input);

    // Connect to device and start pipeline
    dai::Device device(pipeline);

    // Output queue color
    auto qColor = device.getOutputQueue("color");
    // Output queue depth will be used to get the disparity frames from the outputs defined above, in this case no queue is used
    auto qDepth = device.getOutputQueue("depth");

    while (true) {
        // Get color frame
        std::shared_ptr<dai::ImgFrame> inColor = qColor->get<dai::ImgFrame>();
        std::shared_ptr<dai::ImgFrame> inDepth = qDepth->get<dai::ImgFrame>();
        cv::Mat colorFrame = inColor->getCvFrame();
        cv::Mat depthFrame = inDepth->getFrame();

        std::cout << "output image height: " << colorFrame.rows << std::endl;
        std::cout << "output image width: " << colorFrame.cols << std::endl;
        std::cout << "camRgb height: " << camRgb->getResolutionHeight() << std::endl;
        std::cout << "camRgb width: " << camRgb->getResolutionWidth() << std::endl;

        // Normalization for better visualization
        depthFrame.convertTo(depthFrame, CV_8UC1, 255 / depth->initialConfig.getMaxDisparity());

        // Display images
        cv::imshow("ColorFrame", colorFrame);
        // Available color maps: https://docs.opencv.org/3.4/d3/d50/group__imgproc__colormap.html
        cv::applyColorMap(depthFrame, depthFrame, cv::COLORMAP_JET);
        cv::imshow("DepthFrame", depthFrame);

        int key = cv::waitKey(1);
        if (key == 'q' || key == 'Q') {
            return 0;
        }
    }
    return 0;
}
cesarpgouveia commented 3 months ago

It seems this issue is explained here: https://discuss.luxonis.com/d/3548-fatal-error-with-1200-p-resolution/2

However, I'm now encountering a new error using THE_720_P for both color and depth:

[1944301041DF982E00] [1.13] [0.788] [ColorCamera(0)] [warning] Unsupported resolution set for detected camera IMX378/214, needs 1080_P / 4_K / 12_MP. Defaulting to 1080_P

I really need to use the same resolution for both streams (depth and color).

themarpe commented 3 months ago

CC @jakaskerl

@cesarpgouveia you may use IspScaling to downscale center camera to 720p, same as left/right & depth (+ setDepthAlign to then be able to do RGBD. Example can be found here: examples\StereoDepth\rgb_depth_aligned.py

cesarpgouveia commented 3 months ago

Hey @themarpe thanks for the response!

Do you have an example in C++? I am unable to access certain methods, such as camRgb.setMeshSource(dai.CameraProperties.WarpMeshSource.CALIBRATION) or camRgb.setCalibrationAlpha(alpha)

Thanks, César.

themarpe commented 3 months ago

@cesarpgouveia make sure you are using the latest DepthAI - also that same example should be present under cpp examples

cesarpgouveia commented 3 months ago

I'm using DepthAI version 2.24.0, which is from Dec 14, 2023. Have so many changes been made in such a short time, especially to such essential functions?

On the Depth-AI core, we have this example: depth_align.cpp. It appears to have many differences compared to the Python version. Is this the one I should use as a reference?

jakaskerl commented 3 months ago

Hi @cesarpgouveia Yes, the changes have been made especially to the Camera node. I'd suggest you use the develop branch of depthai-core with this script.

Here is the same one as for Python.