This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

J721S2XSOMXEVM: vxObjectArray with existing vx_reference

Part Number: J721S2XSOMXEVM


Tool/software:

Hello Ti experts,

Is there any way to map or assign already existing vx_reference to vxObjectArray?

Or If possible, even a way to create vxObjectArray with exsting vx_reference would be okay.

Regards,

Juhyun

  • Hi Kim,

      Create object array from the meta data of the reference, using createObjectarray api and then get reference of element from the object array using vxGetObjectArrayItem api and then depending on the reference type use map or copy api to assign the existing reference.

    Regards,

    Gokul

  • Hi Gokul,

    Thanks for the answer.

    So if the type is vx_image or vx_tensor, then how should I map or assign existing vx_reference to vxObjectArray via the element fetched by vxGetObjectArrayItem?

    And the copy for the assign should be shallow, not deep copy.

    Regards,

    Juhyun

  • Hi Kim,

      Can you elaborate on shallow copy ?


    Regards,

    Gokul

  • I meant shallow copy as general terminology that means copying only meta data and buffer pointer, which doesn't involve actual memory copy of the buffer.

    Usually we use that with pointer assignment as you know.

    Regards,

    Juhyun

  • Hi Juhyun,

      Thanks for the reply.
      Use the element as dst and the existing reference as src in the following code snippet,

    vx_status copyImageHandles(vx_image src, vx_image dst)
    {
        vx_status status = VX_SUCCESS;
        void           *addr[TIVX_IMAGE_MAX_PLANES] = {NULL};
        uint32_t        size[TIVX_IMAGE_MAX_PLANES];
        uint32_t        num_entries;
    
        status = tivxReferenceExportHandle((vx_reference)src,
                                             addr,
                                             size,
                                             max_entries,
                                             &num_entries);
    
        if(status==VX_SUCCESS)
        {
            status = tivxReferenceImportHandle((vx_reference)dst,
                                               (const void **)addr,
                                               (const uint32_t *)size,
                                               num_entries);
        }
    
        return status;
    }

    this will work if dst is already allocated (either by vxMapImagePatch or vxVerifyGraph).

    Regards,

    Gokul

  • Hi Gokul,

    I appreciate the code snippet, I get the idea and will try it soon.

    Regards,

    Juhyun

  • Hi Gokul,

    I tested the code you shared, and checked it worked as I expected.

    I appreciate your support, that's exactly what I wanted.

    Regards,

    Juhyun