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.

Compiler/TDA4VMXEVM: TDA4 app_multi_cam.c save all channel images of viss node

Part Number: TDA4VMXEVM

Tool/software: TI C/C++ Compiler

Hi,

I am working on app_multi_cam.c demo on PSDK_06_02_00_21 SDK.

My application runs on two AR0233 camera inputs and I wish to save output images of VISS node of these two cameras.

But if try to save out_viss_image as blow, it could only save image of one camera channel. 

I wish to know how to save out_viss_image of both channels

 

thanks!

 

case NODE_VISS_COMPLETED_EVENT:
vxGraphParameterDequeueDoneRef(
obj->graph,
obj->viss_gp_index,
(vx_reference*)&out_viss_image,
1,
&num_refs);

vxGraphParameterEnqueueReadyRef(
obj->graph,
obj->viss_gp_index,
(vx_reference*)&out_viss_image,
1);
if (obj->write_file)
{
save_debug_u8_images(obj, out_viss_image);
save_debug_images(obj, out_capture_frames);
obj->write_file = 0;
}

 

  • Can you please share your implementation of save_debug_u8_images?

    Have you made any other changes to app_multi_cam app?

  • Thanks for your response.

    I only make a few change of app_multi_cam.c in order to save U8 images of viss_node output.

    1. I change all VX_DF_IMAGE_NV12 in  app_multi_cam.c to VX_DF_IMAGE_U8

    2. changed viss_params.mux_output2 from 4 to 0

    viss_params.mux_output2 = 0;

    3. add save_debug_u8_images() functions in void app_run_graph(MultiCamAppObj *obj)

    if (obj->write_file)
    {
    save_debug_u8_images(obj, out_viss_image);
    save_debug_images(obj, out_capture_frames);
    obj->write_file = 0;
    }


    implementation of save_debug_u8_images(obj, out_viss_image) code:

    vx_int32 write_output_image_u8(char * file_name, vx_image out_image)
    {
    vx_status status = VX_SUCCESS;
    FILE * fp = fopen(file_name, "wb");
    uint32_t data_size = 0;
    vx_uint32 width, height;
    vx_df_image df;
    vx_imagepatch_addressing_t image_addr;
    vx_rectangle_t rect;
    vx_uint32 num_bytes_written_to_file;
    vx_map_id map_id1;
    void *data_ptr1;

    if(!fp)
    {
    APP_PRINTF("Unable to open file %s\n", file_name);
    return -1;
    }

    vxQueryImage(out_image, VX_IMAGE_WIDTH, &width, sizeof(vx_uint32));
    vxQueryImage(out_image, VX_IMAGE_HEIGHT, &height, sizeof(vx_uint32));
    vxQueryImage(out_image, VX_IMAGE_FORMAT, &df, sizeof(vx_df_image));

    printf("out width = %d\n", width);
    printf("out height = %d\n", height);
    printf("out format = %d\n", df);

    rect.start_x = 0;
    rect.start_y = 0;
    rect.end_x = width;
    rect.end_y = height;
    data_size = width * height;

    status = vxMapImagePatch(out_image,
    &rect,
    0,
    &map_id1,
    &image_addr,
    &data_ptr1,
    VX_WRITE_ONLY,
    VX_MEMORY_TYPE_HOST,
    VX_NOGAP_X
    );

    if (VX_SUCCESS == status)
    {
    num_bytes_written_to_file = fwrite(data_ptr1, 1, width*height, fp);
    fflush(fp);
    }

    vxUnmapImagePatch(out_image, map_id1);
    fclose(fp);

    return num_bytes_written_to_file;
    }
    vx_status save_debug_u8_images(MultiCamAppObj *obj, vx_image out_img)
    {
    vx_uint32 buf_id = 0;
    char image_fname[APP_MAX_FILE_PATH];
    char * test_data_path = app_get_test_file_path();
    char failsafe_test_data_path[3] = "./";
    if(NULL == test_data_path)
    {
    printf("Test data path is NULL. Defaulting to current folder \n");
    test_data_path = failsafe_test_data_path;
    }

    snprintf(image_fname, APP_MAX_FILE_PATH, "%s/%03d_%s%1d%s", test_data_path, file_num, "CAM_u8", buf_id, ".raw");
    printf("writing viss channel %d to file %s...\n", buf_id, image_fname);
    write_output_image_u8(image_fname, out_img);

    file_num++;

    return VX_SUCCESS;
    }
  • Please refer to the function save_debug_images. It has a loop which goes through all the enabled cameras

        for(buf_id=0; buf_id<obj->num_cameras_enabled; buf_id++)

    your function save_debug_u8_images does not have this loop. Therefore it capturing only the first camera output.

  • I have already try this but it did not work and caused many errors while saving images.

    I realized that app_multi_cam.c only have one capture node to get image from multi sensors, yet use vxReplicateNode to create viss_node for each camera.

    Dose that means that I have to create two different NODE_VISS_COMPLETED_EVENT in run_graph to get images from different channel? If so, how to change the code ?

    vxReplicateNode(obj->graph, obj->node_aewb, aewb_prms_replicate, 6u);

     

    The error log and my code of save_debug_u8_images() are list as below:

    writing viss channel 0 to file .//000_CAM_u80.raw...
        35.630929 s:  VX_ZONE_ERROR:[vxQueryImage:1611] vxQueryImage: invalid image reference
        35.630940 s:  VX_ZONE_ERROR:[vxQueryImage:1611] vxQueryImage: invalid image reference
        35.630958 s:  VX_ZONE_ERROR:[vxQueryImage:1611] vxQueryImage: invalid image reference
    out width =  1074791425
    out height =  1074791425
    out format =  1074791425
        35.631004 s:  VX_ZONE_ERROR:[ownCopyAndMapCheckParams:600] ownCopyAndMapCheckParams: image is not valid
        35.631018 s:  VX_ZONE_ERROR:[vxUnmapImagePatch:2005] vxUnmapImagePatch: invalid image reference
        35.631040 s:  VX_ZONE_ERROR:[ownReleaseReferenceInt:299] ownReleaseReferenceInt: Invalid reference
    writing viss channel 1 to file .//000_CAM_u81.raw...
        35.631093 s:  VX_ZONE_ERROR:[vxQueryImage:1611] vxQueryImage: invalid image reference
        35.631111 s:  VX_ZONE_ERROR:[vxQueryImage:1611] vxQueryImage: invalid image reference
        35.631149 s:  VX_ZONE_ERROR:[vxQueryImage:1611] vxQueryImage: invalid image reference
    out width =  1074791425
    out height =  1074791425
    out format =  1074791425
        35.631191 s:  VX_ZONE_ERROR:[ownCopyAndMapCheckParams:600] ownCopyAndMapCheckParams: image is not valid
        35.631205 s:  VX_ZONE_ERROR:[vxUnmapImagePatch:2005] vxUnmapImagePatch: invalid image reference
        35.631221 s:  VX_ZONE_ERROR:[ownReleaseReferenceInt:299] ownReleaseReferenceInt: Invalid reference



    vx_status save_debug_u8_images(MultiCamAppObj *obj, vx_object_array out_img)
    {
    vx_uint32 buf_id = 0;
    char image_fname[APP_MAX_FILE_PATH];
    char * test_data_path = app_get_test_file_path();
    char failsafe_test_data_path[3] = "./";
    if(NULL == test_data_path)
    {
    printf("Test data path is NULL. Defaulting to current folder \n");
    test_data_path = failsafe_test_data_path;
    }

    for(buf_id=0; buf_id<obj->num_cameras_enabled; buf_id++)
    {
    vx_image out_viss_image;
    snprintf(image_fname, APP_MAX_FILE_PATH, "%s/%03d_%s%1d%s", test_data_path, file_num, "CAM_u8", buf_id, ".raw");
    printf("writing viss channel %d to file %s...\n", buf_id, image_fname);
    out_viss_image = (vx_image)vxGetObjectArrayItem(out_img, buf_id);
    write_output_image_u8(image_fname, out_viss_image);
    vxReleaseImage(&out_viss_image);
    }

    file_num++;

    return VX_SUCCESS;
    }


  • Hello Wesley,

    You can make use of the API tivxGetReferenceParent linked to below.  When you get the image from the first channel, you can pass this "child reference" to the tivxGetReferenceParent API and retrieve the "parent reference" which is the object array.  From the object array, you can get the specific channel that you could like via the vxGetObjectArrayItem API.

    http://software-dl.ti.com/jacinto7/esd/processor-sdk-rtos-jacinto7/latest/exports/docs/tiovx/docs/user_guide/group__group__tivx__ext__host.html#ga5ffdd2559e8e8ca61e5ee61d7a585d54

    Regards,

    Lucas

  • Hi lucas,

    This API resolved my issue, thanks a lot!