Monado OpenXR Runtime
Loading...
Searching...
No Matches
u_autoexpgain.h
Go to the documentation of this file.
1// Copyright 2022, Collabora, Ltd.
2// SPDX-License-Identifier: BSL-1.0
3/*!
4 * @file
5 * @brief Automatically compute exposure and gain values from an image stream
6 * @author Mateo de Mayo <mateo.demayo@collabora.com>
7 * @ingroup aux_util
8 */
9
10#pragma once
11
12#include "xrt/xrt_frame.h"
13#include <stdint.h>
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19//! Most steps a custom table passed to @ref u_autoexpgain_create_with_steps can have.
20#define U_AEG_MAX_STEPS 16
21
22//! An auto exposure/gain strategy tunes the algorithm for specific objectives.
24{
25 U_AEG_STRATEGY_TRACKING = 0, //!< Lower exposure and gain at the cost of darker images.
26 U_AEG_STRATEGY_DYNAMIC_RANGE, //!< Tries to maximize the image information
27 U_AEG_STRATEGY_COUNT
28};
29
30struct u_autoexpgain;
31
32//! These are steps for constructing a piecewise linear function that maps
33//! brightness into (exposure, gain) pairs.
35{
36 float brightness; //!< Must be between 0 and 1
37 float exposure; //!< Must be set such that pixel brightness increases with brightness, ideally linearly
38 float gain; //!< @copydoc exposure
39};
40
41/*!
42 * Create auto exposure and gain (AEG) algorithm object.
43 *
44 * @param strategy What objective is preferred for the algorithm.
45 * @param enabled_from_start Update exposure/gain from the start.
46 * @param frame_delay About how many frames does it take for exp and gain to settle in.
47 * @return struct u_autoexpgain* Created object
48 */
49struct u_autoexpgain *
50u_autoexpgain_create(enum u_aeg_strategy strategy, bool enabled_from_start, int frame_delay);
51
52/*!
53 * @copydoc u_autoexpgain_create
54 * @param steps Brightness ascending, from 0 to 1; copied.
55 * @param step_count Between 2 and @ref U_AEG_MAX_STEPS.
56 */
57struct u_autoexpgain *
59 bool enabled_from_start,
60 int frame_delay,
61 const struct u_aeg_step *steps,
62 int step_count);
63
64//! Setup UI for the AEG algorithm
65void
66u_autoexpgain_add_vars(struct u_autoexpgain *aeg, void *root, char *prefix);
67
68//! Update the AEG with a frame
69void
70u_autoexpgain_update(struct u_autoexpgain *aeg, struct xrt_frame *xf);
71
72//! Get currently computed exposure value in usecs.
73float
75
76//! Get currently computed gain value
77float
79
80//! Destroy AEG object
81void
83
84#ifdef __cplusplus
85}
86#endif
These are steps for constructing a piecewise linear function that maps brightness into (exposure,...
Definition u_autoexpgain.h:35
float exposure
Must be set such that pixel brightness increases with brightness, ideally linearly.
Definition u_autoexpgain.h:37
float brightness
Must be between 0 and 1.
Definition u_autoexpgain.h:36
float gain
Must be set such that pixel brightness increases with brightness, ideally linearly.
Definition u_autoexpgain.h:38
Auto exposure and gain (AEG) adjustment algorithm state.
Definition u_autoexpgain.c:68
enum u_aeg_strategy strategy
The selected strategy affects various targets of the algorithm.
Definition u_autoexpgain.c:86
int frame_delay
A camera might take a couple of frames until the new exposure/gain sets in the image.
Definition u_autoexpgain.c:112
struct u_aeg_step steps[U_AEG_MAX_STEPS]
Custom exp/gain table, used instead of the strategy's default when not empty.
Definition u_autoexpgain.c:118
Basic frame data structure - holds a pointer to buffer.
Definition xrt_frame.h:25
u_aeg_strategy
An auto exposure/gain strategy tunes the algorithm for specific objectives.
Definition u_autoexpgain.h:24
@ U_AEG_STRATEGY_TRACKING
Lower exposure and gain at the cost of darker images.
Definition u_autoexpgain.h:25
@ U_AEG_STRATEGY_DYNAMIC_RANGE
Tries to maximize the image information.
Definition u_autoexpgain.h:26
float u_autoexpgain_get_exposure(struct u_autoexpgain *aeg)
Get currently computed exposure value in usecs.
Definition u_autoexpgain.c:522
void u_autoexpgain_add_vars(struct u_autoexpgain *aeg, void *root, char *prefix)
Setup UI for the AEG algorithm.
Definition u_autoexpgain.c:477
float u_autoexpgain_get_gain(struct u_autoexpgain *aeg)
Get currently computed gain value.
Definition u_autoexpgain.c:528
void u_autoexpgain_destroy(struct u_autoexpgain **aeg)
Destroy AEG object.
Definition u_autoexpgain.c:534
struct u_autoexpgain * u_autoexpgain_create(enum u_aeg_strategy strategy, bool enabled_from_start, int frame_delay)
Create auto exposure and gain (AEG) algorithm object.
Definition u_autoexpgain.c:421
struct u_autoexpgain * u_autoexpgain_create_with_steps(enum u_aeg_strategy strategy, bool enabled_from_start, int frame_delay, const struct u_aeg_step *steps, int step_count)
Create auto exposure and gain (AEG) algorithm object.
Definition u_autoexpgain.c:454
void u_autoexpgain_update(struct u_autoexpgain *aeg, struct xrt_frame *xf)
Update the AEG with a frame.
Definition u_autoexpgain.c:515
Data frame header.