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

TDA4VM: how to send frame to two thread by CaptureNode

Part Number:TDA4VM

Hello, everyone

I have a question about CaptureNode.

My project need run two threads, these input are all CaptureNode's output.

In TDA4X, we can get CaptureNode's output by 

while(1)
{
vxGraphParameterDequeueDoneRef 

vxGraphParameterEnqueueReadyRef
}

But I think there must be some problem If two threads all run vxGraphParameterDequeueDoneRef and vxGraphParameterEnqueueReadyRef.

Some I think I need to send CaptureNode's to two pipeline by

vxSetGraphScheduleConfig

for this vxGraphParameterDequeueDoneRef and vxGraphParameterEnqueueReadyRef can get frame by different index.
But I don't know how to send CaptureNode's output to differnet index by vxSetGraphScheduleConfig.
I think I need some help, thank you.
best regard



Cherry Zhou:

Hi,

We've got the issue and escalated to e2e, please expect the response.

Thanks!

,

Cherry Zhou:

Hi,

In order to understand the issue could you please address my below queries:1. Are you running multiple graphs or a single graph?2. Could you brief your setup?3. Are both the threads run on same graph?

Thanks,

Cherry

,

dong yuwei:

Hello

First, I run multiple graphs

Second, my setup for a thread is avm, it's as same as /ti-processor-sdk-rtos-j7-evm-07_03_00_05/vision_apps/apps/basic_demos/app_aitronx_basic/app_aitronx_main.c 

the second thread is run deeplearning, I input image to deeplearning Node and get the result. It's already can be work.

Third, two threads run two graph, first graph is avm graph, second is deeplearning graph

Thanks

best regard

,

Cherry Zhou:

Hi,

May we know the source of the file "/ti-processor-sdk-rtos-j7-evm-07_03_00_05/vision_apps/apps/basic_demos/app_aitronx_basic/app_aitronx_main.c"… This is not part of SDK 7.3 release. It would be great if we could get this file to see which implementation you are referring.Is the capture node part of the first graph or second graph?It would be better if the capture node is kept in a separate graph and the frames are dequeued from this graph and enqueued in avm graph and deeplearning graph.Currently what is the issue that you are facing when 2 graphs are running dequeue and enqueue functions?

Thanks!

,

dong yuwei:

Hello

In my project, the capture node's code is like this

First init

#define NUM_CAPT_INST(1U)
capture_cfg->num_cap_channels= 4vx_status tsovx_init_capture(vx_context context, CaptureConfig *capture_cfg, CaptureObject *capture_obj)
{vx_status status = VX_FAILURE;if (NULL != capture_cfg && NULL != capture_obj) {if (vx_true_e == tivxIsTargetEnabled(TIVX_TARGET_CAPTURE1))status = VX_SUCCESS;if(VX_SUCCESS == status) {tivx_capture_params_init(&capture_obj->capture_params);capture_obj->capture_params.numInst = NUM_CAPT_INST;capture_obj->capture_params.numCh = (capture_cfg->num_cap_channels * NUM_CAPT_INST);uint32_t chIdx = 0U;for (uint32_t instIdx = 0U ; instIdx < NUM_CAPT_INST ; instIdx++){capture_obj->capture_params.instId[instIdx] = instIdx;capture_obj->capture_params.instCfg[instIdx].enableCsiv2p0Support = (uint32_t)vx_true_e;capture_obj->capture_params.instCfg[instIdx].numDataLanes= 4;for (uint32_t loop_id = 0U; loop_id < capture_obj->capture_params.instCfg[0U].numDataLanes ; loop_id++){capture_obj->capture_params.instCfg[instIdx].dataLanesMap[loop_id] = (loop_id + 1u);}for (uint32_t loop_id = 0U; loop_id < capture_cfg->num_cap_channels; loop_id++){capture_obj->capture_params.chVcNum[chIdx]= loop_id;capture_obj->capture_params.chInstMap[chIdx] = instIdx;chIdx++;}}capture_obj->capture_params_obj = vxCreateUserDataObject(context, "tivx_capture_params_t" , sizeof(tivx_capture_params_t), &capture_obj->capture_params);status = vxGetStatus((vx_reference)capture_obj->capture_params_obj);if(VX_SUCCESS == status) {tsovx_init_capture_buf(context, capture_cfg, capture_obj);}}}return status;
}

then create capture nodethe frame is uyvy

vx_status tsovx_create_capture_node(vx_graph graph, CaptureObject *capture_obj, vx_object_array frame)
{capture_obj->node = NULL;vx_status status = VX_FAILURE;if (vx_true_e == tivxIsTargetEnabled(TIVX_TARGET_CAPTURE1)) {capture_obj->node = tivxCaptureNode(graph, capture_obj->capture_params_obj, frame);vxSetNodeTarget(capture_obj->node, VX_TARGET_STRING, TIVX_TARGET_CAPTURE1);status = vxGetStatus((vx_reference)capture_obj->node);}return status;
}

