Tutorial - Health Status

Open in ClaudeOpen in ChatGPT

This tutorial shows how to enable the camera’s image and sensor health checks and read the detailed health status returned by the SDK. It reports whether the current frame is corrupted, and flags low image quality, low lighting, low depth reliability and low motion-sensor reliability, so your application can detect and react to degraded camera conditions in real time.

Getting Started

Code Overview

Open the camera with the image validity check enabled

As in previous tutorials, we create, configure and open the ZED. Here, we also set enable_image_validity_check in InitParameters: a value of 1 enables the base health check, while higher values (2, 3) progressively enable image-quality and blur/quality verification at extra computational cost.

C++
1// Create a ZED camera object
2Camera zed;
3
4// Set configuration parameters
5InitParameters init_parameters;
6init_parameters.camera_resolution = RESOLUTION::AUTO; // Use HD720 or HD1200, depending on camera type
7init_parameters.camera_fps = 30;
8init_parameters.depth_mode = sl::DEPTH_MODE::NEURAL;
9// '1' enables the health check, higher values enable more advanced verification (see documentation)
10// but also increase the computation time. '2' adds image quality checks (absolute quality, and
11// difference between left and right), '3' adds advanced blur and quality checks.
12init_parameters.enable_image_validity_check = 1;
13
14// Open the camera
15auto returned_state = zed.open(init_parameters);
16if (returned_state > ERROR_CODE::SUCCESS) {
17 cout << "Error " << returned_state << ", exit program." << endl;
18 return EXIT_FAILURE;
19}

Detect corrupted frames

If the health check detects a corrupted frame, grab() returns the CORRUPTED_FRAME warning instead of SUCCESS (both are non-fatal — any error code lower than or equal to ERROR_CODE::SUCCESS still means a new image is available).

C++
1returned_state = zed.grab();
2// A new image is available if grab() returns ERROR_CODE::SUCCESS or a WARNING (an error_code lower than ERROR_CODE::SUCCESS)
3if (returned_state <= ERROR_CODE::SUCCESS) {
4
5} else if (returned_state == ERROR_CODE::CORRUPTED_FRAME) {
6 // If the health check detects a corrupted frame, grab() returns a warning error code: ERROR_CODE::CORRUPTED_FRAME
7 cout << "**** Corrupted frame detected ! *****" << endl;
8} else {
9 cout << "Error " << returned_state << endl;
10}

Read the detailed health status

Beyond the per-frame grab() result, Camera::getHealthStatus() returns a HealthStatus structure with independent indicators for image quality, lighting, depth and motion-sensor reliability.

C++
1// Get the detailed health status
2auto health = zed.getHealthStatus();
3std::cout << "Health check enabled " << health.enabled << std::endl;
4std::cout << "low_image_quality " << health.low_image_quality << std::endl;
5std::cout << "low_lighting " << health.low_lighting << std::endl;
6std::cout << "low_depth_reliability " << health.low_depth_reliability << std::endl;
7std::cout << "low_motion_sensors_reliability " << health.low_motion_sensors_reliability << std::endl;

low_image_quality and low_lighting are only evaluated when enable_image_validity_check is set to 2 or higher.

Close the camera

C++
1// Close the camera
2zed.close();