TI中文支持网
TI专业的中文技术问题搜集分享网站

TDA4VM: TDA4VM

Part Number:TDA4VM

您好,我这边有一个关于人脸关键点检测的模型,我将其部署在8.6的SDK上可以正常运行并能得到正确的结果,但是将其部署在8.2的SDK上的话,程序就会卡死在tivxAlgiVisionProcess这个函数中,请问这个问题可以解决吗

Shine:

请问是自己的板子还是TI的EVM板?能否发一下执行步骤和执行后的log信息?

,

Gong Shanhe:

您好,我这边使用的是TI的EVM板,型号为J784S4XG01EVM,我的执行步骤如下:

1. 准备好SDK 8.2和SDK 8.6的人脸关键点检测模型(PFLD)的bin文件和运行的cfg文件,bin文件为tidl_io_pfld_1.bin和tidl_net_pfld.bin,cfg文件为app_my.cfg,我已经上传到Google Drive里面了,分享链接如下

SDK 8.2 : https://drive.google.com/file/d/1ZSKoRsou3eC7-526ZADT2MKcRb0XOaIY/view?usp=drive_link

SDK 8.6 : https://drive.google.com/file/d/1mAoLMCnnGSjdvKkEUfxBxur28pCd6ny4/view?usp=drive_link

2. 修改vision_apps/kernels/img_proc/c66/vx_draw_box_detections_target.c为下面内容

