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

本页目录

  • 类似示例:
  • 演示
  • 设置
  • 源代码

校准闪存

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

类似示例:

演示

示例脚本输出
Command Line
1~/depthai-python/examples$ python3 Calibration/calibration_flash.py
2    设备上的校准数据已备份到:
3    /home/erik/Luxonis/depthai-python/examples/Calibration/depthai_calib_backup.json
4    # 校准闪存成功

设置

请运行 安装脚本 以下载所有必需的依赖项。请注意,此脚本必须在 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 depthai as dai
5import argparse
6
7calibJsonFile = str((Path(__file__).parent / Path('../models/depthai_calib.json')).resolve().absolute())
8calibBackUpFile = str((Path(__file__).parent / Path('depthai_calib_backup.json')).resolve().absolute())
9
10parser = argparse.ArgumentParser()
11parser.add_argument('calibJsonFile', nargs='?', help="Path to calibration file in json", default=calibJsonFile)
12args = parser.parse_args()
13
14# Connect device
15with dai.Device(dai.OpenVINO.VERSION_UNIVERSAL, dai.UsbSpeed.HIGH) as device:
16
17    deviceCalib = device.readCalibration()
18    deviceCalib.eepromToJsonFile(calibBackUpFile)
19    print("Calibration Data on the device is backed up at:")
20    print(calibBackUpFile)
21    calibData = dai.CalibrationHandler(args.calibJsonFile)
22
23    try:
24        device.flashCalibration2(calibData)
25        print('Successfully flashed calibration')
26    except Exception as ex:
27        print(f'Failed flashing calibration: {ex}')

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 calibJsonFile(CALIB_PATH);
10    std::string calibBackUpFile("depthai_calib_backup.json");
11    if(argc > 1) {
12        calibJsonFile = std::string(argv[1]);
13    }
14
15    // Connect device
16    dai::Device device(dai::OpenVINO::VERSION_UNIVERSAL, dai::UsbSpeed::HIGH);
17
18    dai::CalibrationHandler deviceCalib = device.readCalibration();
19    deviceCalib.eepromToJsonFile(calibBackUpFile);
20    std::cout << "Calibration Data on the device is backed up at:" << calibBackUpFile << std::endl;
21    dai::CalibrationHandler calibData(calibJsonFile);
22
23    try {
24        device.flashCalibration2(calibData);
25        std::cout << "Successfully flashed calibration" << std::endl;
26    } catch(const std::exception& ex) {
27        std::cout << "Failed flashing calibration: " << ex.what() << std::endl;
28    }
29
30    return 0;
31}

需要帮助?

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