Vision Apps User Guide
tivx_srv_kernels.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (c) 2019 Texas Instruments Incorporated
4  *
5  * All rights reserved not granted herein.
6  *
7  * Limited License.
8  *
9  * Texas Instruments Incorporated grants a world-wide, royalty-free, non-exclusive
10  * license under copyrights and patents it now or hereafter owns or controls to make,
11  * have made, use, import, offer to sell and sell ("Utilize") this software subject to the
12  * terms herein. With respect to the foregoing patent license, such license is granted
13  * solely to the extent that any such patent is necessary to Utilize the software alone.
14  * The patent license shall not apply to any combinations which include this software,
15  * other than combinations with devices manufactured by or for TI ("TI Devices").
16  * No hardware patent is licensed hereunder.
17  *
18  * Redistributions must preserve existing copyright notices and reproduce this license
19  * (including the above copyright notice and the disclaimer and (if applicable) source
20  * code license limitations below) in the documentation and/or other materials provided
21  * with the distribution
22  *
23  * Redistribution and use in binary form, without modification, are permitted provided
24  * that the following conditions are met:
25  *
26  * * No reverse engineering, decompilation, or disassembly of this software is
27  * permitted with respect to any software provided in binary form.
28  *
29  * * any redistribution and use are licensed by TI for use only with TI Devices.
30  *
31  * * Nothing shall obligate TI to provide you with source code for the software
32  * licensed and provided to you in object code.
33  *
34  * If software source code is provided to you, modification and redistribution of the
35  * source code are permitted provided that the following conditions are met:
36  *
37  * * any redistribution and use of the source code, including any resulting derivative
38  * works, are licensed by TI for use only with TI Devices.
39  *
40  * * any redistribution and use of any object code compiled from the source code
41  * and any resulting derivative works, are licensed by TI for use only with TI Devices.
42  *
43  * Neither the name of Texas Instruments Incorporated nor the names of its suppliers
44  *
45  * may be used to endorse or promote products derived from this software without
46  * specific prior written permission.
47  *
48  * DISCLAIMER.
49  *
50  * THIS SOFTWARE IS PROVIDED BY TI AND TI'S LICENSORS "AS IS" AND ANY EXPRESS
51  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
52  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
53  * IN NO EVENT SHALL TI AND TI'S LICENSORS BE LIABLE FOR ANY DIRECT, INDIRECT,
54  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
55  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
56  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
57  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
58  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
59  * OF THE POSSIBILITY OF SUCH DAMAGE.
60  *
61  */
62 
63 #ifndef TIVX_SRV_KERNELS_H_
64 #define TIVX_SRV_KERNELS_H_
65 
66 #include <VX/vx.h>
67 #include <VX/vx_kernels.h>
68 #include <math.h>
69 
70 #ifdef __cplusplus
71 extern "C" {
72 #endif
73 
74 
91 #define TIVX_MODULE_NAME_SRV "srv"
92 
111 #define TIVX_KERNEL_POSE_ESTIMATION_NAME "com.ti.srv.pose_estimation"
112 
116 #define TIVX_KERNEL_POINT_DETECT_NAME "com.ti.srv.point_detect"
117 
121 #define TIVX_KERNEL_GENERATE_3DBOWL_NAME "com.ti.srv.generate_3dbowl"
122 
126 #define TIVX_KERNEL_GENERATE_GPULUT_NAME "com.ti.srv.generate_gpulut"
127 
131 #define TIVX_KERNEL_GL_SRV_NAME "com.ti.srv.gl_srv"
132 
137 void tivxSrvLoadKernels(vx_context context);
138 
143 void tivxSrvUnLoadKernels(vx_context context);
144 
149 void tivxSrvPrintPerformance(vx_perf_t performance, uint32_t numPixels, const char* testName);
150 
156 
162 
168 
174 
175 #define SKIP 4 /*Subsample ratio */
176 /* Note: skip is hard-coded here to 4 for pipeline efficiency ... this value should match sv->subsampleratio */
177 #define LDC_LIB_DATA_TYPE 0 /* 0: float, 1:double */
178 #define LDC_U2D_TABLE_MAX_LENGTH (1024) /* maximum u2d table length allowed */
179 #define LDC_D2U_TABLE_MAX_LENGTH (1024) /* maximum d2d table length allowed */
180 #define LDC_MAX_NUM_CAMERAS (6) /* maximum number of cameras allowed */
181 #define FP_TO_DETECT 2
182 #define MAX_INPUT_CAMERAS 4
183 
184 /*data type*/
185 #if LDC_LIB_DATA_TYPE==2
186 typedef int32_t dtype;
187 #elif LDC_LIB_DATA_TYPE==1
188 typedef double dtype;
189 #elif LDC_LIB_DATA_TYPE==0
190 typedef float dtype;
191 #endif
192 
198 typedef struct {
204  int32_t lut_d2u_indMax;
208  int32_t lut_u2d_indMax;
212 
213 
219 typedef struct {
220  vx_uint8 enableSV_ACDetect;
221  vx_uint8 thresholdMode;
222  vx_uint8 windowMode;
223  vx_uint8 Ransac;
225  vx_int16 SVROIWidth;
226  vx_int16 SVROIHeight;
227  vx_int16 binarizeOffset;
228  vx_int16 borderOffset;
229  vx_int16 smallestCenter;
230  vx_int16 largestCenter;
231  vx_int16 maxWinWidth;
232  vx_int16 maxWinHeight;
233  vx_int16 maxBandLen;
234  vx_int16 minBandLen;
236  vx_int16 firstROITop;
237  vx_int16 firstROIBottom;
238  vx_int16 firstROILeft;
239  vx_int16 firstROIRight;
240  vx_int16 secondROITop;
241  vx_int16 secondROIBottom;
242  vx_int16 secondROILeft;
243  vx_int16 secondROIRight;
245  vx_int16 camera_id;
249 
256 typedef struct {
258 } svLdcLut_t;
259 
260 
261 
269 /* Each camera used FP_TO_DETECT * 8 entries */
270 /* The 8 entries are stored in y,x format for each 4 corners */
271 /* Starting from the top left corner */
272 typedef struct {
273  vx_int32 finalCorners [FP_TO_DETECT][8];
274  vx_int16 numFPDetected;
277 
278 
279 
285 typedef struct {
286  vx_uint8 Ransac;
287  vx_uint8 SingleChartPose;
288  vx_uint8 numCameras;
289  vx_uint8 rsv[1];
290  vx_int8 inChartPos [164];
293 
294 
301 typedef struct
302 {
303 
304  vx_int32 outcalmat[12*MAX_INPUT_CAMERAS];
305  vx_float32 scaled_outcalmat[12*MAX_INPUT_CAMERAS];
308 
309 
315 typedef struct {
316  vx_int32 offsetXleft;
317  vx_int32 offsetXright;
318  vx_int32 offsetYfront;
319  vx_int32 offsetYback;
321 } svGeometric_t;
322 
323 
330 typedef struct {
331  vx_int16 SVInCamFrmHeight;
332  vx_int16 SVInCamFrmWidth;
334  vx_int16 SVOutDisplayWidth;
335  vx_uint8 numCameras;
336  vx_int8 subsampleratio;
337  vx_int8 useWideBowl;
339 } svGpuLutGen_t;
340 
341 /*********************************
342  * GPU SRV STRUCTURES
343  *********************************/
349 typedef struct
350 {
351  uint32_t cam_bpp;
354 
355 #ifdef __cplusplus
356 }
357 #endif
358 
359 #endif /* TIVX_SRV_KERNELS_H_ */
360 
361 
int32_t lut_u2d_indMax
Definition: tivx_srv_kernels.h:208
vx_int16 maxWinHeight
Definition: tivx_srv_kernels.h:232
The point detect structure is the configuration data structure used by the TIVX_KERNEL_POINT_DETECT k...
Definition: tivx_srv_kernels.h:219
The svLdcLut_t structure is the configuration data structure for lens model used by the followig kern...
Definition: tivx_srv_kernels.h:256
vx_int16 SVOutDisplayHeight
Definition: tivx_srv_kernels.h:333
#define FP_TO_DETECT
Definition: tivx_srv_kernels.h:181
vx_int16 secondROIBottom
Definition: tivx_srv_kernels.h:241
vx_int16 SVROIHeight
Definition: tivx_srv_kernels.h:226
dtype lut_d2u_step
Definition: tivx_srv_kernels.h:205
vx_int32 offsetXright
Definition: tivx_srv_kernels.h:317
dtype distFocalLengthInv
Definition: tivx_srv_kernels.h:202
void tivxSrvUnLoadKernels(vx_context context)
Used for the Application to unload the srv kernels from the context.
dtype distCenterY
Definition: tivx_srv_kernels.h:200
#define LDC_D2U_TABLE_MAX_LENGTH
Definition: tivx_srv_kernels.h:179
vx_int8 subsampleratio
Definition: tivx_srv_kernels.h:336
vx_int16 secondROITop
Definition: tivx_srv_kernels.h:240
dtype lut_u2d_stepInv
Definition: tivx_srv_kernels.h:210
vx_int16 camera_id
Definition: tivx_srv_kernels.h:245
vx_int32 offsetYfront
Definition: tivx_srv_kernels.h:318
vx_uint8 numCameras
Definition: tivx_srv_kernels.h:335
dtype distFocalLength
Definition: tivx_srv_kernels.h:201
vx_int16 firstROILeft
Definition: tivx_srv_kernels.h:238
vx_int16 minBandLen
Definition: tivx_srv_kernels.h:234
vx_int32 offsetXleft
Definition: tivx_srv_kernels.h:316
vx_int32 offsetYback
Definition: tivx_srv_kernels.h:319
float dtype
Definition: tivx_srv_kernels.h:190
vx_int16 smallestCenter
Definition: tivx_srv_kernels.h:229
vx_int16 maxBandLen
Definition: tivx_srv_kernels.h:233
vx_uint8 windowMode
Definition: tivx_srv_kernels.h:222
vx_int16 borderOffset
Definition: tivx_srv_kernels.h:228
void tivxRegisterSrvTargetC66Kernels(void)
Function to register SRV Kernels on the c66 Target.
void tivxRegisterSrvTargetGpuKernels(void)
Function to register SRV Kernels on the gpu Target.
void tivxUnRegisterSrvTargetGpuKernels(void)
Function to un-register SRV Kernels on the gpu Target.
The svGpuLutGen_t structure is the configuration structure used by the following kernel(s) TIVX_KERNE...
Definition: tivx_srv_kernels.h:330
vx_int16 numFPDetected
Definition: tivx_srv_kernels.h:274
The svGeometric_t structure is the configuration data structure used by the TIVX_KERNEL_GENERATE_3DBO...
Definition: tivx_srv_kernels.h:315
vx_int16 SVROIWidth
Definition: tivx_srv_kernels.h:225
vx_int16 binarizeOffset
Definition: tivx_srv_kernels.h:227
vx_int16 secondROIRight
Definition: tivx_srv_kernels.h:243
vx_int16 firstROITop
Definition: tivx_srv_kernels.h:236
The data structure used by the SGX SRV kernel for SRV creation.
Definition: tivx_srv_kernels.h:349
vx_int16 SVInCamFrmWidth
Definition: tivx_srv_kernels.h:332
vx_uint8 Ransac
Definition: tivx_srv_kernels.h:286
The configuration data structure for representing lens model of a signle camera.
Definition: tivx_srv_kernels.h:198
vx_int16 minSampleInCluster
Definition: tivx_srv_kernels.h:235
uint32_t cam_bpp
Definition: tivx_srv_kernels.h:351
vx_int16 SVInCamFrmHeight
Definition: tivx_srv_kernels.h:331
The svACDetectStructFinalCorner_t structure is the configuration data structure containing detected p...
Definition: tivx_srv_kernels.h:272
#define MAX_INPUT_CAMERAS
Definition: tivx_srv_kernels.h:182
The svPoseEstimation_t structure is the configuration data structure used by the TIVX_KERNEL_POSE_EST...
Definition: tivx_srv_kernels.h:285
vx_int16 maxWinWidth
Definition: tivx_srv_kernels.h:231
vx_int16 largestCenter
Definition: tivx_srv_kernels.h:230
dtype distCenterX
Definition: tivx_srv_kernels.h:199
vx_int16 firstROIBottom
Definition: tivx_srv_kernels.h:237
vx_uint8 numCameras
Definition: tivx_srv_kernels.h:288
vx_uint8 thresholdMode
Definition: tivx_srv_kernels.h:221
dtype lut_d2u_stepInv
Definition: tivx_srv_kernels.h:206
#define LDC_MAX_NUM_CAMERAS
Definition: tivx_srv_kernels.h:180
vx_int16 firstROIRight
Definition: tivx_srv_kernels.h:239
vx_int16 secondROILeft
Definition: tivx_srv_kernels.h:242
#define LDC_U2D_TABLE_MAX_LENGTH
Definition: tivx_srv_kernels.h:178
void tivxSrvLoadKernels(vx_context context)
Used for the Application to load the srv kernels into the context.
dtype lut_u2d_step
Definition: tivx_srv_kernels.h:209
vx_uint8 Ransac
Definition: tivx_srv_kernels.h:223
vx_int16 SVOutDisplayWidth
Definition: tivx_srv_kernels.h:334
vx_uint8 enableSV_ACDetect
Definition: tivx_srv_kernels.h:220
The svACCalmatStruct_t structure is the structure containing calibration data used by the following k...
Definition: tivx_srv_kernels.h:301
void tivxUnRegisterSrvTargetC66Kernels(void)
Function to un-register SRV Kernels on the c66 Target.
void tivxSrvPrintPerformance(vx_perf_t performance, uint32_t numPixels, const char *testName)
Used to print the performance of the kernels.
vx_int8 useWideBowl
Definition: tivx_srv_kernels.h:337
vx_uint8 SingleChartPose
Definition: tivx_srv_kernels.h:287
int32_t lut_d2u_indMax
Definition: tivx_srv_kernels.h:204