DepthAI v2 has been superseded by DepthAI v3. You are viewing legacy documentation.
此页面由 AI 自动翻译。查看英文原版
DepthAI 教程
DepthAI API 参考

本页目录

  • 设置
  • 源代码

校准闪存 v5

此示例演示如何将版本 5(gen1 校准数据)的校准数据闪存到设备。

类似示例:

设置

请运行 安装脚本 以下载所有必需的依赖项。请注意,此脚本必须在 git 上下文中运行,因此您必须先下载 depthai-python 存储库,然后运行脚本
Command Line
1git clone https://github.com/luxonis/depthai-python.git
2cd depthai-python/examples
3python3 install_requirements.py
有关更多信息,请遵循 安装指南

源代码

Python

Python
GitHub
1#!/usr/bin/env python3
2
3from pathlib import Path
4import cv2
5import depthai as dai
6import argparse
7
8boardConfigFile = str((Path(__file__).parent / Path('../models/BW1098OBC.json')).resolve().absolute())
9calibBinaryFile = str((Path(__file__).parent / Path('../models/depthai_v5.calib')).resolve().absolute())
10calibBackUpFile = str((Path(__file__).parent / Path('depthai_calib_backup.json')).resolve().absolute())
11
12parser = argparse.ArgumentParser()
13parser.add_argument('boardConfigFile', nargs='?', help="Path to board config file", default=boardConfigFile)
14parser.add_argument('calibBinaryFile', nargs='?', help="Path to version 5 .calib file", default=calibBinaryFile)
15args = parser.parse_args()
16
17# Connect device
18with dai.Device() as device:
19
20    deviceCalib = device.readCalibration()
21    deviceCalib.eepromToJsonFile(calibBackUpFile)
22    print("Calibration Data on the device is backed up at:")
23    print(calibBackUpFile)
24    calibData = dai.CalibrationHandler(args.calibBinaryFile, args.boardConfigFile)
25
26    status = device.flashCalibration(calibData)
27    if status:
28        print('Calibration Flash Successful')
29    else:
30        print('Calibration Flash Failed!!!')

C++

1#include <cstdio>
2#include <iostream>
3#include <string>
4
5// Includes common necessary includes for development using depthai library
6#include "depthai/depthai.hpp"
7
8int main(int argc, char** argv) {
9    std::string calibBinaryFile(CALIB_PATH), boardConfigFile(BOARD_PATH);
10    std::string calibBackUpFile("depthai_calib_backup.json");
11    if(argc > 2) {
12        calibBinaryFile = std::string(argv[1]);
13        boardConfigFile = std::string(argv[2]);
14    }
15
16    // Connect device
17    dai::Device device;
18
19    dai::CalibrationHandler deviceCalib = device.readCalibration();
20    deviceCalib.eepromToJsonFile(calibBackUpFile);
21    std::cout << "Calibration Data on the device is backed up at:" << calibBackUpFile << std::endl;
22    dai::CalibrationHandler calibData(calibBinaryFile, boardConfigFile);
23
24    if(device.flashCalibration(calibData)) {
25        std::cout << "Calibration Flash Successful" << std::endl;
26    } else {
27        std::cout << "Calibration Flash Failed!!!" << std::endl;
28    }
29
30    return 0;
31}

需要帮助?

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