Rate This Document
Findability
Accuracy
Completeness
Readability

Add

Adds two images.

The function interface is declared as follows:

HmppResult HMPPI_Add_32f_C1R(const float* pSrc1, int src1Step, const float* pSrc2, int src2Step, float* pDst, int dstStep, HmppiSize roiSize);

HmppResult HMPPI_Add_32f_C3R(const float* pSrc1, int src1Step, const float* pSrc2, int src2Step, float* pDst, int dstStep, HmppiSize roiSize);

Parameters

Parameter

Description

Value Range

Input/Output

pSrc1

Pointer to the ROI of source image 1

The value cannot be NULL.

Input

src1Step

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

The value must be zero or a positive integer.

Input

pSrc2

Pointer to the ROI of source image 2

The value cannot be NULL.

Input

src2Step

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

The value must be zero or a positive integer.

Input

pDst

Pointer to the destination 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

roiSize

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

roiSize.width ∈ (0, INT_MAX], roiSize.height ∈ (0, INT_MAX]

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 max is NULL.

HMPP_STS_STEP_ERR

The value of srcStep is less than or equal to 0.

HMPP_STS_SIZE_ERR

The value of roiSize.width or roiSize.height is less than or equal to 0.

Example

#define BUFFER_SIZE_T 10
void AddExample(void)
{
    float src1[BUFFER_SIZE_T] = {1.64, 1.63, -1.09, 0.71, -3.20, -0.43, 0.41, -4.83, 5.36, -4.40};
    float src2[BUFFER_SIZE_T] = {9.54, 3.77, 2.1, -3.77, 1.59, 2.9, -3.77, 8.91, 0.19, -0.11};
    float dst[BUFFER_SIZE_T];
    (void)HMPPS_Zero_32f(dst, BUFFER_SIZE_T); // Initialize all elements of dst to 0.
    HmppiSize roiSize = {2, 5};
    HmppResult result = HMPPI_Add_32f_C1R(src1, 2 * sizeof(float), src2, 2 * sizeof(float),
        dst, 2 * sizeof(float), roiSize);
    printf("result = %d\n", result);
    if (result != HMPP_STS_NO_ERR) {
        return;
    }
    printf("dst =");
    for (int i = 0; i < BUFFER_SIZE_T; i++) {
        printf(" %.2f", dst[i]);
    }
    printf("\n");
}
int main() {
    AddExample();
    return 0;
}

Output:

result = 0
dst = 11.18 5.40 1.01 -3.06 -1.61 2.47 -3.36 4.08 5.55 -4.51