HI TI:
now i find a problem,when use yuv sensor, capture csirx output,i find the resolution is wrong. the res is 640*1280. but mosaic output is right,the right resolution is 1280*1285. please have a look, thanks very much!
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.
HI TI:
now i find a problem,when use yuv sensor, capture csirx output,i find the resolution is wrong. the res is 640*1280. but mosaic output is right,the right resolution is 1280*1285. please have a look, thanks very much!
Hi,
Can you please provide correct resolution in the capture node?
CSIRX module in itself cannot change the resolution, so it capture only configured size.. So please use correct size in the capture node..
Regards,
Brijesh
HI TI:
capture node size has correct configured.but from capture image,the image is wrong.attached the uart log
J7EVM@QNX:/ti_fs/vision_apps# ./run_app_multi_cam.sh
APP: Init QNX ... !!!
Sciclient_qnxVirtToPhyFxn:Error from mem_offset
Sciclient_qnxVirtToPhyFxn:Error from mem_offset
[xxx] disable ENABLE_IPC_MCU1_0 in qnx app
appIpcInit: IPC: Init QNX ... !!!
appIpcInit: IPC: Init ... Done !!!
22.711994 s: REMOTE_SERVICE: Init ... !!!
22.712116 s: REMOTE_SERVICE: Init ... Done !!!
22.712144 s: GTC Frequency = 200 MHz
APP: Init ... Done !!!
22.712167 s: VX_ZONE_INIT:Enabled
22.712179 s: VX_ZONE_ERROR:Enabled
22.712191 s: VX_ZONE_WARNING:Enabled
22.712380 s: VX_ZONE_INIT:[tivxInit:71] Initialization Done !!!
22.712412 s: VX_ZONE_INIT:[tivxHostInit:48] Initialization Done for HOST !!!
22.713209 s: ISS: Enumerating sensors ... !!!
22.713370 s: ISS: Enumerating sensors ... found 0 : IMX390-UB953_D3
22.713392 s: ISS: Enumerating sensors ... found 1 : UB9xxx_RAW12_TESTPATTERN
22.713409 s: ISS: Enumerating sensors ... found 2 : UB96x_UYVY_TESTPATTERN
22.713424 s: ISS: Enumerating sensors ... found 3 : GW_AR0233_UYVY
4 sensor(s) found
Supported sensor list:
a : IMX390-UB953_D3
b : UB9xxx_RAW12_TESTPATTERN
c : UB96x_UYVY_TESTPATTERN
d : GW_AR0233_UYVY
Select a sensor above or press '0' to autodetect the sensor
b
Sensor selected : UB9xxx_RAW12_TESTPATTERN
Querying UB9xxx_RAW12_TESTPATTERN
23.777320 s: ISS: Querying sensor [UB9xxx_RAW12_TESTPATTERN] ... !!!
23.777465 s: ISS: Querying sensor [UB9xxx_RAW12_TESTPATTERN] ... Done !!!
---sensorObj->sensor_out_format = 1---
LDC Selection Yes(1)/No(0)
Invalid selection
. Try again
LDC Selection Yes(1)/No(0)
1
Max number of cameras supported by sensor UB9xxx_RAW12_TESTPATTERN = 4
Please enter number of cameras to be enabled
Invalid selection
. Try again
Max number of cameras supported by sensor UB9xxx_RAW12_TESTPATTERN = 4
Please enter number of cameras to be enabled
4
WDR mode is not supported. Defaulting to linear
Sensor DCC is enabled
Sensor width = 1280
Sensor height = 1285
Sensor DCC ID = 9702
Sensor Supported Features = 0x00000120
Sensor Enabled Features = 0x00000120
[xxx] app_multi_cam_main test
sensor_out_format=1
YUV Input selected. VISS, AEWB and Mosaic nodes will be bypassed.
obj->sensorObj.image_width=1280
obj->sensorObj.image_height=1285
now set obj->sensorObj.image_width=1280
now set obj->sensorObj.image_height=1280
resized_width=1280,resized_height=1280,
num_cameras_enabled=4
numCh=4,grid_size is 2
----imgMosaicObj->params.windows[0].startX=0---
----imgMosaicObj->params.windows[0].startY=0---
----imgMosaicObj->params.windows[0].width=640
----imgMosaicObj->params.windows[0].height=640
----imgMosaicObj->params.windows[1].startX=640---
----imgMosaicObj->params.windows[1].startY=0---
----imgMosaicObj->params.windows[1].width=640
----imgMosaicObj->params.windows[1].height=640
----imgMosaicObj->params.windows[2].startX=0---
----imgMosaicObj->params.windows[2].startY=640---
----imgMosaicObj->params.windows[2].width=640
----imgMosaicObj->params.windows[2].height=640
----imgMosaicObj->params.windows[3].startX=640---
----imgMosaicObj->params.windows[3].startY=640---
----imgMosaicObj->params.windows[3].width=640
----imgMosaicObj->params.windows[3].height=640
Creating context done!
Kernel loading done!
---app_init_sensor----
---sensorObj->num_cameras_enabled=4---
---sensorObj->image_width=1280---
---sensorObj->image_height=1280---
24.763159 s: ISS: Initializing sensor [UB9xxx_RAW12_TESTPATTERN], doing IM_SENSOR_CMD_PWRON ... !!!
24.763393 s: ISS: ERROR: Initializing sensor [UB9xxx_RAW12_TESTPATTERN] failed !!!
24.763415 s: ISS: Initializing sensor [UB9xxx_RAW12_TESTPATTERN] ... Done !!!
Error initializing sensor UB9xxx_RAW12_TESTPATTERN
Sensor init done!
captureObj->params.numDataLanes = 4
captureObj->params.dataLanesMap[0] = 1
captureObj->params.dataLanesMap[1] = 2
captureObj->params.dataLanesMap[2] = 3
captureObj->params.dataLanesMap[3] = 4
24.763696 s: VX_ZONE_ERROR:[vxCopyUserDataObject:429] wdp offset is 0,size is 208
captureObj->capture_format is 1
vx vxCreateImage UYVY width=1280,height=1285
wdp bufq_depth is 4,num_cameras_enabled is 4
24.900578 s: VX_ZONE_ERROR:[vxCopyUserDataObject:429] wdp offset is 0,size is 12
24.900645 s: VX_ZONE_ERROR:[vxCopyUserDataObject:429] wdp offset is 0,size is 16
24.900702 s: VX_ZONE_ERROR:[vxCopyUserDataObject:429] wdp offset is 0,size is 24
ldcObj->table_width=1280----ldcObj->table_height=1280---
LDC init done!
24.900844 s: VX_ZONE_ERROR:[vxCopyUserDataObject:429] wdp offset is 0,size is 1428
vxCreateImage NV12 imgMosaicObj->out_width=1280,height is 1280
Img Mosaic init done!
Display init done!
App Init Done!
Graph create done!
Capture graph done!
enable_ldc is 1
LDC graph done!
enable_mosaic is 1
Img Mosaic graph done!
Display graph done!
App Create Graph Done!
24.901391 s: VX_ZONE_ERROR:[vxCopyUserDataObject:429] wdp offset is 0,size is 24
Graph verify done!
App Verify Graph Done!
App Send Error Frame Done!
app_run_graph_interactive
app_pipeline_params_defaults returned
obj->test_mode is 0
25.056968 s: ISS: Starting sensor [UB9xxx_RAW12_TESTPATTERN] ... !!!
[MCU2_0] 25.450275 s: IssSensor_Start camera 0
[MCU2_0] 25.450331 s: no need IssSensor_Start
[MCU2_0] 25.451369 s: Error : sensor handle at channel Id 0 = NULL
[MCU2_0] 25.451415 s: IssSensor_Start camera 1
[MCU2_0] 25.451444 s: no need IssSensor_Start
[MCU2_0] 25.452460 s: Error : sensor handle at channel Id 1 = NULL
[MCU2_0] 25.452498 s: IssSensor_Start camera 2
[MCU2_0] 25.452524 s: no need IssSensor_Start
[MCU2_0] 25.453540 s: Error : sensor handle at channel Id 2 = NULL
[MCU2_0] 25.453580 s: IssSensor_Start camera 3
[MCU2_0] 25.453607 s: no need IssSensor_Start
[MCU2_0] 25.454628 s: Error : sensor handle at channel Id 3 = NULL
[MCU2_0] 25.493740 s: wdp now set all four port
25.501608 s: ISS: Starting sensor [UB9xxx_RAW12_TESTPATTERN] ... !!!
appStartImageSensor returned with status: 0
wdp start frame is 0,num_frames is 1
25.501676 s: VX_ZONE_ERROR:[vxCopyUserDataObject:429] wdp offset is 0,size is 12
Capture node send command success!
app_run_graph_for_one_pipeline: frame 0 beginning
app_run_graph_for_one_pipeline: frame 1 beginning
app_run_graph_for_one_pipeline: frame 2 beginning
=========================
Demo : Camera Demo
=========================
s: Save CSIx, VISS and LDC outputs
p: Print performance statistics
x: Exit
Enter Choice:
=========================
Demo : Camera Demo
=========================
s: Save CSIx, VISS and LDC outputs
p: Print performance statistics
x: Exit
Enter Choice: Writing /tmp/csix_raw_output_1280x1285_ch_0_00000000.bin ..
Done!
Writing /tmp/csix_raw_output_1280x1285_ch_1_00000000.bin ..
Done!
Writing /tmp/csix_raw_output_1280x1285_ch_2_00000000.bin ..
Done!
Writing /tmp/csix_raw_output_1280x1285_ch_3_00000000.bin ..
Done!
app_run_graph_for_one_pipeline: frame 3 beginning
app_run_graph_for_one_pipeline: frame 4 beginning
app_run_graph_for_one_pipeline: frame 5 beginning
app_run_graph_for_one_pipeline: frame 6 beginning
app_run_graph_for_one_pipeline: frame 7 beginning
app_run_graph_for_one_pipeline: frame 8 beginning
app_run_graph_for_one_pipeline: frame 9 beginning
app_run_graph_for_one_pipeline: frame 10 beginning
app_run_graph_for_one_pipeline: frame 11 beginning
app_run_graph_for_one_pipeline: frame 12 beginning
app_run_graph_for_one_pipeline: frame 13 beginning
app_run_graph_for_one_pipeline: frame 14 beginning
app_run_graph_for_one_pipeline: frame 15 beginning
app_run_graph_for_one_pipeline: frame 16 beginning
app_run_graph_for_one_pipeline: frame 17 beginning
sapp_run_graph_for_one_pipeline: frame 18 beginning
app_run_graph_for_one_pipeline: frame 19 beginning
app_run_graph_for_one_pipeline: frame 20 beginning
app_run_graph_for_one_pipeline: frame 21 beginning
app_run_graph_for_one_pipeline: frame 22 beginning
=========================
Demo : Camera Demo
=========================
s: Save CSIx, VISS and LDC outputs
p: Print performance statistics
x: Exit
Enter Choice:
=========================
Demo : Camera Demo
=========================
s: Save CSIx, VISS and LDC outputs
p: Print performance statistics
x: Exit
Enter Choice: wdp start frame is 23,num_frames is 1
26.835264 s: VX_ZONE_ERROR:[vxCopyUserDataObject:429] wdp offset is 0,size is 12
Capture node send command success!
app_run_graph_for_one_pipeline: frame 23 beginning
app_run_graph_for_one_pipeline: frame 24 beginning
app_run_graph_for_one_pipeline: frame 25 beginning
Writing /tmp/csix_raw_output_1280x1285_ch_0_00000023.bin ..
Done!
Writing /tmp/csix_raw_output_1280x1285_ch_1_00000023.bin ..
Done!
Writing /tmp/csix_raw_output_1280x1285_ch_2_00000023.bin ..
Done!
Writing /tmp/csix_raw_output_1280x1285_ch_3_00000023.bin ..
Done!
app_run_graph_for_one_pipeline: frame 26 beginning
app_run_graph_for_one_pipeline: frame 27 beginning
app_run_graph_for_one_pipeline: frame 28 beginning
app_run_graph_for_one_pipeline: frame 29 beginning
app_run_graph_for_one_pipeline: frame 30 beginning
app_run_graph_for_one_pipeline: frame 31 beginning
app_run_graph_for_one_pipeline: frame 32 beginning
xapp_run_graph_for_one_pipeline: frame 33 beginning
app_run_graph_for_one_pipeline: frame 34 beginning
app_run_graph_for_one_pipeline: frame 35 beginning
app_run_graph_for_one_pipeline: frame 36 beginning
27.511028 s: ISS: Stopping sensor [UB9xxx_RAW12_TESTPATTERN] ... !!!
27.591153 s: ISS: Stopping sensor [UB9xxx_RAW12_TESTPATTERN] ... Done !!!
App Run Graph Done!
Capture delete done!
VISS delete done!
AEWB delete done!
LDC delete done!
Img Mosaic delete done!
Display delete done!
[MCU2_0] 27.629536 s: ==========================================================
[MCU2_0] 27.629619 s: Capture Status: Instance|0
[MCU2_0] 27.629662 s: ==========================================================
[MCU2_0] 27.629699 s: overflowCount: 0
[MCU2_0] 27.629746 s: spuriousUdmaIntrCount: 0
[MCU2_0] 27.629776 s: frontFIFOOvflCount: 0
[MCU2_0] 27.629800 s: crcCount: 1
[MCU2_0] 27.629821 s: eccCount: 0
[MCU2_0] 27.629843 s: correctedEccCount: 0
[MCU2_0] 27.629868 s: dataIdErrorCount: 0
[MCU2_0] 27.629893 s: invalidAccessCount: 0
[MCU2_0] 27.629917 s: invalidSpCount: 0
[MCU2_0] 27.629942 s: strmFIFOOvflCount[0]: 0
[MCU2_0] 27.629969 s: strmFIFOOvflCount[1]: 0
[MCU2_0] 27.629995 s: strmFIFOOvflCount[2]: 83
[MCU2_0] 27.630021 s: strmFIFOOvflCount[3]: 18
[MCU2_0] 27.630064 s: Channel Num | Frame Queue Count | Frame De-queue Count | Frame Drop Count | Error Frame Count |
[MCU2_0] 27.630119 s: 0 | 39 | 39 | 2 | 0 |
[MCU2_0] 27.630197 s: 1 | 39 | 39 | 2 | 0 |
[MCU2_0] 27.630257 s: 2 | 39 | 39 | 2 | 0 |
[MCU2_0] 27.630311 s: 3 | 39 | 39 | 2 | 0 |
Graph delete done!
App Delete Graph Done!
27.632881 s: ISS: De-initializing sensor [UB9xxx_RAW12_TESTPATTERN] ... !!!
27.633024 s: ISS: De-initializing sensor [UB9xxx_RAW12_TESTPATTERN] ... Done !!!
Sensor deinit done!
Capture deinit done!
LDC deinit done!
Img Mosaic deinit done!
Display deinit done!
Kernels unload done!
Release context done!
App De-init Done!
27.638061 s: VX_ZONE_INIT:[tivxHostDeInit:56] De-Initialization Done for HOST !!!
27.645842 s: VX_ZONE_INIT:[tivxDeInit:111] De-Initialization Done !!!
APP: Deinit ... !!!
27.645867 s: REMOTE_SERVICE: Deinit ... !!!
27.645919 s: REMOTE_SERVICE: Deinit ... Done !!!
IPC: Deinit ... !!!
IPC: Deinit ... Done !!!
APP: Deinit ... Done !!!
HI TI:
from uart log it show
captureObj->capture_format is 1
vx vxCreateImage UYVY width=1280,height=1285
so i think i have configured correct capture resolution.but from attach 4-1.zip,you can see csix_raw_output_1280x1285_ch_0_00000038.bin can't show the full picture.it is about quarter size.but mosaic_output_0000000075_1280x1288.yuv can see full size.
Hi,
It looks like half of the frame is getting cut, during dumping the frame. This is because only saved frame is incorrect, but the frame which goes to next component, most likely LDC and then mosaic, seems to be of correct size.. Can you please check your logic of saving frames?
Regards,
Brijesh
HI TI:
yes,the first dump frame is csirx frame,and then ldc,the last mosaic. i dump csirx frame and mosaic frame in 4-1.zip.and i found mosaic dump is ok,but csirx frame is wrong. i doubt it is SDK7.3 problem. i can't find the reason, buffer malloc?buffer queue or storage format
Hi,
Which function prints "Writing /tmp/csix_raw_output_1280x1285_ch_3_00000023.bin ." statement? Can you please share this function? Essentially, i want to check the code which is writing the CSIRX output to a file..
Regards,
Brijesh
HI TI:
i found the function is tivxKernelWriteImageProcess,attached the file. and the format is VX_DF_IMAGE_UYVY.
/* * * Copyright (c) 2020 Texas Instruments Incorporated * * All rights reserved not granted herein. * * Limited License. * * Texas Instruments Incorporated grants a world-wide, royalty-free, non-exclusive * license under copyrights and patents it now or hereafter owns or controls to make, * have made, use, import, offer to sell and sell ("Utilize") this software subject to the * terms herein. With respect to the foregoing patent license, such license is granted * solely to the extent that any such patent is necessary to Utilize the software alone. * The patent license shall not apply to any combinations which include this software, * other than combinations with devices manufactured by or for TI ("TI Devices"). * No hardware patent is licensed hereunder. * * Redistributions must preserve existing copyright notices and reproduce this license * (including the above copyright notice and the disclaimer and (if applicable) source * code license limitations below) in the documentation and/or other materials provided * with the distribution * * Redistribution and use in binary form, without modification, are permitted provided * that the following conditions are met: * * * No reverse engineering, decompilation, or disassembly of this software is * permitted with respect to any software provided in binary form. * * * any redistribution and use are licensed by TI for use only with TI Devices. * * * Nothing shall obligate TI to provide you with source code for the software * licensed and provided to you in object code. * * If software source code is provided to you, modification and redistribution of the * source code are permitted provided that the following conditions are met: * * * any redistribution and use of the source code, including any resulting derivative * works, are licensed by TI for use only with TI Devices. * * * any redistribution and use of any object code compiled from the source code * and any resulting derivative works, are licensed by TI for use only with TI Devices. * * Neither the name of Texas Instruments Incorporated nor the names of its suppliers * * may be used to endorse or promote products derived from this software without * specific prior written permission. * * DISCLAIMER. * * THIS SOFTWARE IS PROVIDED BY TI AND TI'S LICENSORS "AS IS" AND ANY EXPRESS * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL TI AND TI'S LICENSORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. * */ #include <stdio.h> #include <TI/tivx.h> #include <TI/j7.h> #include <TI/tivx_fileio.h> #include <TI/tivx_target_kernel.h> #include "tivx_kernels_target_utils.h" #include <tivx_fileio_write_image_host.h> #define WRITE_FILE_OUTPUT typedef struct { tivxFileIOWriteCmd cmd; vx_uint32 frame_counter; vx_uint32 skip_counter; vx_uint32 ch_num; } tivxWriteImageParams; static tivx_target_kernel vx_write_image_target_kernel = NULL; static vx_int32 inst_id = 0; static vx_status tivxKernelWriteImageCmd ( tivxWriteImageParams *prms, const tivx_obj_desc_user_data_object_t *usr_data_obj ) { vx_status status = (vx_status)VX_SUCCESS; if (NULL != usr_data_obj) { void *target_ptr = tivxMemShared2TargetPtr(&usr_data_obj->mem_ptr); tivxMemBufferMap(target_ptr, usr_data_obj->mem_size, (vx_enum)VX_MEMORY_TYPE_HOST, (vx_enum)VX_READ_ONLY); if (sizeof(tivxFileIOWriteCmd) == usr_data_obj->mem_size) { memcpy(&prms->cmd, target_ptr, sizeof(tivxFileIOWriteCmd)); } prms->skip_counter = 0; tivxMemBufferUnmap(target_ptr, usr_data_obj->mem_size, (vx_enum)VX_MEMORY_TYPE_HOST, (vx_enum)VX_READ_ONLY); } else { VX_PRINT(VX_ZONE_ERROR, "tivxKernelWriteImageCmd: Data Object is NULL\n"); status = (vx_status)VX_ERROR_INVALID_PARAMETERS; } return (status); } static vx_status VX_CALLBACK tivxKernelWriteImageControl ( tivx_target_kernel_instance kernel, uint32_t node_cmd_id, tivx_obj_desc_t *obj_desc[], uint16_t num_params, void *priv_arg ) { vx_status status = VX_SUCCESS; tivxWriteImageParams *prms = NULL; if (NULL == obj_desc[TIVX_KERNEL_WRITE_IMAGE_INPUT_IDX]) { printf("Input Image handle is NULL!\n"); status = VX_FAILURE; } if(status==VX_SUCCESS) { uint32_t size; status = tivxGetTargetKernelInstanceContext(kernel, (void **)&prms, &size); if ((VX_SUCCESS != status) || (NULL == prms) || (sizeof(tivxWriteImageParams) != size)) { status = VX_FAILURE; } } switch (node_cmd_id) { case TIVX_FILEIO_CMD_SET_FILE_WRITE: { tivxKernelWriteImageCmd(prms, (tivx_obj_desc_user_data_object_t *)obj_desc[0U]); break; } default: { VX_PRINT(VX_ZONE_ERROR, "tivxKernelWriteImageControl: Invalid Command Id\n"); status = (vx_status)VX_FAILURE; break; } } return (status); } static vx_status VX_CALLBACK tivxKernelWriteImageCreate ( tivx_target_kernel_instance kernel, tivx_obj_desc_t *obj_desc[], vx_uint16 num_params, void *priv_arg ) { tivxWriteImageParams * prms = NULL; prms = tivxMemAlloc(sizeof(tivxWriteImageParams), TIVX_MEM_EXTERNAL); if(prms == NULL) { printf("Unable to allcate memory for tivxWriteImageParams\n"); return VX_FAILURE; } prms->ch_num = inst_id; prms->frame_counter = 0; prms->skip_counter = 0; prms->cmd.start_frame = -1; prms->cmd.num_frames = 0; prms->cmd.num_skip = 0; inst_id++; tivxSetTargetKernelInstanceContext(kernel, prms, sizeof(tivxWriteImageParams)); return(VX_SUCCESS); } static vx_status VX_CALLBACK tivxKernelWriteImageDelete( tivx_target_kernel_instance kernel, tivx_obj_desc_t *obj_desc[], vx_uint16 num_params, void *priv_arg) { vx_status status = VX_SUCCESS; if (NULL == obj_desc[TIVX_KERNEL_WRITE_IMAGE_INPUT_IDX]) { printf("Input Image handle is NULL!\n"); status = VX_FAILURE; } if (VX_SUCCESS == status) { uint32_t size; tivxWriteImageParams *prms = NULL; status = tivxGetTargetKernelInstanceContext(kernel, (void **)&prms, &size); tivxMemFree(prms, sizeof(tivxWriteImageParams), TIVX_MEM_EXTERNAL); } return (status); } static vx_status VX_CALLBACK tivxKernelWriteImageProcess ( tivx_target_kernel_instance kernel, tivx_obj_desc_t *obj_desc[], vx_uint16 num_params, void *priv_arg ) { vx_status status = VX_SUCCESS; tivxWriteImageParams *prms = NULL; if (NULL == obj_desc[TIVX_KERNEL_WRITE_IMAGE_INPUT_IDX]) { printf("Input Image handle is NULL!\n"); status = VX_FAILURE; } if(status==VX_SUCCESS) { uint32_t size; status = tivxGetTargetKernelInstanceContext(kernel, (void **)&prms, &size); if ((VX_SUCCESS != status) || (NULL == prms) || (sizeof(tivxWriteImageParams) != size)) { status = VX_FAILURE; } } if (VX_SUCCESS == status) { tivx_obj_desc_image_t *in_img_desc; void* in_img_target_ptr[2]; tivx_obj_desc_array_t* file_path_desc; void * file_path_target_ptr = NULL; tivx_obj_desc_array_t* file_prefix_desc; void * file_prefix_target_ptr = NULL; in_img_desc = (tivx_obj_desc_image_t *)obj_desc[TIVX_KERNEL_WRITE_IMAGE_INPUT_IDX]; in_img_target_ptr[0] = tivxMemShared2TargetPtr(&in_img_desc->mem_ptr[0]); tivxMemBufferMap(in_img_target_ptr[0], in_img_desc->mem_size[0], VX_MEMORY_TYPE_HOST, VX_READ_ONLY); in_img_target_ptr[1] = NULL; if(in_img_desc->mem_ptr[1].shared_ptr != 0) { in_img_target_ptr[1] = tivxMemShared2TargetPtr(&in_img_desc->mem_ptr[1]); tivxMemBufferMap(in_img_target_ptr[1], in_img_desc->mem_size[1], VX_MEMORY_TYPE_HOST, VX_READ_ONLY); } file_path_desc = (tivx_obj_desc_array_t *)obj_desc[TIVX_KERNEL_WRITE_IMAGE_FILE_PATH_IDX]; if(file_path_desc != NULL) { file_path_target_ptr = tivxMemShared2TargetPtr(&file_path_desc->mem_ptr); tivxMemBufferMap(file_path_target_ptr, file_path_desc->mem_size, VX_MEMORY_TYPE_HOST,VX_READ_ONLY); } file_prefix_desc = (tivx_obj_desc_array_t *)obj_desc[TIVX_KERNEL_WRITE_IMAGE_FILE_PREFIX_IDX]; if(file_prefix_desc != NULL) { file_prefix_target_ptr = tivxMemShared2TargetPtr(&file_prefix_desc->mem_ptr); tivxMemBufferMap(file_prefix_target_ptr, file_prefix_desc->mem_size, VX_MEMORY_TYPE_HOST,VX_READ_ONLY); } /* This helps in synchonizing frames across nodes */ if(prms->frame_counter == prms->cmd.start_frame) prms->skip_counter = 0; if((prms->frame_counter >= prms->cmd.start_frame) && (prms->frame_counter < (prms->cmd.start_frame + (prms->cmd.num_frames * (prms->cmd.num_skip + 1)))) && (prms->skip_counter == 0)) { char file_path[TIVX_FILEIO_FILE_PATH_LENGTH]; char file_prefix[TIVX_FILEIO_FILE_PREFIX_LENGTH]; char file_name[TIVX_FILEIO_FILE_PATH_LENGTH * 2]; strcpy(file_path, file_path_target_ptr); strcpy(file_prefix, file_prefix_target_ptr); sprintf(file_name, "%s/%s_%dx%d_ch_%d_%08d", file_path, file_prefix, in_img_desc->width, in_img_desc->height, prms->ch_num, prms->frame_counter); if(in_img_desc->format == VX_DF_IMAGE_NV12) { strcat(file_name, ".yuv"); } else if (in_img_desc->format == VX_DF_IMAGE_RGB) { strcat(file_name, ".rgb"); } else { strcat(file_name, ".bin"); } printf("Writing %s ..\n", file_name); printf("wdp it is image target\n"); #ifdef WRITE_FILE_OUTPUT FILE *fp = fopen(file_name, "wb"); if(fp == NULL) { printf("Unable to write file %s\n", file_name); } else { uint32_t width = in_img_desc->imagepatch_addr[0].dim_x; uint32_t height = in_img_desc->imagepatch_addr[0].dim_y; uint32_t stride = in_img_desc->imagepatch_addr[0].stride_y; uint8_t *pData = in_img_target_ptr[0]; int32_t i; for(i = 0; i < height; i++) { fwrite(pData, 1, width, fp); pData += stride; } if(in_img_target_ptr[1] != NULL) { pData = in_img_target_ptr[1]; height = height / 2; for(i = 0; i < height; i++) { fwrite(pData, 1, width, fp); pData += stride; } } fflush(fp); fclose(fp); } #endif printf("Done!\n"); } prms->skip_counter++; prms->skip_counter = prms->skip_counter % (prms->cmd.num_skip + 1); prms->frame_counter++; tivxMemBufferUnmap(in_img_target_ptr[0], in_img_desc->mem_size[0], VX_MEMORY_TYPE_HOST, VX_READ_ONLY); if (in_img_target_ptr[1] != NULL){ tivxMemBufferUnmap(in_img_target_ptr[1], in_img_desc->mem_size[1], VX_MEMORY_TYPE_HOST, VX_READ_ONLY); } if(file_path_target_ptr != NULL) { tivxMemBufferUnmap(file_path_target_ptr, file_path_desc->mem_size, VX_MEMORY_TYPE_HOST, VX_READ_ONLY); } if(file_prefix_target_ptr != NULL) { tivxMemBufferUnmap(file_prefix_target_ptr, file_prefix_desc->mem_size, VX_MEMORY_TYPE_HOST, VX_READ_ONLY); } } return (status); } void tivxAddTargetKernelWriteImage() { char target_name[TIVX_TARGET_MAX_NAME]; vx_enum self_cpu; self_cpu = tivxGetSelfCpuId(); if ((self_cpu == TIVX_CPU_ID_A72_0)) { strncpy(target_name, TIVX_TARGET_A72_0, TIVX_TARGET_MAX_NAME); vx_write_image_target_kernel = tivxAddTargetKernelByName ( TIVX_KERNEL_WRITE_IMAGE_NAME, target_name, tivxKernelWriteImageProcess, tivxKernelWriteImageCreate, tivxKernelWriteImageDelete, tivxKernelWriteImageControl, NULL ); } } void tivxRemoveTargetKernelWriteImage() { vx_status status = VX_SUCCESS; status = tivxRemoveTargetKernel(vx_write_image_target_kernel); if (status == VX_SUCCESS) { vx_write_image_target_kernel = NULL; } }
Hi wu dunpeng,
I think i know what is the issue here.
In the below code snippet, it is writing one line at a time, but the size used here is width. For YUV422 image, it must be width*2, otherwise, it would just write half of the captured image.
for(i = 0; i < height; i++)
{
fwrite(pData, 1, width, fp);
pData += stride;
}
Can you please make a small change in this function, as shown below, and try it out?
uint32_t width = in_img_desc->imagepatch_addr[0].dim_x * in_img_desc->imagepatch_addr[0].stride_x;
uint32_t height = in_img_desc->imagepatch_addr[0].dim_y;
uint32_t stride = in_img_desc->imagepatch_addr[0].stride_y;
uint8_t *pData = in_img_target_ptr[0];
int32_t i;
if (in_img_desc->format == VX_DF_IMAGE_RGB)
{
width = width * 3;
}
else if ((in_img_desc->format == VX_DF_IMAGE_UYVY) || (in_img_desc->format == VX_DF_IMAGE_YUYV))
{
width = width * 2;
}
Regards,
Brijesh
HI TI:
now i only modify
uint32_t width = in_img_desc->imagepatch_addr[0].dim_x * in_img_desc->imagepatch_addr[0].stride_x
and //height = height / 2;
capture image ok. so i want to ask why need height = height / 2?
Hi,
No, i dont think by making height to half of what is actual will save the correct image.
In your case,
in_img_desc->imagepatch_addr[0].dim_x = 1280
in_img_desc->imagepatch_addr[0].stride_x = 1
height = 1285
So you need to multiply width by 2, for yuv422 data..
Regards,
Brijesh
HI TI:
i see in_img_desc->imagepatch_addr[0].stride_x = 2 from uart log.
i doubt is
if(in_img_target_ptr[1] != NULL)
{
pData = in_img_target_ptr[1];
height = height / 2;
for(i = 0; i < height; i++)
{
fwrite(pData, 1, width, fp);
pData += stride;
}
}
height = height / 2; is not applicable for yuv sensor. so yuv sensor need't this.
Hi,
ok this is for the NV12 image. For NV12 images, there are two planes, one for luma and other for chroam and chroma height is half of luma height..
As we can see, the condition is "if(in_img_target_ptr[1] != NULL)", which mean it is trying to save chroma plane..
Regards,
Brijesh