相机健康检查

简介

The camera health check runs a set of diagnostics on a connected camera and returns a report (Camera::checkHealth()). Each individual check has a status (severity) and the underlying value it was derived from, and an overall status aggregates the worst severity across all checks. This is useful for verifying that the camera is operating within its specified range, and for catching issues such as a stopped fan, or a slow host connection before they affect production.

Zivid Studio 中也提供相同的报告,请参见 Health Check(健康检查)。

备注

The camera must be connected to run a health check. Calling Camera::checkHealth() on a camera that is not connected throws an exception.

状态值

每项检查会报告以下严重程度之一:

状态

含义

OK

最佳状态。

Suboptimal

状态下降但仍可正常工作。

Error

故障或超出规格。

Unknown

未执行检查,或无法确定其结果。

各项检查

检查项

描述

值

最大传输速度

相机与主机计算机之间的最大端到端传输速度(取相机端口链路速度与主机 PC 网络适配器链路速度中的较小值)。

以 Mbps 表示的传输速度。

温度(DMD、LED、镜头)

相机各组件温度的状态。

组件温度,以摄氏度表示。

风扇

相机风扇是否按预期运行。

风扇是正在运行,还是意外停转。

内存

相机内存测试的结果。

检测到的内存错误数量。

Infield Verification(现场验证)

相机最近一次 Infield Verification 的状态。

最近一次现场验证的时间。

每项检查都同时携带一个状态和由此得出该状态的原始数值。该数值是可选的,可能未设置(例如当检查无法执行时)。

备注

健康检查是一次性的诊断操作。如需持续监测以摄氏度表示的原始组件温度,请参见 监控相机温度。

轮询健康检查

以下示例在一个独立线程中轮询健康检查,每秒打印一次整体状态以及各项状态和数值,同时主线程持续进行捕获。这展示了如何在正在运行的捕获循环的后台监测健康检查:

转到源码

源码

const auto pollInterval = std::chrono::seconds(1);
std::promise<void> stop;
auto stopRequested = stop.get_future();

auto polling = std::async(std::launch::async, [&] {
    do
    {
        printHealthcheck(camera.checkHealth());
        std::cout << std::endl;
    } while(stopRequested.wait_for(pollInterval) == std::future_status::timeout);
});

const auto settings = Zivid::Settings{ Zivid::Settings::Acquisitions{ Zivid::Settings::Acquisition{} } };
const auto captureCycle = std::chrono::seconds(5);
const size_t numberOfCaptures = 5;

for(size_t i = 1; i <= numberOfCaptures; ++i)
{
    const auto frame = camera.capture3D(settings);
    std::cout << "Captured frame " << i << " of " << numberOfCaptures << std::endl;
    if(i < numberOfCaptures)
    {
        std::this_thread::sleep_for(captureCycle);
    }
}

stop.set_value();
polling.get();
转到源码

源码

var pollInterval = TimeSpan.FromSeconds(1);
var stop = new ManualResetEventSlim(false);

var pollingTask = Task.Run(() =>
{
    while (!stop.IsSet)
    {
        PrintHealthcheck(camera.CheckHealth());
        Console.WriteLine();
        stop.Wait(pollInterval);
    }
});

var settings = new Zivid.NET.Settings { Acquisitions = { new Zivid.NET.Settings.Acquisition { } } };
var captureCycle = TimeSpan.FromSeconds(5);
const int numberOfCaptures = 5;

for (int i = 1; i <= numberOfCaptures; ++i)
{
    using (camera.Capture3D(settings)) { }
    Console.WriteLine("Captured frame {0} of {1}", i, numberOfCaptures);
    if (i < numberOfCaptures)
    {
        Thread.Sleep(captureCycle);
    }
}

stop.Set();
pollingTask.Wait();
转到源码

源码

poll_interval = 1
stop = threading.Event()

def poll() -> None:
    while not stop.is_set():
        _print_healthcheck(camera.check_health())
        print()
        stop.wait(poll_interval)

polling_thread = threading.Thread(target=poll)
polling_thread.start()

settings = zivid.Settings(acquisitions=[zivid.Settings.Acquisition()])
capture_cycle = 5
number_of_captures = 5

for i in range(1, number_of_captures + 1):
    camera.capture_3d(settings)
    print(f"Captured frame {i} of {number_of_captures}")
    if i < number_of_captures:
        time.sleep(capture_cycle)

stop.set()
polling_thread.join()

版本历史

SDK

变更内容

2.18.0

新增相机健康检查功能。