首页 > 其他分享 >RealSense、ZED 和奥比中光Astra几款主流相机介绍及应用

RealSense、ZED 和奥比中光Astra几款主流相机介绍及应用

时间:2024-09-27 17:50:06浏览次数:3  
标签:stream ZED color frame 中光 RealSense depth sl image

以下是英特尔 RealSense、Stereolabs ZED 和奥比中光Astra几款相机的详细对比,包括参数、性能以及二次开发等支持,附带代码示例。

详细信息对比和二次开发示例

1. 英特尔 RealSense (例如 D435/D455)

  • 深度技术:立体视觉 + 红外投影
  • 分辨率
    • D435: 1280x720 @ 30fps
    • D455: 1920x1080 @ 30fps
  • 工作范围:0.2 米到 10 米
  • 视场角 (FOV):宽度 86°,高度 57°
  • 通讯接口:USB 3.0
  • SDK 支持Intel RealSense SDK
  • 二次开发支持:C++, Python, ROS 等
  • 安装依赖
pip install pyrealsense2

代码示例(Python)

import pyrealsense2 as rs
import numpy as np
import cv2

# 创建管道
pipeline = rs.pipeline()

# 配置流
config = rs.config()
config.enable_stream(rs.stream.depth, 640, 480, rs.format.z16, 30)
config.enable_stream(rs.stream.color, 640, 480, rs.format.bgr8, 30)

# 启动流
pipeline.start(config)

try:
    while True:
        frames = pipeline.wait_for_frames()
        depth_frame = frames.get_depth_frame()
        color_frame = frames.get_color_frame()

        if not depth_frame or not color_frame:
            continue

        # 将帧转换为numpy数组
        depth_image = np.asanyarray(depth_frame.get_data())
        color_image = np.asanyarray(color_frame.get_data())

        # 显示图像
        cv2.imshow('Color', color_image)
        cv2.imshow('Depth', depth_image)

        if cv2.waitKey(1) & 0xFF == ord('q'):
            break
finally:
    pipeline.stop()
    cv2.destroyAllWindows()

代码示例(C++)

#include <librealsense2/rs.hpp> // Include RealSense Cross Platform API
#include <iostream>

int main() {
    // Create a RealSense pipeline
    rs2::pipeline p;

    // Start the pipeline with default configuration
    p.start();

    while (true) {
        // Wait for a new frame
        rs2::frameset frames = p.wait_for_frames();

        // Get the depth frame
        rs2::depth_frame depth = frames.get_depth_frame();
        // Get the color frame
        rs2::frame color = frames.get_color_frame();

        if (!depth || !color) continue;

        // Get the dimensions of the image
        int width = depth.get_width();
        int height = depth.get_height();

        std::cout << "Depth Frame: " << width << "x" << height << std::endl;

        // Process the images (for demonstration, we just print the size)
        // Here you can add your own image processing code

        // Break the loop on a specific condition (e.g., pressing a key)
        // For this example, we'll just run indefinitely
    }

    return 0;
}

2. ZED (Stereolabs)

  • 深度技术:立体视觉 + IMU
  • 分辨率
    • ZED 2: 4416x1242 @ 15fps(720p模式约 60fps)
  • 工作范围:0.5 米到 20 米
  • 视场角 (FOV):水平 110°,垂直 75°
  • 通讯接口:USB 3.0
  • SDK 支持ZED SDK
  • 二次开发支持:C++, Python, Unity, ROS 等
    安装依赖
    参考 ZED SDK 安装指南

代码示例(Python)

import sys
import time
import pyzed.sl as sl

# 创建相机对象
zed = sl.Camera()

# 配置相机
init_params = sl.InitParameters()
init_params.camera_resolution = sl.RESOLUTION.HD720
init_params.depth_mode = sl.DEPTH_MODE.PERFORMANCE
zed.open(init_params)

while True:
    # 捕获图像
    if zed.grab() == sl.ERROR_CODE.SUCCESS:
        image = sl.Mat()
        zed.retrieve_image(image, sl.VIEW.COLOR)
        depth = sl.Mat()
        zed.retrieve_measure(depth, sl.MEASURE.DEPTH)

        # 获取图像数据
        image_ocv = image.get_data()
        depth_ocv = depth.get_data()

        # 显示图像
        cv2.imshow("ZED Color", image_ocv)
        cv2.imshow("ZED Depth", depth_ocv)
        
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break

# 关闭相机
zed.close()

代码示例(C++)

#include <sl/Camera.hpp>

