Skip to main content
💡 TL;DR

Tracking quality of every Computer Vision app is only as good as the environment it runs in. Our new LightBuzz APIs allow your Body Tracking apps to understand the lighting conditions and prompt users to adjust their setup. Read on to make your application environment-aware!

Computer vision algorithms have a well-known limitation: they cannot see in the dark. No matter how advanced the AI model, the quality of body tracking is often at the mercy of the physical environment’s lighting.

When users complain about “jittery” tracking or lost skeletons, the culprit is frequently a poorly lit room, not the software.

To help developers solve this common UX challenge, we are introducing the Brightness Estimator. This new tool analyzes the incoming video stream and provides a normalized luminance score, allowing your application to provide real-time feedback to the user.

Understanding the Data

The BrightnessEstimator analyzes camera frames and outputs a normalized float value between 0.0 and 1.0.

The value is proportional to the light level:

  • 0.0: Insufficient lighting (total darkness).
  • 1.0: High-intensity environment (direct sunlight or bright studio lights).

The sweet spot

For optimal skeletal tracking results, you should aim for a luminance value between 0.2 (20%) and 0.8 (80%).

Hint: If the value drops below 20%, you can trigger a UI prompt advising the user to “Turn on a light.” If it exceeds 80%, you might warn them about potential glare or washout.

Implementation Guide

Using the tool is straightforward. It integrates directly into your existing sensor loop.

1. Initialization

Create an instance of the class. This is lightweight and should be done when your script starts.

private readonly BrightnessEstimator _brightnessEstimator = new BrightnessEstimator();

2. Update

Feed the current FrameData into the estimator to get the instantaneous brightness level.

float brightness = _brightnessEstimator.Update(frame);
Debug.Log($"Brightness level: {(brightness * 100.0f):N0}%");

3. Cleanup

As with other sensor components, always dispose of the estimator when the scene ends to free up resources.

_brightnessEstimator.Dispose();

⚡ Pro Tip: Performance Optimization

While the BrightnessEstimator is highly efficient — executing in just a few milliseconds on modern hardware — lighting conditions seldom fluctuate at the speed of a camera’s shutter. Consequently, recalculating luminance every 16ms or 33ms (60 or 30 FPS) introduces redundant processing overhead without adding tangible value.

Recommendation: To maximize CPU performance for your core application logic, we recommend calling the Update() method once per second. This sampling rate is sufficient to detect environmental changes (like a user turning off a light switch) without consuming unnecessary system resources.

Complete code example

Below is a complete MonoBehaviour script demonstrating how to integrate the Brightness Estimator into a standard Unity workflow.

using LightBuzz.BodyTracking;
using UnityEngine;
public class BrightnessEstimatorDemo : MonoBehaviour
{
    // 1. The streaming sensor
    // Learn more: https://lightbuzz.com/docs/
    private Sensor _sensor;
    
    // 1. Define the estimator
    private readonly BrightnessEstimator _brightnessEstimator = new BrightnessEstimator();
    private void Start()
    {
        _sensor = Sensor.Create(new SensorConfiguration());
        _sensor.Open();
    }
    private void OnDestroy()
    {
        // 3. Clean up resources
        _brightnessEstimator.Dispose();
        
        _sensor.Close();
        _sensor.Dispose();
    }
    private void Update()
    {
        if (_sensor == null || !_sensor.IsOpen) return;
        FrameData frame = _sensor.Update();
        if (frame == null) return;
        
        // 2. Calculate brightness
        // For production, consider wrapping this in a timer to run 1x per second.
        float brightness = _brightnessEstimator.Update(frame);
        
        // Log the result as a percentage
        // For production, display a message if the scene is too dark or too bright.
        Debug.Log($"Brightness level: {(brightness * 100.0f):N0}%");
    }
}

Summary

By implementing the Brightness Estimator, you move from “passive” tracking (hoping the user has good lights) to active environment diagnostics. This small addition can significantly reduce support tickets regarding tracking quality and improve the overall professionalism of your application.

The Brightness Estimator is available in the latest version of the Body Tracking SDK.

Body tracking

LightBuzz has created the world’s most accurate body tracking software solution. Companies and universities worldwide use our SDK to develop commercial apps for desktop and mobile devices.

Vangos Pterneas

Vangos Pterneas is a software engineer, book author, and award-winning Microsoft Most Valuable Professional (2014-2019). Since 2012, Vangos has been helping Fortune-500 companies and ambitious startups create demanding motion-tracking applications. He's obsessed with analyzing and modeling every aspect of human motion using AI and Maths. Vangos shares his passion by regularly publishing articles and open-source projects to help and inspire fellow developers.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.