Code Monkey home page Code Monkey logo

Comments (3)

zhonghong322 avatar zhonghong322 commented on September 27, 2024

I'm having problems when performing Color to Depth and Depth to Color transformations using new align filter added in 1.10.5 release. It looks like it doesn't take into account lens distortion. However, when using CoordinateTransformHelper::transformationDepthFrameToColorCamera, the result of the transformation is correct. The thing is that I would like to be able to transform images captured from both geometries and CoordinateTransformHelper only supports D2C. Is there a way to perform a C2D transformation without getting weird distoritons or is it intended to be added in the future?

This is how I'm using align filter:

std::shared_ptr<ob::Align> align = std::make_shared<ob::Align>(OB_STREAM_DEPTH);
// Wait up to 100ms for a frameset
auto frameset = pipeline->waitForFrames(100);
// Check if a fameset has been grabbed and if it has color and depth frames in it
if (frameset != nullptr && frameset->colorFrame() != nullptr && frameset->depthFrame() != nullptr) {
    std::shared_ptr<ob::Frame> alignedFrame;
    try {
        alignedFrame = align->process(frameset);
    }
    catch (ob::Error& e) {
        // Handle the exception
    }
    auto alignedFrameSet = alignedFrame->as<ob::FrameSet>();
    auto colorFrame = alignedFrameSet->colorFrame();
    auto depthFrame = alignedFrameSet->depthFrame();

    // Check if there are color and depth frames inside the frameset grabbed
    if (colorFrame != nullptr && depthFrame != nullptr) {

        // Save color and depth data into a CameraFrame
        std::shared_ptr<CameraFrame> frame = std::make_shared<CameraFrame>();

        cv::Mat colorMat(colorFrame->height(), colorFrame->width(), CV_8UC4, colorFrame->data(), cv::Mat::AUTO_STEP);
        cv::cvtColor(colorMat, frame->color, cv::COLOR_BGRA2RGBA);
        cv::imwrite("ColorImage", colorMat);

        cv::Mat depthMat(depthFrame->height(), depthFrame->width(), CV_16U, depthFrame->data(), cv::Mat::AUTO_STEP);
        cv::imwrite("DepthImage", depthMat);
    }
}

This is how im using CoordinateTransformHelper:

// Wait up to 100ms for a frameset
auto frameset = pipeline->waitForFrames(100);
// Check if a fameset has been grabbed and if it has color and depth frames in it
if (frameset != nullptr && frameset->colorFrame() != nullptr && frameset->depthFrame() != nullptr) {

    auto colorFrame = frameset->colorFrame();
    auto depthFrame = frameset->depthFrame();


    // Check if there are color and depth frames inside the frameset grabbed
    if (colorFrame != nullptr && depthFrame != nullptr) {

        // Temporary depth to color transformation since align doesn't seem to take into account lens distortion
        std::shared_ptr<ob::VideoFrame> transDepthFrame = (ob::CoordinateTransformHelper::transformationDepthFrameToColorCamera(device, depthFrame, colorFrame->width(), colorFrame->height()))->as<ob::VideoFrame>();

        if (transDepthFrame != nullptr) {
            // Save color and depth data into a CameraFrame
            std::shared_ptr<CameraFrame> frame = std::make_shared<CameraFrame>();

            cv::Mat colorMat(colorFrame->height(), colorFrame->width(), CV_8UC4, colorFrame->data(), cv::Mat::AUTO_STEP);
            cv::cvtColor(colorMat, frame->color, cv::COLOR_BGRA2RGBA);
            cv::imwrite("ColorImage", colorMat);

            cv::Mat depthMat(transDepthFrame->height(), transDepthFrame->width(), CV_16U, transDepthFrame->data(), cv::Mat::AUTO_STEP);
            cv::imwrite("DepthImage", depthMat);

        }
    }
}

What type of device are you using? The Align Filter currently only supports Gemini 330 series devices. It will support all devices in the future.

from orbbecsdk.

zhonghong322 avatar zhonghong322 commented on September 27, 2024

In future versions, the interface will be unified, and there will be a single interface to implement both D2C and C2D functionality,all Device use the Align Filter.

from orbbecsdk.

Xasyo avatar Xasyo commented on September 27, 2024

Thanks for the response! I'm using Femtobolt I guess I'll just have to wait ; )

from orbbecsdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.