set the dequeue&&enqueue param is like this

obj->pipeline_dep = 7void add_graph_parameter_by_node_index(vx_graph graph, vx_node node, vx_uint32 node_parameter_index)
{vx_parameter parameter = vxGetParameterByIndex(node, node_parameter_index);vxAddParameterToGraph(graph, parameter);vxReleaseParameter(&parameter);
}add_graph_parameter_by_node_index(obj->avm_graph, obj->capture_obj.node, 1);vx_graph_parameter_queue_params_t graph_parameters_queue_params_list[2];
graph_parameters_queue_params_list[0].graph_parameter_index = 0;
graph_parameters_queue_params_list[0].refs_list_size = obj->num_buf;
graph_parameters_queue_params_list[0].refs_list = (vx_reference*)&obj->frames[0];vxSetGraphScheduleConfig(obj->avm_graph,VX_GRAPH_SCHEDULE_MODE_QUEUE_AUTO,1,graph_parameters_queue_params_list);
tivxSetGraphPipelineDepth(obj->avm_graph, obj->pipeline_dep);

at last, get the frame is by these code

obj->num_buf = 4
vx_status tsovx_avm_apa_run_graph(AVMObject *obj)
{uint32_t num_refs, loop_id = 0;for(uint32_t buf_id=0; buf_id<obj->num_buf-2; buf_id++) {tivxGraphParameterEnqueueReadyRef(obj->avm_graph, 0, (vx_reference*)&obj->frames[buf_id], 1, TIVX_GRAPH_PARAMETER_ENQUEUE_FLAG_PIPEUP);}vxGraphParameterEnqueueReadyRef(obj->avm_graph, 0, (vx_reference*)&obj->frames[obj->num_buf-2], 1);/* After first trigger, start the sensor */vx_status status = appRemoteServiceRun(APP_IPC_CPU_MCU2_0,APP_REMOTE_SERVICE_SENSOR_NAME,APP_REMOTE_SERVICE_SENSOR_CMD_CONFIG_IMX390, &obj->cmdPrms, sizeof(obj->cmdPrms), 0);if(VX_SUCCESS!=status) {ZF_LOGE("appRemoteServiceRun is error");return status;}/* Need to trigger again since display holds on to a buffer */vxGraphParameterEnqueueReadyRef(obj->avm_graph, 0, (vx_reference*)&obj->frames[obj->num_buf-1], 1);if (obj->encode_conf.option != 0)vxGraphParameterEnqueueReadyRef(obj->avm_graph, 1, (vx_reference*)&obj->encode_obj.bitstream_obj, 1);while(1) {vx_object_array frame;/* Get output reference, waits until a frame is available */vxGraphParameterDequeueDoneRef(obj->avm_graph, 0, (vx_reference*)&frame, 1, &num_refs);/* Recycles dequeued input and output refs *//* input and output can be enqueued in any order */vxGraphParameterEnqueueReadyRef(obj->avm_graph, 0, (vx_reference*)&frame, 1);}/* ensure all graph processing is complete */vxWaitGraph(obj->avm_graph);return VX_SUCCESS;
}

The CaptureNode is run in first graph

My project need to run two thread, both of them need the capture node's result, I want to use dequeue&&enqueue to get themBecause I think if two thread run dequeue&&enqueue by the same index in vxGraphParameterDequeueDoneRef is not right.I want to know how to set capture node result to different pipeline or I just need to use dequeue&&enqueue in different thread, and there is no problem, no lost frame.

Thank you

Best regard

,

Cherry Zhou:

Hi,

Please refer the below FAQ which consists of the implementation of single cam demo in 2 graphs where output of capture node is fed to the secondary graph.https://e2e.ti.com/support/processors/f/791/t/1078116 There wouldn't be any lost frame in this scenario.We would suggest to keep the capture node is kept in a separate graph and the frames are dequeued from this graph and enqueued in avm graph and deeplearning graph.

Thanks.

,

dong yuwei:

Hello,

I see this FAQ, but it is created by RTOS 8.1. For company reason, I have to use RTOS 7.3, so is it can be used in this version?

And it is single camera, but I need to use 4 camera, is there any special thing I should to focus on?

Thanks

,

Cherry Zhou:

Hi,

Sorry for the delay.Yes, This could be extended for Multi-cam scenario. Please find the below patch that consists of changes to be done to multi-cam demo (PSDKRA/vision_apps/apps/basic_demos/app_multi_cam/) in order to run it in a dual graph, where the first graph consists only capture node and the second graph consists of the rest of the processing nodes.This patch is on SDK 8.1, but it could also be applied on SDK 7.3./cfs-file/__key/communityserver-discussions-components-files/791/Dual_5F00_Graph_5F00_Multicam.zip

Thanks.

,

dong yuwei:

ok, I will try to run this one

,

dong yuwei:

Thank you, it's ok now

赞(0)
未经允许不得转载:TI中文支持网 » TDA4VM: how to send frame to two thread by CaptureNode
分享到: 更多 (0)