Set and get data from vx_image

笑着哭i 提交于 2019-12-10 19:22:34

问题


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.


回答1:


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).




回答2:


 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);
  }


来源:https://stackoverflow.com/questions/45080883/set-and-get-data-from-vx-image

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!