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.

TDA4VM: Is there a difference between xv_image objects got by vxCreateImageFromHandle and xCreateImage?

Part Number: TDA4VM

Hi TI experts,

I made 2 simple pipeline.

1. create two vx_image by vxCreateImage(input and output), load data to input image from file, connect to tivxVpacMscScaleNode, start vxVerifyGraph, start vxProcessGraph, and save output image to file. All works.

2. create one vx_image by vxCreateImage(output) and one by vxCreateImageFromHandle(input), connect to tivxVpacMscScaleNode, start vxVerifyGraph, start vxProcessGraph, and save output image to file.

In second pipeline output file is incorrect. I checked input vx_image by saving to a file. This file was correct.  And i have question: what should  i do for using image get by vxCreateImageFromHandle with nodes?

  • There is same behavior and for tivxImgPreProcNode. Should I add any information to help you?

  • Hi,

    Could you please confirm if the image is created correctly using vxCreateImageFromHandle?

    You could refer the tiovx tutorial vx_tutorial_image_crop_roi.c, present in the SDK at ${PSDKRA}/tiovx/tutorial/ch02_image/

    Here the image used is being created using vxCreateImageFromHandle.

    Regards,
    Nikhil

  • Hi, Hikhil Dason

    Thank for your answer!

    Of course i check  vx_image, that created by vxCreateImageFromHandle with the function vxGetStatus. And i have checked this image with a calling function  vxMapImagePatch and a writing data to file. 

    Do you mean to use a function "show_image_attributes"?

    struct RawImageObj {
        void* mem;
        size_t size;
        uint32_t width;
        uint32_t height;
    };
    
    static void fillAdderAndMemPtr(RawImageObj img, vx_imagepatch_addressing_t* ref_addr, void** ref_ptrs)
    {
        vx_int32 stride = img.width;
        ref_addr[0].dim_x    = img.width;
        ref_addr[0].dim_y    = img.height;
        ref_addr[0].stride_x = sizeof(vx_uint8);
        ref_addr[0].stride_y = stride * sizeof(vx_uint8);
    
        ref_ptrs[0] = img.mem;
    
        ref_addr[1].dim_x    = img.width / 2;
        ref_addr[1].dim_y    = img.height / 2;
        ref_addr[1].stride_x = 2 * sizeof(vx_uint8);
        ref_addr[1].stride_y = stride * sizeof(vx_uint8);
    
        ref_ptrs[1] = (vx_uint8*)((vx_uint8*)img.mem + img.height * stride * sizeof(vx_uint8));
    }
    
    VxImage::VxImage(VxContext &context, RawImageObj obj) {
        const uint32_t vx_plane_max = 4;
        vx_imagepatch_addressing_t ref_addr[vx_plane_max] = {};
        void* ref_ptrs[vx_plane_max] = {};
    
        fillAdderAndMemPtr(obj, ref_addr, ref_ptrs);
    
        img_ = std::make_unique<ImageImp>(vxCreateImageFromHandle(context.get(), VX_DF_IMAGE_NV12, ref_addr, ref_ptrs, VX_MEMORY_TYPE_HOST), TypeImage::k_handle);
        if (vxGetStatus((vx_reference)(img_->get())) != VX_SUCCESS) {
            throw std::invalid_argument("Bad ref for a creating image with handling memory");
        }
        width_ = obj.width;
        height_ = obj.height;
    }

  • Hi,

    Sorry, do you mean you are reading back the data in the image using vxMapImagePatch() and comparing it with the data in the ref_ptrs?

    Do you mean to use a function "show_image_attributes"?

    Yes, could you print all the attributes of the image as shown in this function and share it with me?

    Regards,
    Nikhil

  • Hi.

    Output:

    VX_TYPE_IMAGE: image_98, 1920 x 1080, 2 plane(s), 3110400 B, VX_DF_IMAGE_NV12 VX_COLOR_SPACE_BT709 VX_CHANNEL_RANGE_FULL VX_MEMORY_TYPE_NONE, 1 refs

    Sorry, do you mean you are reading back the data in the image using vxMapImagePatch() and comparing it with the data in the ref_ptrs?

    Yes. I write data from ref_ptrs to file, and file is correct.

    I have checked an another type of image

            cv::Mat matBGR = cv::Mat::zeros(cv::Size(amount_col, amount_row), CV_8UC1);
            vx_imagepatch_addressing_t addr;
            addr.dim_x = matBGR.cols;
            addr.dim_y = matBGR.rows;
            addr.stride_x = matBGR.elemSize();
            addr.stride_y = matBGR.step;
            void *ptr[] = {matBGR.data};
    
            vx_image image = vxCreateImageFromHandle(context, VX_DF_IMAGE_U8, &addr, ptr, VX_MEMORY_TYPE_HOST);
    
            show_image_attributes(image);

    Output:

    VX_TYPE_IMAGE: image_70, 640 x 480, 1 plane(s), 307200 B, VX_DF_IMAGE_U8 VX_COLOR_SPACE_NONE VX_CHANNEL_RANGE_FULL VX_MEMORY_TYPE_NONE, 1 refs

    Can be a reason of my problem,  that a memory type is "VX_MEMORY_TYPE_NONE"?

  •  Hi, Nikhil Dasan

    Should I add any information to help you?

  • Hi,

    VX_MEMORY_TYPE_NONE is being returned as it was hardcoded to the same in the vxQueryImage(), this is a bug in the function, but this shouldn't affect your implementation.

    n second pipeline output file is incorrect

    Could you brief me what is the error that you are observing?
    Does your graph consist of only tivxVpacMscScaleNode() ?

    Are you seeing any error in the application logs or any error being observed from the remote core logs?
    Could you share me the logs of "source ./vision_apps_init.sh" and your application logs?

    Regards,
    Nikhil

  • Hi,

    Could you brief me what is the error that you are observing?

    I checked a output image content before a call of vxProcessGraph and after. And image content has not been change.

    Does your graph consist of only tivxVpacMscScaleNode() ?

    Yes

    Are you seeing any error in the application logs or any error being observed from the remote core logs?

    No

    Could you share me the logs of "source ./vision_apps_init.sh" and your application logs?

    APP: Init ... !!!
    MEM: Init ... !!!
    MEM: Initialized DMA HEAP (fd=9) !!!
    MEM: Init ... Done !!!
    IPC: Init ... !!!
    IPC: Init ... Done !!!
    REMOTE_SERVICE: Init ... !!!
    REMOTE_SERVICE: Init ... Done !!!
    1363716.561430 s: GTC Frequency = 200 MHz
    APP: Init ... Done !!!
    1363716.561510 s:  VX_ZONE_INIT:Enabled
    1363716.561519 s:  VX_ZONE_ERROR:Enabled
    1363716.561524 s:  VX_ZONE_WARNING:Enabled
    1363716.562102 s:  VX_ZONE_INIT:[tivxInitLocal:130] Initialization Done !!!
    1363716.562325 s:  VX_ZONE_INIT:[tivxHostInitLocal:86] Initialization Done for HOST !!!
    TDA4VMPlatform: Platform is initialized
    Second:Got buffer stream1 0xffff78057ce0 size 3133440
    Amount 1. Time 0.113181. FPS 8.8317
    1363716.762587 s:  VX_ZONE_INIT:[tivxHostDeInitLocal:100] De-Initialization Done for HOST !!!
    1363716.766089 s:  VX_ZONE_INIT:[tivxDeInitLocal:193] De-Initialization Done !!!
    APP: Deinit ... !!!
    REMOTE_SERVICE: Deinit ... !!!
    REMOTE_SERVICE: Deinit ... Done !!!
    IPC: Deinit ... !!!
    IPC: DeInit ... Done !!!
    MEM: Deinit ... !!!
    MEM: Alloc's: 3 alloc's of 395832 bytes 
    MEM: Free's : 3 free's  of 395832 bytes 
    MEM: Open's : 0 allocs  of 0 bytes 
    MEM: Deinit ... Done !!!
    APP: Deinit ... Done !!!
    TDA4VMPlatform: Platform deinitialized
    

  • Hi,

    I have checked different types memory(static and dynamic). And It doesn't matter.

    The output image content doesn't change after a call vxProcessGraph.

  • Hi.

    I found a reason of my problem.

    When i have used the function tivxMemAlloc for an allocation memory, a pipeline returned a correct output image.