pnna/include/preprocess.h

86 lines
2.2 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* @Author: xun
* @Date: 2024-05-08 09:30:39
* @LastEditors: xun
* @LastEditTime: 2025-02-18 11:20:05
* @Description:
* Copyright (c) 2024 by CCYH, All Rights Reserved.
*/
#ifndef _PREPROCESS_H_
#define _PREPROCESS_H_
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief 归一化相关参数,输入为图片时用到
*
*/
typedef struct _normalization_params
{
int width;
int height;
int channel;
int mean[3];
int std[3];
int reorder_channel[3];
float scale;
} normalization_params;
/**
* @brief 设置归一化参数
*
* @param OUT norm_params 将参数赋值给该结构体
* @param IN w 图片宽
* @param IN h 图片高
* @param IN c 图片通道数
* @param IN mean 数组,每个通道的平均值
* @param IN std 数组,每个通道的标准差
* @param IN reorder_channel 数组通道的顺序rgb bgr...
* @param IN scale 缩放因子
*/
void set_normalize_params(normalization_params *norm_params, int w, int h, int c,\
int *mean, int *std, int *reorder_channel, float scale);
/**
* @brief 利用malloc创建空间
*
* @param OUT buffer 创建好的内存空间地址
* @param IN count 需要创建内存空间的个数
* @param IN size 需要创建内存空间的大小
* @return int 处理后的状态码0表示成功其他表示失败
*/
int create_buffers(void **buffer, const int count, int *size);
/**
* @brief 销毁空间与create_buffers()函数配套使用
*
* @param IN buffer 待销毁的内存空间地址
* @param IN count 待销毁的内存空间的个数
*/
void destroy_buffers(void **buffer, const int count);
/**
* @brief 前处理,将每维度输入数据都进行归一化操作
*
* @param IN input_buffer 待归一化的数据
* @param IN norm_params 归一化参数
* @param IN input_count 输入数据的维度
* @param OUT output_buffer 归一化后的结果
* @return int 处理后的状态码0表示成功其他表示失败
*/
int preprocess(void **input_buffer, normalization_params *norm_params, \
int input_count, void **output_buffer);
#ifdef __cplusplus
}
#endif
#endif // !_PREPROCESS_H_