#include <TI/tivx.h>
#include <TI/tivx_img_proc.h>
#include <TI/tivx_target_kernel.h>
#include <tivx_kernels_target_utils.h>
#include <utils/udma/include/app_udma.h>
#include <utils/mem/include/app_mem.h>#include <tivx_draw_box_detections_host.h>
#include "itidl_ti.h"
#include <math.h>static tivx_target_kernel vx_DrawBoxDetections_kernel = NULL;static void drawPoints(vx_uint8 *data_ptr_1, vx_uint8 *data_ptr_2, vx_uint32 width, vx_uint32 height, vx_uint32 x_offset, vx_uint32 y_offset,vx_uint32 *kp_ptr, vx_uint32 num_points, vx_uint8 dim, vx_uint8 color_map[][3]);static vx_float32 prob[196];
static vx_uint32 point[196];#if defined(SOC_J721E) || defined(SOC_J721S2)
#ifndef x86_64
#if CPU_COPY/* Not enabled - change to 1 for doing CPU copy */
static void memcpyC66(uint8_t *restrict pOut, uint8_t *restrict pIn, int32_t size)
{int32_t remSize = size - ((size >> 3) << 3);int32_t i;for(i = 0; i < size; i+=8){_mem8(&pOut[i]) = _mem8(&pIn[i]);}if(remSize > 0){i-=8;for(; i < size; i++){pOut[i] = pIn[i];}}
}
#else
static void memcpyC66(uint8_t *pOut, uint8_t *pIn, int32_t size)
{app_udma_copy_1d_prms_t prms_1d;appUdmaCopy1DPrms_Init(&prms_1d);prms_1d.dest_addr= appMemGetVirt2PhyBufPtr((uint64_t) pOut, APP_MEM_HEAP_DDR);prms_1d.src_addr= appMemGetVirt2PhyBufPtr((uint64_t) pIn, APP_MEM_HEAP_DDR);prms_1d.length= (uint32_t) size;appUdmaCopy1D(NULL, &prms_1d);
}
#endif
#else
#define memcpyC66 memcpy
#endif
#else
#define memcpyC66 memcpy
#endifstatic vx_status VX_CALLBACK tivxKernelDrawBoxDetectionsCreate
(tivx_target_kernel_instance kernel,tivx_obj_desc_t *obj_desc[],vx_uint16 num_params,void *priv_arg
)
{vx_status status = VX_SUCCESS;uint32_t i;for (i = 0U; i < num_params; i ++){if (NULL == obj_desc[i]){status = VX_FAILURE;break;}}return(status);
}static vx_status VX_CALLBACK tivxKernelDrawBoxDetectionsDelete(tivx_target_kernel_instance kernel, tivx_obj_desc_t *obj_desc[],vx_uint16 num_params, void *priv_arg)
{vx_status status = VX_SUCCESS;uint32_t i;for (i = 0U; i < num_params; i ++){if (NULL == obj_desc[i]){status = VX_FAILURE;break;}}return (status);
}static vx_status VX_CALLBACK tivxKernelDrawBoxDetectionsProcess
(tivx_target_kernel_instance kernel,tivx_obj_desc_t *obj_desc[],vx_uint16 num_params,void *priv_arg
)
{vx_status status = VX_SUCCESS;vx_int32 i;for (i = 0U; i < num_params; i ++){if (NULL == obj_desc[i]){status = VX_FAILURE;break;}}if (VX_SUCCESS == status){tivx_obj_desc_user_data_object_t* config_desc;void * config_target_ptr = NULL;tivx_obj_desc_tensor_t* input_tensor_desc;void * input_tensor_target_ptr = NULL;tivx_obj_desc_image_t* input_image_desc;void * input_image_target_ptr[2];tivx_obj_desc_image_t* output_image_desc;void * output_image_target_ptr[2];input_image_target_ptr[0] = NULL;input_image_target_ptr[1] = NULL;output_image_target_ptr[0] = NULL;output_image_target_ptr[1] = NULL;config_desc = (tivx_obj_desc_user_data_object_t *)obj_desc[TIVX_KERNEL_DRAW_BOX_DETECTIONS_CONFIGURATION_IDX];config_target_ptr = tivxMemShared2TargetPtr(&config_desc->mem_ptr);tivxMemBufferMap(config_target_ptr, config_desc->mem_size, VX_MEMORY_TYPE_HOST,VX_READ_ONLY);input_tensor_desc = (tivx_obj_desc_tensor_t *)obj_desc[TIVX_KERNEL_DRAW_BOX_DETECTIONS_INPUT_TENSOR_IDX];input_tensor_target_ptr = tivxMemShared2TargetPtr(&input_tensor_desc->mem_ptr);tivxMemBufferMap(input_tensor_target_ptr, input_tensor_desc->mem_size, VX_MEMORY_TYPE_HOST,VX_READ_ONLY);input_image_desc = (tivx_obj_desc_image_t *)obj_desc[TIVX_KERNEL_DRAW_BOX_DETECTIONS_INPUT_IMAGE_IDX];input_image_target_ptr[0] = tivxMemShared2TargetPtr(&input_image_desc->mem_ptr[0]);tivxMemBufferMap(input_image_target_ptr[0], input_image_desc->mem_size[0], VX_MEMORY_TYPE_HOST,VX_READ_ONLY);input_image_target_ptr[1] = NULL;if(input_image_desc->mem_ptr[1].shared_ptr != 0){input_image_target_ptr[1] = tivxMemShared2TargetPtr(&input_image_desc->mem_ptr[1]);tivxMemBufferMap(input_image_target_ptr[1], input_image_desc->mem_size[1], VX_MEMORY_TYPE_HOST,VX_READ_ONLY);}output_image_desc = (tivx_obj_desc_image_t *)obj_desc[TIVX_KERNEL_DRAW_BOX_DETECTIONS_OUTPUT_IMAGE_IDX];output_image_target_ptr[0] = tivxMemShared2TargetPtr(&output_image_desc->mem_ptr[0]);tivxMemBufferMap(output_image_target_ptr[0], output_image_desc->mem_size[0], VX_MEMORY_TYPE_HOST,VX_WRITE_ONLY);if(output_image_desc->mem_ptr[1].shared_ptr != 0){output_image_target_ptr[1] = tivxMemShared2TargetPtr(&output_image_desc->mem_ptr[1]);tivxMemBufferMap(output_image_target_ptr[1], output_image_desc->mem_size[1], VX_MEMORY_TYPE_HOST,VX_WRITE_ONLY);}if(output_image_desc->mem_size[0] == input_image_desc->mem_size[0]){memcpyC66(output_image_target_ptr[0], input_image_target_ptr[0], output_image_desc->mem_size[0]);}if(output_image_desc->mem_size[1] == input_image_desc->mem_size[1]){memcpyC66(output_image_target_ptr[1], input_image_target_ptr[1], output_image_desc->mem_size[1]);}tivxDrawBoxDetectionsParams *params;params = (tivxDrawBoxDetectionsParams *)config_target_ptr;vx_uint32 point_num = 0;for (i = 0; i < 196; i++){prob[i] = ((vx_float32)(((vx_uint16 *)input_tensor_target_ptr)[i])) / 16384.0;}for (i = 0, point_num = 0; i < 98; i++, point_num++){point[2 * point_num] = prob[2 * i] * 448;point[2 * point_num + 1] = prob[2 * i + 1] * 448;}drawPoints((vx_uint8 *)output_image_target_ptr[0], (vx_uint8 *)output_image_target_ptr[1], 448, 448,0, 0, point, point_num, 1, &params->color_map[0]);tivxMemBufferUnmap(config_target_ptr, config_desc->mem_size, VX_MEMORY_TYPE_HOST, VX_READ_ONLY);tivxMemBufferUnmap(input_tensor_target_ptr, input_tensor_desc->mem_size, VX_MEMORY_TYPE_HOST, VX_READ_ONLY);tivxMemBufferUnmap(input_image_target_ptr[0], input_image_desc->mem_size[0], VX_MEMORY_TYPE_HOST, VX_READ_ONLY);if(input_image_target_ptr[1] != NULL){tivxMemBufferUnmap(input_image_target_ptr[1], input_image_desc->mem_size[1], VX_MEMORY_TYPE_HOST, VX_READ_ONLY);}tivxMemBufferUnmap(output_image_target_ptr[0], output_image_desc->mem_size[0], VX_MEMORY_TYPE_HOST, VX_WRITE_ONLY);if(output_image_target_ptr[1] != NULL){tivxMemBufferUnmap(output_image_target_ptr[1], output_image_desc->mem_size[1], VX_MEMORY_TYPE_HOST, VX_WRITE_ONLY);}}return (status);
}
void tivxAddTargetKernelDrawBoxDetections()
{vx_status status = (vx_status)VX_FAILURE;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);status = (vx_status)VX_SUCCESS;}else{status = tivxKernelsTargetUtilsAssignTargetNameDsp(target_name);}if( (vx_status)VX_SUCCESS == status){vx_DrawBoxDetections_kernel = tivxAddTargetKernelByName(TIVX_KERNEL_DRAW_BOX_DETECTIONS_NAME,target_name,tivxKernelDrawBoxDetectionsProcess,tivxKernelDrawBoxDetectionsCreate,tivxKernelDrawBoxDetectionsDelete,NULL,NULL);}
}void tivxRemoveTargetKernelDrawBoxDetections()
{vx_status status = VX_SUCCESS;status = tivxRemoveTargetKernel(vx_DrawBoxDetections_kernel);if (status == VX_SUCCESS){vx_DrawBoxDetections_kernel = NULL;}
}
static void drawPoints(vx_uint8 *data_ptr_1, vx_uint8 *data_ptr_2, vx_uint32 width, vx_uint32 height, vx_uint32 x_offset, vx_uint32 y_offset,vx_uint32 *kp_ptr, vx_uint32 num_points, vx_uint8 dim, vx_uint8 color_map[][3])
{vx_uint8 color[3];vx_uint32 kp_x, kp_y;color[0] = color_map[0][0];color[1] = color_map[0][1];color[2] = color_map[0][2];vx_int32 i = 0, j = 0, k = 0;for (i = 0; i < num_points; i++){kp_x = (vx_uint32)((vx_float32)kp_ptr[2 * i]) + x_offset;kp_y = (vx_uint32)((vx_float32)kp_ptr[2 * i + 1]) + y_offset;for (j = -((dim - 1) / 2); j < ((dim + 1) / 2); j++){for (k = -((dim - 1) / 2); k < ((dim + 1) / 2); k++){data_ptr_1[(kp_y * width) + kp_x + (j * width) + k] = color[0];}}for (j = -((dim - 1) / 2); j < ((dim + 1) / 2); j++){for (k = -((dim - 1) / 2); k < ((dim + 1) / 2); k++){data_ptr_2[((kp_y + j) >> 1) * width + (kp_x + k)] = color[1];data_ptr_2[((kp_y + j) >> 1) * width + (kp_x + k) + 1] = color[2];}}}
}

3. 编译SDK

4. 我这边采用的例程是vision_apps/dl_demos/app_tidl_od,生成的可执行文件为vx_app_tidl_od.out,在EVM板上运行vx_app_tidl_od.out –cfg app_my.cfg

5. 在SDK 8.2 上得到的LOG信息如下,此时程序卡死,

屏幕上面显示的效果如下

,

Cherry Zhou:

您好,您的问题我们需要升级到英文论坛寻求帮助,链接如下,如有答复将尽快回复您:

https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1271156/tda4vm-program-gets-stuck-when-deployed-on-sdk-8-2

,

Cherry Zhou:

您好,

很抱歉回复晚了。

您能否连接 CCS 或使用日志来检查下 C7x 内核悬空的位置?

在 TIDL 节点过程函数中是否有挂起? 

赞(0)
未经允许不得转载:TI中文支持网 » TDA4VM: TDA4VM
分享到: 更多 (0)