我要评分
获取效率
正确性
完整性
易理解

Mirror

Mirrors an image along an axis specified by the enumeration parameter flip.

The function interface declaration is as follows:

  • Not-in-place operation:

    HmppResult HMPPI_Mirror_8u_C1R(const uint8_t *src, int32_t srcStep, uint8_t *dst, int32_t dstStep, HmppiSize roiSize, HmppiAxis flip);

    HmppResult HMPPI_Mirror_8u_C3R(const uint8_t *src, int32_t srcStep, uint8_t *dst, int32_t dstStep, HmppiSize roiSize, HmppiAxis flip);

    HmppResult HMPPI_Mirror_8u_C4R(const uint8_t *src, int32_t srcStep, uint8_t *dst, int32_t dstStep, HmppiSize roiSize, HmppiAxis flip);

    HmppResult HMPPI_Mirror_8u_AC4R(const uint8_t *src, int32_t srcStep, uint8_t *dst, int32_t dstStep, HmppiSize roiSize, HmppiAxis flip);

    HmppResult HMPPI_Mirror_16u_C1R(const uint16_t *src, int32_t srcStep, uint16_t *dst, int32_t dstStep, HmppiSize roiSize, HmppiAxis flip);

    HmppResult HMPPI_Mirror_16u_C3R(const uint16_t *src, int32_t srcStep, uint16_t *dst, int32_t dstStep, HmppiSize roiSize, HmppiAxis flip);

    HmppResult HMPPI_Mirror_16u_C4R(const uint16_t *src, int32_t srcStep, uint16_t *dst, int32_t dstStep, HmppiSize roiSize, HmppiAxis flip);

    HmppResult HMPPI_Mirror_16u_AC4R(const uint16_t *src, int32_t srcStep, uint16_t *dst, int32_t dstStep, HmppiSize roiSize, HmppiAxis flip);

    HmppResult HMPPI_Mirror_16s_C1R(const int16_t *src, int32_t srcStep, int16_t *dst, int32_t dstStep, HmppiSize roiSize, HmppiAxis flip);

    HmppResult HMPPI_Mirror_16s_C3R(const int16_t *src, int32_t srcStep, int16_t *dst, int32_t dstStep, HmppiSize roiSize, HmppiAxis flip);

    HmppResult HMPPI_Mirror_16s_C4R(const int16_t *src, int32_t srcStep, int16_t *dst, int32_t dstStep, HmppiSize roiSize, HmppiAxis flip);

    HmppResult HMPPI_Mirror_16s_AC4R(const int16_t *src, int32_t srcStep, int16_t *dst, int32_t dstStep, HmppiSize roiSize, HmppiAxis flip);

    HmppResult HMPPI_Mirror_32s_C1R(const int32_t *src, int32_t srcStep, int32_t *dst, int32_t dstStep, HmppiSize roiSize, HmppiAxis flip);

    HmppResult HMPPI_Mirror_32s_C3R(const int32_t *src, int32_t srcStep, int32_t *dst, int32_t dstStep, HmppiSize roiSize, HmppiAxis flip);

    HmppResult HMPPI_Mirror_32s_C4R(const int32_t *src, int32_t srcStep, int32_t *dst, int32_t dstStep, HmppiSize roiSize, HmppiAxis flip);

    HmppResult HMPPI_Mirror_32s_AC4R(const int32_t *src, int32_t srcStep, int32_t *dst, int32_t dstStep, HmppiSize roiSize, HmppiAxis flip);

    HmppResult HMPPI_Mirror_32f_C1R(const float *src, int32_t srcStep, float *dst, int32_t dstStep, HmppiSize roiSize, HmppiAxis flip);

    HmppResult HMPPI_Mirror_32f_C3R(const float *src, int32_t srcStep, float *dst, int32_t dstStep, HmppiSize roiSize, HmppiAxis flip);

    HmppResult HMPPI_Mirror_32f_C4R(const float *src, int32_t srcStep, float *dst, int32_t dstStep, HmppiSize roiSize, HmppiAxis flip);

    HmppResult HMPPI_Mirror_32f_AC4R(const float *src, int32_t srcStep, float *dst, int32_t dstStep, HmppiSize roiSize, HmppiAxis flip);

  • In-place operation:

    HmppResult HMPPI_Mirror_8u_C1IR(uint8_t* srcDst, int32_t srcDstStep, HmppiSize roiSize, HmppiAxis flip);

    HmppResult HMPPI_Mirror_8u_C3IR(uint8_t* srcDst, int32_t srcDstStep, HmppiSize roiSize, HmppiAxis flip);

    HmppResult HMPPI_Mirror_8u_C4IR(uint8_t* srcDst, int32_t srcDstStep, HmppiSize roiSize, HmppiAxis flip);

    HmppResult HMPPI_Mirror_8u_AC4IR(uint8_t* srcDst, int32_t srcDstStep, HmppiSize roiSize, HmppiAxis flip);

    HmppResult HMPPI_Mirror_16u_C1IR(uint16_t* srcDst, int32_t srcDstStep, HmppiSize roiSize, HmppiAxis flip);

    HmppResult HMPPI_Mirror_16u_C3IR(uint16_t* srcDst, int32_t srcDstStep, HmppiSize roiSize, HmppiAxis flip);

    HmppResult HMPPI_Mirror_16u_C4IR(uint16_t* srcDst, int32_t srcDstStep, HmppiSize roiSize, HmppiAxis flip);

    HmppResult HMPPI_Mirror_16u_AC4IR(uint16_t* srcDst, int32_t srcDstStep, HmppiSize roiSize, HmppiAxis flip);

    HmppResult HMPPI_Mirror_16s_C1IR(int16_t* srcDst, int32_t srcDstStep, HmppiSize roiSize, HmppiAxis flip);

    HmppResult HMPPI_Mirror_16s_C3IR(int16_t* srcDst, int32_t srcDstStep, HmppiSize roiSize, HmppiAxis flip);

    HmppResult HMPPI_Mirror_16s_C4IR(int16_t* srcDst, int32_t srcDstStep, HmppiSize roiSize, HmppiAxis flip);

    HmppResult HMPPI_Mirror_16s_AC4IR(int16_t* srcDst, int32_t srcDstStep, HmppiSize roiSize, HmppiAxis flip);

    HmppResult HMPPI_Mirror_32s_C1IR(int32_t* srcDst, int32_t srcDstStep, HmppiSize roiSize, HmppiAxis flip);

    HmppResult HMPPI_Mirror_32s_C3IR(int32_t* srcDst, int32_t srcDstStep, HmppiSize roiSize, HmppiAxis flip);

    HmppResult HMPPI_Mirror_32s_C4IR(int32_t* srcDst, int32_t srcDstStep, HmppiSize roiSize, HmppiAxis flip);

    HmppResult HMPPI_Mirror_32s_AC4IR(int32_t* srcDst, int32_t srcDstStep, HmppiSize roiSize, HmppiAxis flip);

    HmppResult HMPPI_Mirror_32f_C1IR(float* srcDst, int32_t srcDstStep, HmppiSize roiSize, HmppiAxis flip);

    HmppResult HMPPI_Mirror_32f_C3IR(float* srcDst, int32_t srcDstStep, HmppiSize roiSize, HmppiAxis flip);

    HmppResult HMPPI_Mirror_32f_C4IR(float* srcDst, int32_t srcDstStep, HmppiSize roiSize, HmppiAxis flip);

    HmppResult HMPPI_Mirror_32f_AC4IR(float* srcDst, int32_t srcDstStep, HmppiSize roiSize, HmppiAxis flip);

