commit 8d40e6e8591783faeae9c620e60a8550a602f1c9
Author: Nikhil Dasan <n-dasan@ti.com>
Date:   Tue Nov 28 14:42:33 2023 +0530

    Modified code
    
    Signed-off-by: Nikhil Dasan <n-dasan@ti.com>

diff --git a/apps/dl_demos/app_tidl_od_cam/app_draw_detections_module.c b/apps/dl_demos/app_tidl_od_cam/app_draw_detections_module.c
index 5adb437..2ba1a72 100644
--- a/apps/dl_demos/app_tidl_od_cam/app_draw_detections_module.c
+++ b/apps/dl_demos/app_tidl_od_cam/app_draw_detections_module.c
@@ -148,8 +148,6 @@ vx_status app_create_graph_draw_detections(vx_graph           graph,
     {
         status = vxSetReferenceName((vx_reference)drawDetectionsObj->node, "DrawBoxDetectionsNode");
     }
-    vx_bool replicate[] = {vx_false_e, vx_true_e, vx_true_e, vx_true_e};
-    vxReplicateNode(graph, drawDetectionsObj->node, replicate, 4);
     vxReleaseTensor(&input_tensor);
     vxReleaseImage(&input_image);
     status = vxReleaseImage(&output_image);
diff --git a/apps/dl_demos/app_tidl_od_cam/app_pre_proc_module.c b/apps/dl_demos/app_tidl_od_cam/app_pre_proc_module.c
index 87cae28..4c2ba09 100644
--- a/apps/dl_demos/app_tidl_od_cam/app_pre_proc_module.c
+++ b/apps/dl_demos/app_tidl_od_cam/app_pre_proc_module.c
@@ -174,9 +174,6 @@ vx_status app_create_graph_pre_proc(vx_graph graph, PreProcObj *preProcObj, vx_o
     status = vxSetNodeTarget(preProcObj->node, VX_TARGET_STRING, TIVX_TARGET_DSP1);
     vxSetReferenceName((vx_reference)preProcObj->node, "PreProcNode");
 
-    vx_bool replicate[] = {vx_false_e, vx_true_e, vx_true_e};
-    vxReplicateNode(graph, preProcObj->node, replicate, 3);
-
     vxReleaseImage(&input);
     vxReleaseTensor(&output);
 
diff --git a/apps/dl_demos/app_tidl_od_cam/main.c b/apps/dl_demos/app_tidl_od_cam/main.c
index 33fc6d8..7819d1b 100644
--- a/apps/dl_demos/app_tidl_od_cam/main.c
+++ b/apps/dl_demos/app_tidl_od_cam/main.c
@@ -103,6 +103,8 @@ typedef struct {
     vx_context context;
     vx_graph   graph;
 
+    vx_image display_image;
+
     vx_uint32 is_interactive;
 
     vx_uint32 num_frames_to_run;
@@ -171,6 +173,9 @@ static char menu[] = {
     "\n"
     "\n p: Print performance statistics"
     "\n"
+    "\n"
+    "\n c: Switch channel"
+    "\n"
     "\n x: Exit"
     "\n"
     "\n Enter Choice: "
@@ -222,6 +227,9 @@ static vx_status app_run_graph_interactive(AppObj *obj)
     char ch;
     FILE *fp;
     app_perf_point_t *perf_arr[1];
+    tivx_select_channel_t channel_prms;
+    tivx_select_postchannel_t channel_prms1;
+    vx_reference refs1[1], refs2[1];
 
     status = app_run_task_create(obj);
     if(status != VX_SUCCESS)
@@ -231,6 +239,11 @@ static vx_status app_run_graph_interactive(AppObj *obj)
     else
     {
         appPerfStatsResetAll();
+        
+        vx_user_data_object switch_ch_obj = vxCreateUserDataObject(obj->context, "tivx_select_channel_t", sizeof(tivx_select_channel_t), &channel_prms);
+        vx_user_data_object switch_postch_obj = vxCreateUserDataObject(obj->context, "tivx_select_postchannel_t", sizeof(tivx_select_postchannel_t), &channel_prms);
+        channel_prms.active_channel = 0;
+        channel_prms1.active_channel = 0;
         while(!done && (status == VX_SUCCESS))
         {
             printf(menu);
@@ -265,6 +278,17 @@ static vx_status app_run_graph_interactive(AppObj *obj)
                         printf("fp is null\n");
                     }
                     break;
+                case 'c':
+                    channel_prms.active_channel = (channel_prms.active_channel + 1) % obj->sensorObj.num_cameras_enabled;
+                    channel_prms1.active_channel = (channel_prms1.active_channel + 1) % obj->sensorObj.num_cameras_enabled;
+                    vxCopyUserDataObject(switch_ch_obj, 0, sizeof(tivx_select_channel_t), &channel_prms, VX_WRITE_ONLY, VX_MEMORY_TYPE_HOST);
+                    vxCopyUserDataObject(switch_postch_obj, 0, sizeof(tivx_select_postchannel_t), &channel_prms1, VX_WRITE_ONLY, VX_MEMORY_TYPE_HOST);
+                    refs1[0] = (vx_reference)switch_ch_obj;
+                    refs2[0] = (vx_reference)switch_postch_obj;
+                    status = tivxNodeSendCommand(obj->preProcObj.node, 0u, TIVX_SWITCH_CHANNEL, refs1, 1u);
+                    status = tivxNodeSendCommand(obj->drawDetectionsObj.node, 0u, TIVX_SWITCH_POST_CHANNEL, refs2, 1u);
+                    printf("App Send Command Done!\n");
+                    break;
 #ifdef APP_WRITE_INTERMEDIATE_OUTPUTS
                 case 's':
                     obj->write_file = 1;
@@ -273,6 +297,8 @@ static vx_status app_run_graph_interactive(AppObj *obj)
                 case 'x':
                     obj->stop_task = 1;
                     done = 1;
+                    vxReleaseUserDataObject(&switch_ch_obj);
+                    vxReleaseUserDataObject(&switch_postch_obj);
                     break;
             }
         }
@@ -693,11 +719,11 @@ static vx_status app_init(AppObj *obj)
     APP_PRINTF("Scaler init done!\n");
 
     /* Initialize TIDL first to get tensor I/O information from network */
-    app_init_tidl(obj->context, &obj->tidlObj, "tidl_obj", obj->sensorObj.num_cameras_enabled);
+    app_init_tidl(obj->context, &obj->tidlObj, "tidl_obj", 1);
     APP_PRINTF("TIDL Init Done! \n");
 
     /* Update pre-proc parameters with TIDL config before calling init */
-    app_update_pre_proc(obj->context, &obj->preProcObj, obj->tidlObj.config, obj->sensorObj.num_cameras_enabled);
+    app_update_pre_proc(obj->context, &obj->preProcObj, obj->tidlObj.config, 1);
     APP_PRINTF("Pre Proc Update Done! \n");
 
     app_init_pre_proc(obj->context, &obj->preProcObj, "pre_proc_obj");
@@ -707,12 +733,9 @@ static vx_status app_init(AppObj *obj)
     app_update_draw_detections(&obj->drawDetectionsObj, obj->tidlObj.config);
     APP_PRINTF("Draw detections Update Done! \n");
 
-    app_init_draw_detections(obj->context, &obj->drawDetectionsObj, "draw_detections_obj", obj->sensorObj.num_cameras_enabled);
+    app_init_draw_detections(obj->context, &obj->drawDetectionsObj, "draw_detections_obj", 1);
     APP_PRINTF("Draw Detections Init Done! \n");
 
-    app_init_img_mosaic(obj->context, &obj->imgMosaicObj, "img_mosaic_obj", APP_BUFFER_Q_DEPTH);
-    APP_PRINTF("Img Mosaic init done!\n");
-
     app_init_display(obj->context, &obj->displayObj, "display_obj");
     APP_PRINTF("Display init done!\n");
 
@@ -760,8 +783,7 @@ static void app_deinit(AppObj *obj)
     app_deinit_draw_detections(&obj->drawDetectionsObj);
     APP_PRINTF("Draw detections deinit done!\n");
 
-    app_deinit_img_mosaic(&obj->imgMosaicObj, APP_BUFFER_Q_DEPTH);
-    APP_PRINTF("Img Mosaic deinit done!\n");
+    vxReleaseImage(&obj->display_image);
 
     app_deinit_display(&obj->displayObj);
     APP_PRINTF("Display deinit done!\n");
@@ -810,9 +832,6 @@ static void app_delete_graph(AppObj *obj)
     app_delete_draw_detections(&obj->drawDetectionsObj);
     APP_PRINTF("Post Proc delete done!\n");
 
-    app_delete_img_mosaic(&obj->imgMosaicObj);
-    APP_PRINTF("Img Mosaic delete done!\n");
-
     app_delete_display(&obj->displayObj);
     APP_PRINTF("Display delete done!\n");
 
@@ -879,19 +898,11 @@ static vx_status app_create_graph(AppObj *obj)
         APP_PRINTF("Draw detections graph done!\n");
     }
 
-    vx_int32 idx = 0;
-    obj->imgMosaicObj.input_arr[idx++] = obj->drawDetectionsObj.output_image_arr;
-    obj->imgMosaicObj.num_inputs = idx;
+    obj->display_image   = (vx_image)vxGetObjectArrayItem((vx_object_array)obj->drawDetectionsObj.output_image_arr, 0);
 
     if(status == VX_SUCCESS)
     {
-        status = app_create_graph_img_mosaic(obj->graph, &obj->imgMosaicObj, NULL);
-        APP_PRINTF("Img Mosaic graph done!\n");
-    }
-
-    if(status == VX_SUCCESS)
-    {
-        status = app_create_graph_display(obj->graph, &obj->displayObj, obj->imgMosaicObj.output_image[0]);
+        status = app_create_graph_display(obj->graph, &obj->displayObj, obj->display_image);
         APP_PRINTF("Display graph done!\n");
     }
 
@@ -929,8 +940,6 @@ static vx_status app_create_graph(AppObj *obj)
 
         tivxSetNodeParameterNumBufByIndex(obj->drawDetectionsObj.node, 3, APP_BUFFER_Q_DEPTH);
 
-        tivxSetNodeParameterNumBufByIndex(obj->imgMosaicObj.node, 1, APP_BUFFER_Q_DEPTH);
-
         APP_PRINTF("Pipeline params setup done!\n");
     }
 
diff --git a/modules/src/app_tidl_module.c b/modules/src/app_tidl_module.c
index 1c0325e..fcc0d1b 100644
--- a/modules/src/app_tidl_module.c
+++ b/modules/src/app_tidl_module.c
@@ -266,26 +266,6 @@ vx_status app_create_graph_tidl(vx_context context, vx_graph graph, TIDLObj *tid
     vxSetReferenceName((vx_reference)tidlObj->node, "tidl_node");
     vxSetNodeTarget(tidlObj->node, VX_TARGET_STRING, TIVX_TARGET_DSP_C7_1);
 
-    vx_bool replicate[16];
-    replicate[TIVX_KERNEL_TIDL_IN_CONFIG_IDX] = vx_false_e;
-    replicate[TIVX_KERNEL_TIDL_IN_NETWORK_IDX] = vx_false_e;
-    replicate[TIVX_KERNEL_TIDL_IN_CREATE_PARAMS_IDX] = vx_false_e;
-    replicate[TIVX_KERNEL_TIDL_IN_IN_ARGS_IDX] = vx_true_e;
-    replicate[TIVX_KERNEL_TIDL_IN_OUT_ARGS_IDX] = vx_true_e;
-    replicate[TIVX_KERNEL_TIDL_IN_TRACE_DATA_IDX] = vx_false_e;
-
-    for(i = 0; i < tidlObj->num_input_tensors; i++)
-    {
-      replicate[TIVX_KERNEL_TIDL_NUM_BASE_PARAMETERS + i] = vx_true_e;
-    }
-
-    for(i = 0; i < tidlObj->num_output_tensors; i++)
-    {
-      replicate[TIVX_KERNEL_TIDL_NUM_BASE_PARAMETERS + tidlObj->num_input_tensors + i] = vx_true_e;
-    }
-
-    vxReplicateNode(graph, tidlObj->node, replicate, TIVX_KERNEL_TIDL_NUM_BASE_PARAMETERS + tidlObj->num_input_tensors + tidlObj->num_output_tensors);
-
     for(i = 0; i < tidlObj->num_input_tensors; i++)
     {
         vxReleaseTensor(&input_tensor[i]);