int main(int argc, char **argv) {
    sl::Camera zed;
    sl::InitParameters init_params;
    init_params.camera_resolution = sl::RESOLUTION::HD720;
    init_params.depth_mode = sl::DEPTH_MODE::PERFORMANCE;

    // 开始相机
    if (zed.open(init_params) != sl::ERROR_CODE::SUCCESS) {
        std::cerr << "Error opening ZED camera." << std::endl;
        return EXIT_FAILURE;
    }

    sl::Mat image, depth;

    while (true) {
        if (zed.grab() == sl::ERROR_CODE::SUCCESS) {
            zed.retrieveImage(image, sl::VIEW::LEFT);
            zed.retrieveMeasure(depth, sl::MEASURE::DEPTH);

            // 显示图像和深度
            cv::imshow("ZED Image", image.getCvMat());
            cv::imshow("ZED Depth", depth.getCvMat());

            if (cv::waitKey(1) == 'q') break;
        }
    }
    zed.close();
    return EXIT_SUCCESS;
}

3. 奥比中光(Orbbec)

  • 深度技术:结构光
  • 分辨率
    • Astra: 640x480 @ 30fps
    • Astra Pro: 1280x720 @ 30fps
  • 工作范围:0.4 米到 8 米
  • 视场角 (FOV):水平 60°,垂直 49°
  • 通讯接口:USB 2.0 / USB 3.0
  • SDK 支持奥比中光 SDK
  • 二次开发支持:C++, C#, Python, Unity 等
  • 安装依赖
    参考 奥比中光 SDK 安装指南

代码示例(Python)

import numpy as np
import cv2
import openni2

# 初始化
openni2.initialize()
dev = openni2.Device.open_any()
depth_stream = dev.create_depth_stream()
color_stream = dev.create_color_stream()

# 开启流
depth_stream.start()
color_stream.start()

while True:
    depth_frame = depth_stream.read_frame()
    color_frame = color_stream.read_frame()

    depth_data = np.frombuffer(depth_frame.get_buffer_as_uint16(), dtype=np.uint16)
    color_data = np.frombuffer(color_frame.get_buffer_as_uint8(), dtype=np.uint8)

    # 处理深度数据
    depth_image = depth_data.reshape((depth_frame.height, depth_frame.width))
    color_image = color_data.reshape((color_frame.height, color_frame.width, 3))

    # 显示图像
    cv2.imshow('Color Image', color_image)
    cv2.imshow('Depth Image', depth_image)

    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

# 停止流
depth_stream.stop()
color_stream.stop()
openni2.unload()

代码示例(C++)

#include <OpenNI.h>
#include <iostream>

int main() {
    openni::OpenNI::initialize();
    openni::Device device;
    if (device.open(openni::ANY_DEVICE) != openni::STATUS_OK) {
        std::cerr << "Could not open device." << std::endl;
        return -1;
    }

    openni::VideoStream depthStream, colorStream;
    depthStream.create(device, openni::SENSOR_DEPTH);
    colorStream.create(device, openni::SENSOR_COLOR);

    depthStream.start();
    colorStream.start();

    openni::VideoFrameRef depthFrame, colorFrame;

    while (true) {
        depthStream.readFrame(&depthFrame);
        colorStream.readFrame(&colorFrame);

        // 显示深度和颜色
        // 需添加显示代码 (如使用 OpenCV)
        
        if (/* 检测退出条件 */) break;
    }

    depthStream.stop();
    colorStream.stop();
    device.close();
    openni::OpenNI::shutdown();
    return 0;
}

综合参数对比

参数英特尔 RealSenseStereolabs ZED奥比中光
深度技术立体视觉 + 红外投影立体视觉 + IMU结构光
分辨率D435: 1280x720; D455: 1920x1080ZED 2: 4416x1242Astra: 640x480; Pro: 1280x720
工作范围0.2 米到 10 米0.5 米到 20 米0.4 米到 8 米
视场角 (FOV)86° x 57°110° x 75°60° x 49°
通讯接口USB 3.0USB 3.0USB 2.0 / USB 3.0
SDKIntel RealSense SDKZED SDK奥比中光 SDK
二次开发支持丰富的文档与社区详细API与示例文档与多平台支持
参数Intel RealSense D435iZED Mini奥比中光 Astra Pro
分辨率1280x720 (RGB), 640x480 (Depth)1280x720 (RGB), 720p (Depth)1280x720 (RGB), 640x480 (Depth)
深度范围0.3m - 10m0.3m - 20m0.5m - 8m
帧率30 fps (depth + RGB)60 fps (depth + RGB)30 fps (depth + RGB)
通讯接口USB 3.0USB 3.0USB 3.0
视场角69.4° x 42.5°110° x 80°90° x 60°