Parameters

Parameter

Description

Value Range

Input/Output

src

Pointer to the source image. This array stores the color data of the source planar image.

The value cannot be NULL.

Input

srcStep

Distance between starts of consecutive lines in the source image, in bytes

The value must be zero or a positive integer.

Input

dst

Pointer to the destination image ROI. This array stores the color data of the destination planar image.

The value cannot be NULL.

Output

dstStep

Distance between starts of consecutive lines in the destination image, in bytes

The value must be zero or a positive integer.

Input

srcDst

Pointer to the source and destination buffers

The value cannot be NULL.

Input/Output

srcDstStep

Distance between starts of consecutive lines in the source and destination images, in bytes

The value must be zero or a positive integer.

Input

flip

Specifies the axis to mirror the image along.

HMPP_AXS_HORIZONTAL: horizontal axis

HMPP_AXS_VERTICAL: vertical axis

HMPP_AXS_BOTH: both horizontal and vertical axes

HMPP_AXS_45: 45-degree rotated axis, applicable only to not-in-place operation for the C1R type

HMPP_AXS_135: 135-degree rotated axis, applicable only to not-in-place operation for the C1R type

Input

roiSize

Size of the ROI of the source and destination images, in pixels

The value must be zero or a positive integer.

Input

Return Value

  • Success: HMPP_STS_NO_ERR
  • Failure: An error code is returned.

