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: Does the error frame need to be a raw frame?

Part Number: TDA4VM

Hi there,

I have a system with YUV sensors, and I want the multi-camera demo to continue streaming when one of the sensors stops.

I believe that I need to initialize the error_frame_raw_image member of the capture object.

The following function call in create_error_detection_frame:

captureObj->error_frame_raw_image = tivxCreateRawImage(context, &(sensorParams->sensorInfo.raw_params));

fails with this error message:

VX_ZONE_ERROR:[ownIsValidCreateParams:72] invalid pixel_container for exposure index 0.

So, it looks like tivxCreateRawImage doesn't like the VX_DF_IMAGE_UYVY format.

I looked at replacing the tivxCreateRawImage with vxCreateImage, but the types returned by these two functions don't seem to have anything in common.

Is there a straight way to add YUV support to create_error_detection_frame that maybe I missed?

Thanks.

  • I figured it out.

    Here's a patch, in case anyone needs it:

    rom 10ad39ed6b8cd86c6aad2f3538c325c121ce4559 Mon Sep 17 00:00:00 2001
    From: Catalin Petrescu <cpetrescu@d3engineering.com>
    Date: Wed, 16 Jun 2021 10:35:02 -0400
    Subject: [PATCH] Added YUV support to create_error_detection_frame.
    
    ---
     modules/include/app_capture_module.h |  1 +
     modules/include/app_sensor_module.h  |  5 +++
     modules/src/app_capture_module.c     | 58 ++++++++++++++++++----------
     3 files changed, 43 insertions(+), 21 deletions(-)
    
    diff --git a/modules/include/app_capture_module.h b/modules/include/app_capture_module.h
    index bf8c6e7..230a43c 100644
    --- a/modules/include/app_capture_module.h
    +++ b/modules/include/app_capture_module.h
    @@ -92,6 +92,7 @@ typedef struct {
         vx_char objName[APP_MODULES_MAX_OBJ_NAME_SIZE];
    
         tivx_raw_image error_frame_raw_image;
    +    vx_image error_frame_image;
         vx_uint8 enable_error_detection;
         vx_uint32 capture_format;
     }CaptureObj;
    diff --git a/modules/include/app_sensor_module.h b/modules/include/app_sensor_module.h
    index f6df556..f314bdf 100644
    --- a/modules/include/app_sensor_module.h
    +++ b/modules/include/app_sensor_module.h
    @@ -68,6 +68,11 @@
     #define APP_SENSOR_FEATURE_CFG_UC1 (1)
     #define APP_SENSOR_FEATURE_CFG_UC2 (1)
    
    +enum {
    +    APP_SENSOR_OUT_FORMAT_RAW = 0,
    +    APP_SENSOR_OUT_FORMAT_YUV
    +};
    +
     typedef struct {
         IssSensor_CreateParams sensorParams;
    
    diff --git a/modules/src/app_capture_module.c b/modules/src/app_capture_module.c
    index 26db9fd..f5740a9 100644
    --- a/modules/src/app_capture_module.c
    +++ b/modules/src/app_capture_module.c
    @@ -190,14 +190,6 @@ static vx_status create_error_detection_frame(vx_context context, CaptureObj *ca
         vx_status status = VX_SUCCESS;
         IssSensor_CreateParams *sensorParams = &sensorObj->sensorParams;
    
    -    /*Error detection is currently enabled only for RAW input*/
    -
    -    /* If in test mode, send the test frame */
    -    if(0 != captureObj->capture_format)
    -    {
    -        captureObj->enable_error_detection = 0;
    -    }
    -
         if (captureObj->test_mode)
         {
             char test_data_paths[2][255] = {"/opt/vision_apps/test_data/psdkra/app_single_cam/IMX390_001/input2.raw",
    @@ -234,28 +226,46 @@ static vx_status create_error_detection_frame(vx_context context, CaptureObj *ca
                 vx_rectangle_t rect;
                 vx_imagepatch_addressing_t image_addr;
                 void * data_ptr;
    +            vx_uint32 width;
    +            vx_uint32 height;
    +            vx_df_image format;
    
                 rect.start_x = 0;
                 rect.start_y = 0;
                 rect.end_x = sensorParams->sensorInfo.raw_params.width;
                 rect.end_y = sensorParams->sensorInfo.raw_params.height;
    
    -            captureObj->error_frame_raw_image = tivxCreateRawImage(context, &(sensorParams->sensorInfo.raw_params));
    +            if (captureObj->capture_format == APP_SENSOR_OUT_FORMAT_RAW) {
    +                captureObj->error_frame_raw_image = tivxCreateRawImage(context, &(sensorParams->sensorInfo.raw_params));
    
    -            status = vxGetStatus((vx_reference)captureObj->error_frame_raw_image);
    +                status = vxGetStatus((vx_reference)captureObj->error_frame_raw_image);
    
    -            if(status == VX_SUCCESS)
    -            {
    -                status = tivxMapRawImagePatch((tivx_raw_image)captureObj->error_frame_raw_image, &rect, 0, &map_id, &image_addr, &data_ptr, VX_READ_ONLY, VX_MEMORY_TYPE_HOST, TIVX_RAW_IMAGE_ALLOC_BUFFER);
    -
    -                if ((vx_status)VX_SUCCESS == status)
    +                if(status == VX_SUCCESS)
                     {
    -                    memset(data_ptr, 0x00, image_addr.stride_y*(sensorParams->sensorInfo.raw_params.height+sensorParams->sensorInfo.raw_params.meta_height_before+sensorParams->sensorInfo.raw_params.meta_height_after));
    +                    status = tivxMapRawImagePatch((tivx_raw_image)captureObj->error_frame_raw_image, &rect, 0, &map_id, &image_addr, &data_ptr, VX_READ_ONLY, VX_MEMORY_TYPE_HOST, TIVX_RAW_IMAGE_ALLOC_BUFFER);
                     }
                 }
    -            else
    -            {
    -                printf("[CAPTURE_MODULE] Unable to crate error frame RAW image!\n");
    +            else { /* APP_SENSOR_OUT_FORMAT_YUV */
    +                width = sensorParams->sensorInfo.raw_params.width;
    +                height = sensorParams->sensorInfo.raw_params.height;
    +                format = sensorParams->sensorInfo.raw_params.format->pixel_container;
    +                captureObj->error_frame_image = vxCreateImage(context, width, height, format);
    +
    +                status = vxGetStatus((vx_reference)captureObj->error_frame_image);
    +
    +                if (status == VX_SUCCESS) {
    +                    status = vxMapImagePatch((vx_image)captureObj->error_frame_image, &rect, 0, &map_id, &image_addr, &data_ptr, VX_READ_ONLY, VX_MEMORY_TYPE_HOST, VX_NOGAP_X);
    +                }
    +            }
    +
    +            if (status == VX_SUCCESS) {
    +                memset(data_ptr, 0, image_addr.stride_y *
    +                                    ( sensorParams->sensorInfo.raw_params.height
    +                                    + sensorParams->sensorInfo.raw_params.meta_height_before
    +                                    + sensorParams->sensorInfo.raw_params.meta_height_after ) );
    +            }
    +            else {
    +                printf("[CAPTURE_MODULE] Unable to crate error frame image!\n");
                 }
             }
             else
    @@ -575,8 +585,14 @@ vx_status app_send_cmd_capture_write_node(CaptureObj *captureObj, vx_uint32 star
     vx_status app_send_error_frame(CaptureObj *captureObj)
     {
         vx_status status = VX_SUCCESS;
    +    vx_reference error_frame_image;
    
    -    status = tivxCaptureRegisterErrorFrame(captureObj->node, (vx_reference)captureObj->error_frame_raw_image);
    -
    +    if (captureObj->capture_format == APP_SENSOR_OUT_FORMAT_RAW) {
    +        error_frame_image = (vx_reference)captureObj->error_frame_raw_image;
    +    }
    +    else { /* APP_SENSOR_OUT_FORMAT_YUV */
    +        error_frame_image = (vx_reference)captureObj->error_frame_image;
    +    }
    +    status = tivxCaptureRegisterErrorFrame(captureObj->node, error_frame_image);
         return status;
     }
    -- 
    2.25.1