DepthAI
  • DepthAI组件
    • AprilTags
    • 基准测试
    • 相机
    • 校准
    • DetectionNetwork
    • 事件
    • FeatureTracker
    • HostNodes
    • ImageAlign
    • ImageManip
    • IMU
    • 杂项
    • 模型库
    • NeuralDepth
    • NeuralNetwork
    • ObjectTracker
    • 点云
    • RecordReplay
    • RGBD
    • 脚本
    • SpatialDetectionNetwork
    • SpatialLocationCalculator
    • StereoDepth
    • 同步
    • VideoEncoder
    • 可视化器
    • VSLAM
    • 扭曲
    • RVC2 特有
  • 高级教程
  • API 参考
  • 工具
软件栈

本页目录

  • 流水线
  • 源代码

Basalt VIO

Supported on:RVC2RVC4
该示例创建一个流水线,以 60 FPS 采集 640x400 立体相机帧,以 200 Hz 采集 IMU 数据,使用 BasaltVIO 进行视觉里程计处理,并将生成的变换和图像流式传输到 RerunNode 进行实时可视化。这个示例需要DepthAI v3 API,参见安装说明

流水线

源代码

Python

Python
GitHub
1import signal
2import time
3import depthai as dai
4from rerun_node import RerunNode
5# Create pipeline
6
7with dai.Pipeline() as p:
8    fps = 60
9    width = 640
10    height = 400
11    # Define sources and outputs
12    left = p.create(dai.node.Camera).build(dai.CameraBoardSocket.CAM_B, sensorFps=fps)
13    right = p.create(dai.node.Camera).build(dai.CameraBoardSocket.CAM_C, sensorFps=fps)
14    imu = p.create(dai.node.IMU)
15    odom = p.create(dai.node.BasaltVIO)
16
17    rerunViewer = p.create(RerunNode)
18    imu.enableIMUSensor([dai.IMUSensor.ACCELEROMETER_RAW, dai.IMUSensor.GYROSCOPE_RAW], 200)
19    imu.setBatchReportThreshold(1)
20    imu.setMaxBatchReports(10)
21
22    # Linking
23    left.requestOutput((width, height)).link(odom.left)
24    right.requestOutput((width, height)).link(odom.right)
25    imu.out.link(odom.imu)
26    odom.passthrough.link(rerunViewer.inputImg)
27    odom.transform.link(rerunViewer.inputTrans)
28    p.start()
29    while p.isRunning():
30        time.sleep(0.01)

C++

1#include "depthai/depthai.hpp"
2#include "rerun_node.hpp"
3
4int main() {
5    using namespace std;
6
7    // Create pipeline
8    dai::Pipeline pipeline;
9    int fps = 60;
10    int width = 640;
11    int height = 400;
12    // Define sources and outputs
13    auto left = pipeline.create<dai::node::Camera>()->build(dai::CameraBoardSocket::CAM_B, std::nullopt, fps);
14    auto right = pipeline.create<dai::node::Camera>()->build(dai::CameraBoardSocket::CAM_C, std::nullopt, fps);
15    auto imu = pipeline.create<dai::node::IMU>();
16    auto odom = pipeline.create<dai::node::BasaltVIO>();
17
18    auto rerun = pipeline.create<RerunNode>();
19    imu->enableIMUSensor({dai::IMUSensor::ACCELEROMETER_RAW, dai::IMUSensor::GYROSCOPE_RAW}, 200);
20    imu->setBatchReportThreshold(1);
21    imu->setMaxBatchReports(10);
22
23    // Linking
24    left->requestOutput(std::make_pair(width, height))->link(odom->left);
25    right->requestOutput(std::make_pair(width, height))->link(odom->right);
26    imu->out.link(odom->imu);
27    odom->transform.link(rerun->inputTrans);
28    odom->passthrough.link(rerun->inputImg);
29
30    pipeline.start();
31    pipeline.wait();
32}

需要帮助?

请前往 OAKChina 官网 获取技术支持或解答您的任何疑问。