mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
58 lines
2.1 KiB
C
58 lines
2.1 KiB
C
/*
|
|
* SPDX-License-Identifier: MIT
|
|
*
|
|
* Copyright (C) 2013-2025 OpenMV, LLC.
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
* in the Software without restriction, including without limitation the rights
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
* furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in
|
|
* all copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
* THE SOFTWARE.
|
|
*
|
|
* Averaging utility functions.
|
|
*/
|
|
#ifndef __AVERAGE_H__
|
|
#define __AVERAGE_H__
|
|
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
typedef struct rgb_moving_average_val {
|
|
uint32_t r_value;
|
|
uint32_t g_value;
|
|
uint32_t b_value;
|
|
uint32_t timestamp_ms;
|
|
} rgb_moving_average_val_t;
|
|
|
|
typedef struct rgb_moving_average {
|
|
size_t size;
|
|
size_t tail;
|
|
size_t head;
|
|
size_t count;
|
|
uint32_t max_ms;
|
|
rgb_moving_average_val_t *buffer;
|
|
uint64_t r_sum;
|
|
uint64_t g_sum;
|
|
uint64_t b_sum;
|
|
} rgb_moving_average_t;
|
|
|
|
void rgb_moving_average_init(rgb_moving_average_t *ma, uint32_t max_ms,
|
|
size_t size, rgb_moving_average_val_t *buffer);
|
|
void rgb_moving_average_update(rgb_moving_average_t *ma,
|
|
uint32_t *r_value, uint32_t *g_value, uint32_t *b_value,
|
|
uint32_t current_ms);
|
|
void rgb_moving_average_get(rgb_moving_average_t *ma, uint32_t *r_value, uint32_t *g_value, uint32_t *b_value);
|
|
#endif // __AVERAGE_H__
|