user_12
user_12

Reputation: 53

Set and get data from vx_image

I have two vx_image's src and dst, I need to get each pixel from the src vx_image and do some operation and set that to dst vx image.

vx_image src;
vx_image dst;

I couldn't find the proper documentation for doing this. May I know how to do this ?.

Thank you.

Upvotes: 3

Views: 1296

Answers (2)

vinograd47
vinograd47

Reputation: 6420

There is a section "Host Memory Data Object Access Patterns" in the specification : https://www.khronos.org/registry/OpenVX/specs/1.2/html/page_design.html#sec_host_memory

It shows examples of accessing different data objects (includeing images).

Upvotes: 1

user_12
user_12

Reputation: 53

 foo (vx_image & vxSrcImg, vx_image vxDstImg)
 {
        vx_rectangle_t rect1;
        vx_rectangle_t rect2;

        vxGetValidRegionImage(vxSrcImg, &rect1);
        vxGetValidRegionImage(vxDstImg, &rect2);

        vx_imagepatch_addressing_t addr1;
        vx_imagepatch_addressing_t addr2;

        vx_uint8 *ptr1 = NULL;
        vx_uint8 *ptr2 = NULL;
        vx_uint32  plane1;
        vx_uint32  plane2;

        vx_status status1 = vxAccessImagePatch(vxSrcImg, &rect1, plane1, &addr1, &ptr1, VX_READ_AND_WRITE);
        vx_status status2 = vxAccessImagePatch(vxDstImg, &rect2, plane2, &addr2, &ptr2, VX_READ_AND_WRITE);


        int i=0; 
        for (i = 0; i < addr1.dim_x * addr1.dim_y; i++)
        { 
          ptr2[i] = myPixelOperation (ptr1[i]);
        }

        // Rectangle needs to be commit back to the image post operation.
        vx_status status3 = vxCommitImagePatch(vxSrcImg, &rect1, plane1, &addr1, &ptr1);
        vx_status status4 = vxCommitImagePatch(vxDstImg, &rect2, plane2, &addr2, &ptr2);
  }

Upvotes: 2

Related Questions