Files
kunlun/export/inc/cnn/iot_affine_trans_api.h
2024-09-28 14:24:04 +08:00

89 lines
2.9 KiB
C

/****************************************************************************
Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
be copied by any method or incorporated into another program without
the express written consent of Aerospace C.Power. This Information or any portion
thereof remains the property of Aerospace C.Power. The Information contained herein
is believed to be accurate and Aerospace C.Power assumes no responsibility or
liability for its use in any way and conveys no license or title under
any patent or copyright and makes no representation or warranty that this
Information is free from patent or copyright infringement.
****************************************************************************/
#ifndef AFFINETRANSACTION_H
#define AFFINETRANSACTION_H
#include <math.h>
#include "iot_io_api.h"
#include "os_mem_api.h"
#define WARP_SUCCESS 0
#define WARP_FAILURE 1
/*define a image struct including
image rows,cols,channels,and address of storing data*/
typedef struct _image_data_fmt
{
int32_t rows;
int32_t cols;
int32_t channels;
uint8_t* data;
} image_data_fmt;
/*image rotation center in the source image*/
typedef struct _point_2f
{
float x;
float y;
} point_2f;
/*rotation matrix*/
typedef struct _rotation_matrix
{
float rM[6];
}rotation_matrix;
/**
* @brief rotation_matrix2D_get() - get a rotation matrix
* @param center: Center of the rotation in the source image.
*
* @param angle: Rotation angle in degrees.
* Positive values mean counter-clockwise rotation
* (the coordinate origin is assumed to be the top-left corner)
*
* @param scale: Isotropic scale factor.
*
* @param matrix: The output affine transformation,2x3 floating-point32_t
matrix.
*/
void rotation_matrix2D_get
(point_2f center, float angle, float scale, rotation_matrix *matrix);
/**
* @brief image_warp_affine() - Applies an affine transformation to an image.
* @param source_image: source image struct including image rows, cols,
channels, data.
*
* @param dst_image_rows: Image rows.
*
* @param dst_image_cols: Image cols.
*
* @param dst_image_data: A pointer address to store Image data.
*
* @param matrix: The output affine transformation, 2x3
floating-point32_t matrix.
*
* @param enable_align: The raw align 32byte for cnn ,enable and disable.
*
* @return WARP_SUCCESS -- for success case
* @return WARP_FAILURE -- for failure case
*/
int32_t image_warp_affine(image_data_fmt source_image,
int32_t dst_image_rows, int32_t dst_image_cols, uint8_t *dst_image_data,
rotation_matrix *matrix,bool_t enable_align);
#endif // AFFINETRANSACTION_H