File size: 9,518 Bytes
6c7b14a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
Ticket Name: Integrating Vision Algorithm on Vision SDK TDA3

Query Text:
Other Parts Discussed in Thread: TDA2 In our project, we have algorithm for vision algorithm for adas camera monitoring system using in c. Which is already working in TDA2 EVM board. I need to integrated with framework which is based on Vision SDK provided by Texas Intruments. To under stand Vision SDK completely,i would like to do Image Negative. I have attached the image which was generated by VSDK user case generation Using user case generation, i have generated file adasens_issImageNegative_priv.c adasens_issImageNegative_priv.h My image negative input, output structure and function prototype are below. typedef struct { unsigned char *ptImageInput; //Input Image to unsigned int uiNoRows; unsigned int uiNoCols; }stImageNegativeInput; chains_vipSingleCameraEdgeDetection.c /*
 *******************************************************************************
 *
 * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
 * ALL RIGHTS RESERVED
 *
 *******************************************************************************
 */

/*******************************************************************************
 *  INCLUDE FILES
 *******************************************************************************
 */
#include "chains_vipSingleCameraEdgeDetection_priv.h"
#include <tda2xx/include/bios_chains_common.h>


#define CAPTURE_SENSOR_WIDTH      (1280)
#define CAPTURE_SENSOR_HEIGHT     (720)

/**
 *******************************************************************************
 *
 *  \brief  SingleCameraEdgeDetectionObject
 *
 *        This structure contains all the LinksId's and create Params.
 *        The same is passed to all create, start, stop functions.
 *
 *******************************************************************************
*/
typedef struct {

    chains_vipSingleCameraEdgeDetectionObj ucObj;

    UInt32  captureOutWidth;
    UInt32  captureOutHeight;
    UInt32  displayWidth;
    UInt32  displayHeight;

    Chains_Ctrl *chainsCfg;

} Chains_VipSingleCameraEdgeDetectionAppObj;

/**
 *******************************************************************************
 *
 * \brief   Set Edge Detection Alg parameters
 *
 *          It is called in Create function.
 *          In this function alg link params are set
 *          The algorithm which is to run on core is set to
 *          baseClassCreate.algId. The input whdth and height to alg are set.
 *          Number of input buffers required by alg are also set here.
 *
 *
 * \param   pPrm    [IN]    AlgorithmLink_EdgeDetectionCreateParams
 * \param   chainsCfg    [IN]    Chains_Ctrl
 *
 *******************************************************************************
*/
Void chains_vipSingleCameraEdgeDetection_SetEdgeDetectionAlgPrms(
    AlgorithmLink_EdgeDetectionCreateParams *pPrm,
    Chains_Ctrl *chainsCfg) {
    pPrm->maxWidth    = CAPTURE_SENSOR_WIDTH;
    pPrm->maxHeight   = CAPTURE_SENSOR_HEIGHT;

    pPrm->numOutputFrames = 3;
}


/**
 *******************************************************************************
 *
 * \brief   Set link Parameters
 *
 *          It is called in Create function of the auto generated use-case file.
 *
 * \param pUcObj    [IN] Auto-generated usecase object
 * \param appObj    [IN] Application specific object
 *
 *******************************************************************************
*/
Void chains_vipSingleCameraEdgeDetection_SetAppPrms(chains_vipSingleCameraEdgeDetectionObj *pUcObj,
        Void *appObj) {
    Chains_VipSingleCameraEdgeDetectionAppObj *pObj
        = (Chains_VipSingleCameraEdgeDetectionAppObj *)appObj;

    pObj->captureOutWidth  = CAPTURE_SENSOR_WIDTH;
    pObj->captureOutHeight = CAPTURE_SENSOR_HEIGHT;
    ChainsCommon_GetDisplayWidthHeight(
        pObj->chainsCfg->displayType,
        &pObj->displayWidth,
        &pObj->displayHeight
    );

    ChainsCommon_SingleCam_SetCapturePrms(&(pUcObj->CapturePrm),
                                          CAPTURE_SENSOR_WIDTH,
                                          CAPTURE_SENSOR_HEIGHT,
                                          pObj->captureOutWidth,
                                          pObj->captureOutHeight,
                                          pObj->chainsCfg->captureSrc
                                         );

    ChainsCommon_SetGrpxSrcPrms(&pUcObj->GrpxSrcPrm,
                                pObj->displayWidth,
                                pObj->displayHeight
                               );


    ChainsCommon_SetDisplayPrms(&pUcObj->Display_VideoPrm,
                                &pUcObj->Display_GrpxPrm,
                                pObj->chainsCfg->displayType,
                                pObj->displayWidth,
                                pObj->displayHeight
                               );

    ChainsCommon_StartDisplayCtrl(
        pObj->chainsCfg->displayType,
        pObj->displayWidth,
        pObj->displayHeight
    );

    chains_vipSingleCameraEdgeDetection_SetEdgeDetectionAlgPrms
    (&pUcObj->Alg_EdgeDetectPrm,
     pObj->chainsCfg);
}

/**
 *******************************************************************************
 *
 * \brief   Start the capture display Links
 *
 *          Function sends a control command to capture and display link to
 *          to Start all the required links . Links are started in reverce
 *          order as information of next link is required to connect.
 *          System_linkStart is called with LinkId to start the links.
 *
 * \param   pObj  [IN] Chains_VipSingleCameraEdgeDetectionAppObj
 *
 * \return  SYSTEM_LINK_STATUS_SOK on success
 *
 *******************************************************************************
*/
Void chains_vipSingleCameraEdgeDetection_StartApp(Chains_VipSingleCameraEdgeDetectionAppObj *pObj) {
    Chains_memPrintHeapStatus();

    ChainsCommon_StartDisplayDevice(pObj->chainsCfg->displayType);

    ChainsCommon_StartCaptureDevice(
        pObj->chainsCfg->captureSrc,
        pObj->captureOutWidth,
        pObj->captureOutHeight,1
    );

    chains_vipSingleCameraEdgeDetection_Start(&pObj->ucObj);

    Chains_prfLoadCalcEnable(TRUE, FALSE, FALSE);
}

/**
 *******************************************************************************
 *
 * \brief   Delete the capture display Links
 *
 *          Function sends a control command to capture and display link to
 *          to delete all the prior created links
 *          System_linkDelete is called with LinkId to delete the links.
 *
 * \param   pObj   [IN]   Chains_VipSingleCameraEdgeDetectionAppObj
 *
 *******************************************************************************
*/
Void chains_vipSingleCameraEdgeDetection_StopAndDeleteApp(Chains_VipSingleCameraEdgeDetectionAppObj
        *pObj) {
    chains_vipSingleCameraEdgeDetection_Stop(&pObj->ucObj);
    chains_vipSingleCameraEdgeDetection_Delete(&pObj->ucObj);

    ChainsCommon_StopDisplayCtrl();
    ChainsCommon_StopCaptureDevice(pObj->chainsCfg->captureSrc);
    ChainsCommon_StopDisplayDevice(pObj->chainsCfg->displayType);

    /* Print the HWI, SWI and all tasks load */
    /* Reset the accumulated timer ticks */
    Chains_prfLoadCalcEnable(FALSE, TRUE, TRUE);
}

/**
 *******************************************************************************
 *
 * \brief   Single Channel Capture Display usecase function
 *
 *          This functions executes the create, start functions
 *
 *          Further in a while loop displays run time menu and waits
 *          for user inputs to print the statistics or to end the demo.
 *
 *          Once the user inputs end of demo stop and delete
 *          functions are executed.
 *
 * \param   chainsCfg       [IN]   Chains_Ctrl
 *
 *******************************************************************************
*/
Void Chains_vipSingleCameraEdgeDetection(Chains_Ctrl *chainsCfg) {
    char ch;
    UInt32 done = FALSE;
    Chains_VipSingleCameraEdgeDetectionAppObj chainsObj;

    chainsObj.chainsCfg = chainsCfg;

    chains_vipSingleCameraEdgeDetection_Create(&chainsObj.ucObj, &chainsObj);

    chains_vipSingleCameraEdgeDetection_StartApp(&chainsObj);

    while(!done) {
        ch = Chains_menuRunTime();

        switch(ch) {
            case '0':
                done = TRUE;
                break;
            case 'p':
            case 'P':
                ChainsCommon_PrintStatistics();
                chains_vipSingleCameraEdgeDetection_printStatistics(&chainsObj.ucObj);
                break;
            default:
                Vps_printf("\nUnsupported option '%c'. Please try again\n", ch);
                break;
        }
    }

    chains_vipSingleCameraEdgeDetection_StopAndDeleteApp(&chainsObj);

}

 typedef struct { unsigned char *ptImageOutput; }stImageNegativeOutput; void ImageNegative(&stImageNegatvieInput,&stImageNegativeOutput); Assume that, chains_vipSingleCameraEdgeDetection.c(attched with this) is performing image negative. I have to call the ImageNegative for each frame. Can you please tell me, where i have to exactly call my ImageNegative fuctions and initialize the input and output structures.

Responses:
Hi, Algorithm is integrated into Algorithm Link in Vision SDK. You have to create an algorithm link plug-in for your algorithm. Please refer to Chapter 4 in Vision SDK Development Guide. For example, you can refer to ~\VISION_SDK_02_xx_xx_xx\vision_sdk\examples\tda2xx\src\alg_plugins\edgedetection.