此页面由 AI 自动翻译。查看英文原版
DepthAI
  • DepthAI 组件
    • AprilTags
    • 基准测试
    • Camera
    • 校准
    • DetectionNetwork
    • Events
    • FeatureTracker
    • Gate
    • HostNodes
    • ImageAlign
    • ImageManip
    • IMU
    • 杂项
    • 模型动物园
    • NeuralDepth
    • NeuralNetwork
    • ObjectTracker
    • 点云
    • RecordReplay
    • RGBD
    • Script
    • SpatialDetectionNetwork
    • SpatialLocationCalculator
    • StereoDepth
    • Sync
    • VideoEncoder
    • Visualizer
    • Warp
    • RVC2-specific
  • 高级教程
  • API 参考
  • 工具
软件栈

本页目录

  • 管道
  • 源代码

Basalt VIO

Supported on:RVC2
该示例创建了一个管道,用于以 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}

需要帮助?

请前往 Discussion Forum 获取技术支持或提出您可能有的任何其他问题。