综合性能对比

  • 计算能力:

    • RealSense 配备 IMU,适合移动设备和机器人。
    • ZED 提供高精度深度数据和较大的视场角,适合 AR/VR 应用。
    • 奥比中光专注于深度图像和手势识别等应用,适合人机交互。
  • 使用场景:

    • RealSense: 机器人视觉、手势识别。
    • ZED: 虚拟现实、增强现实、3D 映射。
    • 奥比中光: 智能家居、互动游戏。

总结

以上是对三种不同厂家相机的基本信息对比及二次开发示例,可作为小白简单了解和熟悉。不同的项目需求可以选择不同的相机,根据具体应用场景进行开发。

标签:stream,ZED,color,frame,中光,RealSense,depth,sl,image
From: https://blog.csdn.net/weixin_40514381/article/details/142598884

相关文章

  • 一篇文章讲清楚synchronized关键字的作用及原理
    概述在应用Sychronized关键字时需要把握如下注意点:一把锁只能同时被一个线程获取,没有获得锁的线程只能等待;每个实例都对应有自己的一把锁(this),不同实例之间互不影响;例外:锁对象是*.class以及synchronized修饰的是static方法的时候,所有对象公用同一把锁synchronized修饰......
  • vite optimizeDeps 配置 预编译的包
    说明主要用来让vite启动的时候预编译一些包,而不是运行网页的时候才编译,这样可以加快网页首次的加载速度,但是可能vite首次启动会比较慢点配置示例optimizeDeps:{ include:[ 'vue', 'vue-router', 'vue-types', 'element-plus/es/locale/lang/zh-cn', 'element-plu......
  • Zed for Windows从源代码编译
    Zed是一个优秀的开源IDE,网上很多赞美它的文章,堪比VSCode。笔者用了几次VSCode,一直不喜欢。主要问题有两个:1.界面不美观,不精致;2.最重要的,开发稍微大型的项目,经常崩溃。一直关注Zed官网,Windows版从未上线。这次下决心从源码自己编译一个吧。环境:操作系统:Windows10CPU:Intel......
  • Stylized Smooth Clouds 卡通风格化云朵包
    下载:​​Unity资源商店链接资源下载链接效果图:......
  • synchronized 几种使用方式
    同步方法由于Java的每个对象都有一个内置锁,当synchronized关键字修饰方法时,内置锁会保护整个方法。在调用该方法前,需要获得内置锁,否则就处于阻塞状态publicclassTest{/***这种方式是对象锁。普通实例方法默认同步监视器就是this,即调用该方法的对象*/......
  • 谈谈你对Synchronized锁的理解
    一、什么是Synchronized同步锁synchronized是Java中用于实现线程安全的关键字,可以应用于方法或代码块上,用于实现线程安全的同步机制。synchronized控制多个线程对共享资源的访问,确保多个线程在同一时刻,只有一个线程可以执行某个方法或者代码块,保证了代码执行的一致性和原子性......
  • 开关电源中光耦的CTR对控制环路的影响
    一、基本概念光耦的CTR(CurrentTransferRatio,电流传输比)是指光耦输出端的电流与输入端的电流之比,它直接影响控制环路的增益和稳定性。二、主要影响CTR值对控制环路的主要影响方式有以下两个, 1、CTR值过高当光耦的CTR值过高时,意味着输出端的电流相对于输入端的电流较大......
  • Java 并发编程深度解析:synchronized 关键字的内部原理与应用
    引言在并发编程中,当多个线程访问同一个共享资源时,我们必须考虑如何维护数据的原子性。Java是通过synchronized关键字实现锁功能来做到这点的,synchronized是JVM实现的一种内置锁,锁的获取和释放由JVM隐式实现。锁的本质如上图所示,多个线程要访问同一个资源。线程就......
  • Java中的线程安全:从synchronized到Lock的深入理解
    Java中的线程安全:从synchronized到Lock的深入理解大家好,我是微赚淘客返利系统3.0的小编,是个冬天不穿秋裤,天冷也要风度的程序猿!在多线程编程中,确保线程安全是至关重要的任务。Java提供了多种机制来处理线程安全问题,从基本的synchronized关键字到更复杂的Lock接口。本文将深入......
  • synchronized
    synchronizedsynchronized底层是如何实现的以及什么是锁的升级和降级?synchronized是java内建的一种同步机制,当一个线程已经获取到锁了,其他的线程试图获取锁的时候就只能等待或者阻塞在那里。synchronized可以用来修饰方法也可以用来修饰代码块。synchronized底层是基于一对mo......