奥比中光深度相机使用(1)sdk下载与环境配置


前言

深度图(Depth Map)是一种用于表示场景中各点到观察者距离的图像,它能够为计算机视觉和图形处理提供重要的三维信息。在深度图中,每个像素的值代表了场景中对应点到摄像头的距离,通常使用灰度值或伪彩色来表示,灰度值越大或颜色越暖,表示距离越近。深度图广泛应用于虚拟现实、增强现实、三维重建、物体识别等领域。使用深度图,我们可以实现物体的遮挡检测、距离测量、三维建模等功能,从而为智能设备提供更加丰富的交互体验和更准确的环境感知能力。
本系列旨在通过奥比中光深度相机Gemini335为大家介绍如何使用本相机以及如何使用可见光与深度信息结合的方式用来解决实际问题


一、Gemini介绍

Orbbec Gemini 330系列3D相机集成了Orbbec的最新自研深度引擎ASIC,结合了主动和被动立体视觉技术,可在室内和室外条件下无缝运行。通过在3D相机内部完成深度图像计算和深度图像到彩色图像的空间对齐变换,实现了最小数据延时,并极大降低了对上位机的依赖。相机预置了多种工作模式,便捷高效适应不同的应用场景。灵活而丰富的帧同步机制使多摄像机操作变得简单且可扩展。
Orbbec Gemini 330系列由以下多个组件组成:

● 自研深度引擎ASIC芯片

● 双目IR模块

● 散斑发射模块

● RGB模块

● 激光测距模块

● IMU模块

● Orbbec SDK

● Wrappers(e.g. ROS1 / ROS2 / Python)
在这里插入图片描述
本系列使用的相机为Gemini335l ,其相机参数如下图所示:![在这里插入图片描述](https://i-blog.csdnimg.cn/direct/3d95f295f0c14c42afe270caed765973.png

二、SDK下载与Qt环境配置

本项目使用的系统为ubuntun18.04,使用的工具为Qt,
相机的sdk以及可视化工具点这里,若没有科学上网工具可以点这里,sdk的界面为
在这里插入图片描述

下载好sdk之后需要安装相机所对应的驱动,驱动所在的位置为:OrbbecSDK-main/misc/scripts,界面为:

运行下面代码安装驱动:

cd /home/build/OrbbecSDK-main/misc/scripts
sudo sh install_udev_rules.sh 

驱动安装完成之后即可开始配置QT环境QT工程中的.pro文件的内容为:

TEMPLATE = app
CONFIG += console c++11
CONFIG -= app_bundle
CONFIG -= qt

SOURCES += \
        main.cpp

INCLUDEPATH += /usr/local/include/opencv4
unix|win32: LIBS += -L/usr/local/lib/ -lopencv_world

INCLUDEPATH += /home/build/OrbbecSDK-main/include
INCLUDEPATH += /home/build/OrbbecSDK-main/examples/cpp
LIBS += -L/home/build/OrbbecSDK-main/lib/linux_x64/ -lOrbbecSDK



unix:!macx: LIBS += -L$$PWD/../../../usr/lib/x86_64-linux-gnu/ -lpthread
unix:!macx: PRE_TARGETDEPS += $$PWD/../../../usr/lib/x86_64-linux-gnu/libpthread.a

三、测试程序:

#include "window.hpp"

#include "libobsensor/hpp/Pipeline.hpp"
#include "libobsensor/hpp/Error.hpp"

int main(int argc, char **argv) try {
    // Create a pipeline with default device
    ob::Pipeline pipe;
    // By creating config to configure which streams to enable or disable for the pipeline, here the depth stream will be enabled
    std::shared_ptr<ob::Config> config = std::make_shared<ob::Config>();
    config->enableVideoStream(OB_STREAM_DEPTH);

    // Start the pipeline with config
    pipe.start(config);
    auto currentProfile = pipe.getEnabledStreamProfileList()->getProfile(0)->as<ob::VideoStreamProfile>();
    // Create a window for rendering, and set the resolution of the window
    Window app("DepthViewer", currentProfile->width(), currentProfile->height());

    while(app) {
        // Wait for up to 100ms for a frameset in blocking mode.
        auto frameSet = pipe.waitForFrames(100);
        if(frameSet == nullptr) {
            continue;
        }

        auto depthFrame = frameSet->depthFrame();

        // for Y16 format depth frame, print the distance of the center pixel every 30 frames
        if(depthFrame->index() % 30 == 0 && depthFrame->format() == OB_FORMAT_Y16) {
            uint32_t  width  = depthFrame->width();
            uint32_t  height = depthFrame->height();
            float     scale  = depthFrame->getValueScale();
            uint16_t *data   = (uint16_t *)depthFrame->data();

            // pixel value multiplied by scale is the actual distance value in millimeters
            float centerDistance = data[width * height / 2 + width / 2] * scale;

            // attention: if the distance is 0, it means that the depth camera cannot detect the object(may be out of detection range)
            std::cout << "Facing an object " << centerDistance << " mm away. " << std::endl;
        }

        // Render frame in the window
        app.addToRender(depthFrame);
    }

    // Stop the pipeline
    pipe.stop();

    return 0;
}
catch(ob::Error &e) {
    std::cerr << "function:" << e.getName() << "\nargs:" << e.getArgs() << "\nmessage:" << e.getMessage() << "\ntype:" << e.getExceptionType() << std::endl;
    exit(EXIT_FAILURE);
}

效果:
请添加图片描述

  • 8
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值