Error Codes

Error Code

Description

HMPP_STS_NULL_PTR_ERR

The value of src or dst is NULL.

HMPP_STS_SIZE_ERR

The value of roiSize is 0 or negative.

HMPP_STS_STEP_ERR

The value of srcStep or dstStep is 0 or negative.

HMPP_STS_ROI_ERR

roiSize.width x Number of channels x Number of bytes occupied by the data type > Step

HMPP_STS_NOT_EVEN_STEP_ERR

The value of srcStep or dstStep cannot be exactly divided by the byte length of the data type to which src or dst belongs.

HMPP_STS_MIRROR_FLIP_ERR

The value of flip is invalid.

HMPP_STS_NO_ERR

No error occurs.

Example

#define SRC_BUFFER_SIZE_T 36
#define DST_BUFFER_SIZE_T 36

void PrintResult(HmppResult result, uint8_t *dst, int32_t dstStep)
{
    printf("result = %d \ndst = ", result);
    if (result != HMPP_STS_NO_ERR) {
        printf("result error: %d\n", result);
    }
    int32_t dstWidth = dstStep / sizeof(uint8_t);
    for (int32_t i = 0; i < DST_BUFFER_SIZE_T; i++) {
        if( i % dstWidth == 0 ){
            printf("\n");
        }
        printf("%3d ",dst[i]);
    }
    printf("\n\n");
}

void TestExample()
{
    HmppiSize roi = { 4, 4 };
    uint8_t data[SRC_BUFFER_SIZE_T] = {
        53, 111, 2, 61, 6, 12,
        77, 184, 5, 99, 3,  4,
        41, 233, 1, 27, 5,  6,
        62, 157, 6, 80, 7,  8
    };

    const uint8_t *src = data;
    int32_t srcStep = 6 * sizeof(uint8_t);
    uint8_t dst[DST_BUFFER_SIZE_T] = { 0 };
    int32_t dstStep = 8 * sizeof(uint8_t);
    HmppResult result1 = HMPPI_Mirror_8u_C1R(src, srcStep, dst, dstStep, roi, HMPP_AXS_45);
    PrintResult(result1, dst, dstStep);

    int32_t srcDstStep = 6 * sizeof(uint8_t);
    HmppResult result2 = HMPPI_Mirror_8u_C1IR(data, srcDstStep, roi, HMPP_AXS_BOTH);
    PrintResult(result2, data, dstStep);
}

int main(void)
{
    TestExample();
    return 0;
}

Output:

result = 0 
dst = 
 53  77  41  62   0   0   0   0 
111 184 233 157   0   0   0   0 
  2   5   1   6   0   0   0   0 
 61  99  27  80   0   0   0   0 
  0   0   0   0 

result = 0 
dst = 
 80   6 157  62   6  12 
 27   1 233  41   3   4 
 99   5 184  77   5   6 
 61   2 111  53   7   8 
  0   0   0   0   0   0 
  0   0   0   0   0   0