DepthAI
Software Stack

ON THIS PAGE

  • Source code

Health Check

Supported on:RVC2RVC4
This example runs the DepthAI device health check and prints the resulting diagnostics. Use it as a quick preflight test to inspect device status, connection type, bandwidth, power supply behavior, calibration, camera sensors, IR sensors, and any reported issues.The example customizes HealthCheckConfig.powerSupplyCheckDuration to spend more time validating power behavior before printing the final metrics.This example requires the DepthAI v3 API, see installation instructions.

Source code

Python

Python
GitHub
1#!/usr/bin/env python3
2
3import sys
4import time
5from datetime import timedelta
6
7import depthai as dai
8
9
10def main() -> int:
11    config = dai.HealthCheckConfig(powerSupplyCheckDuration=timedelta(milliseconds=20000))
12
13    deviceInfos = dai.Device.getAllConnectedDevices()
14    if not deviceInfos:
15        print("No DepthAI device found.", file=sys.stderr)
16        return 1
17
18    deviceInfo = deviceInfos[0]
19
20    print(f"Device: {deviceInfo}")
21    print(f"Power supply check duration: {int(config.powerSupplyCheckDuration.total_seconds() * 1000)} ms")
22    print("Running health check...")
23
24    start = time.monotonic()
25    metrics = dai.Device.performHealthCheck(deviceInfo, config)
26    elapsedMs = int((time.monotonic() - start) * 1000)
27
28    print()
29    print(f"Health check completed in {elapsedMs} ms")
30    print(metrics)
31    return 0
32
33
34if __name__ == "__main__":
35    raise SystemExit(main())

C++

1#include <chrono>
2#include <cstdlib>
3#include <iostream>
4
5#include "depthai/depthai.hpp"
6
7int main() {
8    dai::HealthCheckConfig config;
9    config.powerSupplyCheckDuration = std::chrono::milliseconds(20000);
10
11    const auto devices = dai::Device::getAllConnectedDevices();
12    if(devices.empty()) {
13        std::cerr << "No DepthAI device found." << std::endl;
14        return EXIT_FAILURE;
15    }
16    const auto& deviceInfo = devices.front();
17
18    std::cout << "Device: " << deviceInfo.toString() << std::endl;
19    std::cout << "Power supply check duration: " << config.powerSupplyCheckDuration.count() << " ms" << std::endl;
20    std::cout << "Running health check..." << std::endl;
21
22    const auto start = std::chrono::steady_clock::now();
23    const auto metrics = dai::Device::performHealthCheck(deviceInfo, config);
24    const auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - start);
25
26    std::cout << std::endl;
27    std::cout << "Health check completed in " << elapsed.count() << " ms" << std::endl;
28    std::cout << metrics.toString() << std::endl;
29    return 0;
30}

Need assistance?

Head over to Discussion Forum for technical support or any other questions you might have.