DepthAI v2 has been superseded by DepthAI v3. You are viewing legacy documentation.
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}

需要帮助?

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