Perception Tool Kit (PTK) API Guide
create_og.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (c) 2020 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 #ifndef _CREATE_OG_H
63 #define _CREATE_OG_H
64 
65 #ifdef __cplusplus
66 extern "C" {
67 #endif
68 
69 #include <perception/perception.h>
72 #include <perception/base/matrix.h>
73 #include <stdbool.h>
74 
75 #define GRID_MAX_HEIGHT 2000 // 2m
76 #define GRID_MIN_HEIGHT -1000 // -1m
77 
78 #define MAX_CLASS_NUM_IN_GRID 5
79 
83 #define QUAD_LATERAL_BB 0
84 
85 
90 typedef enum
91 {
95 
100 typedef enum
101 {
105 
106 
118 typedef struct {
120  uint8_t classId;
121 
122  // pf4 pf3
123  // pf1 pf2
125  float pf1x;
127  float pf1y;
129  float pf2x;
131  float pf2y;
133  float pf3x;
135  float pf3y;
137  float pf4x;
139  float pf4y;
140 
141  // pr4 pr3
142  // pr1 pr2
144  float pr1x;
146  float pr1y;
148  float pr2x;
150  float pr2y;
152  float pr3x;
154  float pr3y;
156  float pr4x;
158  float pr4y;
159 
161  float frontDepth;
163  float rearDepth;
164 
173 
175 
176 
181 typedef struct {
183  int16_t numObject;
184 
186  uint32_t bbOffset;
188 
193 typedef struct
194 {
196  int16_t width;
197 
199  int16_t height;
200 
203 
206 
209 
215 
217 
222 typedef struct
223 {
225  int32_t camHeight;
226 
228  float camRoll;
229 
231  float camPitch;
232 
234  float camYaw;
235 
237  float sinPitch;
238 
240  float cosPitch;
241 
243  int32_t baseline;
244 
246  float dcx;
247 
249  float dcy;
250 
252  float f;
253 
256 
259 
261 
262 
267 typedef struct
268 {
270  int32_t xGridSize;
271 
273  int32_t yGridSize;
274 
276  int32_t xMinRange;
277 
279  int32_t xMaxRange;
280 
282  int32_t yMinRange;
283 
285  int32_t yMaxRange;
286 
287  /* Number of grids in X dimension */
288  int32_t xGridNum;
289 
290  /* Number of grids in Y dimension */
291  int32_t yGridNum;
292 
294  int16_t thCnt;
295 
297  int16_t thObjCnt;
298 
300  int16_t maxNumObject;
301 
303  int16_t cNeighNum;
304 
306 
307 
312 typedef struct
313 {
316 
319 
322 
324 
325 
330 typedef struct
331 {
333  int8_t * numClass; // xGridNum * yGridNum
334 
336  int16_t * maxHeight; // xGridNum * yGridNum * MAX_CLASS_NUM_IN_GRID
337 
339  int16_t * minHeight; // xGridNum * yGridNum * MAX_CLASS_NUM_IN_GRID
340 
342  uint8_t * classId; // xGridNum * yGridNum * MAX_CLASS_NUM_IN_GRID
343 
345  int16_t * count; // xGridNum * yGridNum * MAX_CLASS_NUM_IN_GRID
346 
348 
353 typedef struct
354 {
356  int8_t * occupied; // xGridNum * yGridNum
357 
359  int16_t * maxHeight; // xGridNum * yGridNum
360 
362  int16_t * minHeight; // xGridNum * yGridNum
363 
365  uint8_t * classId; // xGridNum * yGridNum
366 
368  int16_t * count; // xGridNum * yGridNum
369 
371 
372 
377 typedef struct
378 {
380  int16_t numObject;
381 
383  uint8_t * classId; // MAX_NUM_OBJECT
384 
386  int16_t * count; // MAX_NUM_OBJECT
387 
389  int16_t * maxHeight; // MAX_NUM_OBJECT
390 
392  int16_t * minHeight; // MAX_NUM_OBJECT
393 
395  int16_t * maxObjXGrid; // MAX_NUM_OBJECT
396 
398  int16_t * minObjXGrid; // MAX_NUM_OBJECT
399 
401  int16_t * maxObjYGrid; // MAX_NUM_OBJECT
402 
404  int16_t * minObjYGrid; // MAX_NUM_OBJECT
405 
407  uint8_t * merged; // MAX_NUM_OBJECT
408 
409 #if QUAD_LATERAL_BB
410 
411  int16_t * maxObjXGridYPos; // MAX_NUM_OBJECT
412 
414  int16_t * minObjXGridYPos; // MAX_NUM_OBJECT
415 
417  int16_t * maxObjYGridXPos; // MAX_NUM_OBJECT
418 
420  int16_t * minObjYGridXPos; // MAX_NUM_OBJECT
421 #endif
422 
424  int16_t * width;
425 
427  int16_t * height;
428 
430  float * centerX;
431 
433  float * centerY;
434 
438  int16_t * age;
439 
441  uint8_t * visible;
442 
446  uint8_t * invisibleSpan;
447 
449  int16_t * correspondence;
450 
452  float * dx;
453 
455  float * dy;
457 
458 
463 typedef struct
464 {
468  int32_t numGridInQueue;
469 
471  int8_t * visited; // xGridNum * yGridNum
472 
474  int32_t * neighborQueue; // xGridNum * yGridNum
475 
477  int32_t * neighborIndex; // xGridNum * yGridNum
478 
480 
481 
486 typedef struct
487 {
490 
493 
496 
499 
502 
505 
508 
511 
514 
517 
519 
520 
532 
533 
544 
569  PTK_Api_MemoryReq * memReq);
570 
586  const PTK_Api_MemoryRsp * memRsp);
587 
598  PTK_PointCloud * pc,
599  PTK_Alg_StereoOG_obs3DBox * obsBB);
600 
612 int32_t PTK_Alg_StereoOG_CreateOGGetMem(PTK_Alg_StereoOG_CreateOGObj * cntxt, uint8_t *memPtr);
613 
614 
626 int32_t PTK_Alg_StereoOG_getGridPropMem(PTK_Alg_StereoOG_CreateOGObj * cntxt, uint8_t *memPtr);
627 
639 int32_t PTK_Alg_StereoOG_getOGMem(PTK_Alg_StereoOG_CreateOGObj * cntxt, uint8_t *memPtr);
640 
641 
655 
656 
668 int32_t PTK_Alg_StereoOG_getOGConnMem(PTK_Alg_StereoOG_CreateOGObj * cntxt, uint8_t *memPtr);
669 
670 
682 
694 
706  PTK_Point * points,
707  int32_t numPoints);
708 
718 
734  PTK_Alg_StereoOG_OGConn * ogConn,
735  int32_t idx,
736  int32_t xIdx,
737  int32_t yIdx);
738 
754  PTK_Alg_StereoOG_OGConn * ogConn,
755  int32_t idx,
756  int32_t xIdx,
757  int32_t yIdx);
758 
767 
782  PTK_Alg_StereoOG_Object *newObj,
783  int32_t gridSize,
784  int16_t index);
785 
794 
806  PTK_Alg_StereoOG_Object *srcObj,
807  PTK_Alg_StereoOG_Object *refObj,
808  uint8_t direction);
809 
821  PTK_Alg_StereoOG_Object *curObj,
822  PTK_Alg_StereoOG_Object *prevObj);
823 
835 
850 float PTK_Alg_StereoOG_computeDistanceObjects(uint8_t mode,
853  int16_t idx1,
854  int16_t idx2);
855 
866  PTK_Alg_StereoOG_Object * object,
867  PTK_Alg_StereoOG_obs3DBox * obsBB);
868 
883  PTK_Alg_StereoOG_Object *dstObj,
884  int16_t srcIdx,
885  int16_t dstIdx);
886 
895 
904 
905 #ifdef __cplusplus
906 }
907 #endif
908 
909 #endif // #ifndef _CREATE_OG_H
PTK_Alg_StereoOG_Object * curObject
Definition: create_og.h:507
float cosPitch
Definition: create_og.h:240
float pr1x
Definition: create_og.h:144
uint8_t * visible
Definition: create_og.h:441
int16_t * count
Definition: create_og.h:345
int16_t cNeighNum
Definition: create_og.h:303
int16_t * maxHeight
Definition: create_og.h:336
float topLeftGridY
Definition: create_og.h:168
int16_t * width
Definition: create_og.h:424
int16_t * minObjYGrid
Definition: create_og.h:404
int16_t * height
Definition: create_og.h:427
uint8_t * merged
Definition: create_og.h:407
float camYaw
Definition: create_og.h:234
int16_t getNeighbor24Idx(PTK_Alg_StereoOG_CreateOGParams *ogParams, PTK_Alg_StereoOG_OGConn *ogConn, int32_t idx, int32_t xIdx, int32_t yIdx)
Find 24 neighboring grids.
int32_t * neighborIndex
Definition: create_og.h:477
float * centerY
Definition: create_og.h:433
float pf1y
Definition: create_og.h:127
int16_t * minHeight
Definition: create_og.h:362
Stereo OG Map creation process - OG Parameters.
Definition: create_og.h:267
int16_t * maxObjYGrid
Definition: create_og.h:401
int16_t * minHeight
Definition: create_og.h:392
int16_t * minObjXGrid
Definition: create_og.h:398
int16_t thCnt
Definition: create_og.h:294
float camRoll
Definition: create_og.h:228
float pr2y
Definition: create_og.h:150
uint8_t classId
Definition: create_og.h:120
void PTK_Alg_StereoOG_copyObjectInfo(PTK_Alg_StereoOG_Object *srcObj, PTK_Alg_StereoOG_Object *dstObj, int16_t srcIdx, int16_t dstIdx)
Merge neighboring objects.
Stereo algorithm - OG Map creation context.
Definition: create_og.h:486
float dcx
Definition: create_og.h:246
Definition of a 3x3 matrix.
Definition: matrix.h:119
float pr2x
Definition: create_og.h:148
uint8_t * classId
Definition: create_og.h:342
float pr4y
Definition: create_og.h:158
int32_t PTK_Alg_StereoOG_CreateOGGetMem(PTK_Alg_StereoOG_CreateOGObj *cntxt, uint8_t *memPtr)
Get memory size.
int8_t * occupied
Definition: create_og.h:356
int16_t maxNumObject
Definition: create_og.h:300
void PTK_Alg_StereoOG_resetOG(PTK_Alg_StereoOG_CreateOGObj *cntxt)
Reset OG.
int16_t * minHeight
Definition: create_og.h:339
float pf1x
Definition: create_og.h:125
Stereo OG Map creation process - Grid Property struct.
Definition: create_og.h:330
PTK_Alg_StereoOG_CreateOGConfigParams cfgParams
Definition: create_og.h:315
Stereo OG Map creation process - 3D bounding boxes.
Definition: create_og.h:181
int16_t * count
Definition: create_og.h:386
float pr3x
Definition: create_og.h:152
void PTK_Alg_StereoOG_mergeObjectsTemporal(PTK_Alg_StereoOG_CreateOGObj *cntxt, int8_t direction)
Merge the current (or previous) frame&#39;s object, which does not have correspondences in the prvious ...
void PTK_Alg_StereoOG_addPoints(PTK_Alg_StereoOG_CreateOGObj *cntxt, PTK_Point *points, int32_t numPoints)
Add point clouds to OG map.
int16_t * age
Definition: create_og.h:438
float frontDepth
Definition: create_og.h:161
float pf2y
Definition: create_og.h:131
void * PTK_AlgHandle
Algorithm Handle.
Definition: alg_common.h:79
uint8_t * classId
Definition: create_og.h:383
OBJECT_CORRESPONDENCE
Definition: create_og.h:100
int32_t PTK_Alg_StereoOG_CreateOGConfig(PTK_Alg_StereoOG_CreateOGAllParams *params, PTK_Api_MemoryReq *memReq)
Computes the memory requirements based on the given algorithm configuration parameters.
Definition: pointCloud.h:129
int16_t height
Definition: create_og.h:199
float * dx
Definition: create_og.h:452
int32_t xMaxRange
Definition: create_og.h:279
float * centerX
Definition: create_og.h:430
int32_t PTK_Alg_StereoOG_getOGMem(PTK_Alg_StereoOG_CreateOGObj *cntxt, uint8_t *memPtr)
Get memory size for OG map.
int16_t numObject
Definition: create_og.h:380
int32_t numGridInQueue
Definition: create_og.h:468
int16_t * count
Definition: create_og.h:368
uint8_t enableTemporalObjMerge
Definition: create_og.h:205
PTK_Alg_StereoOG_obs3DBox * PTK_Alg_StereoOG_initObsBB(uint8_t *memPtr)
Initialize bouning box structure using the given chunk of memory.
void PTK_Alg_StereoOG_CreateOGSetParams(PTK_Alg_StereoOG_CreateOGAllParams *params, PTK_Alg_StereoOG_CreateOGObj *cntxt)
Initialize OG Map creation parameters.
OBJECT_SEARCH_DIRECTION
Definition: create_og.h:90
int32_t PTK_Alg_StereoOG_getObjMem(PTK_Alg_StereoOG_CreateOGObj *cntxt, PTK_Alg_StereoOG_Object *obj, uint8_t *memPtr)
Get memory size for OG objects.
int16_t * maxHeight
Definition: create_og.h:359
uint8_t enableSpatialObjMerge
Definition: create_og.h:202
int32_t yMinRange
Definition: create_og.h:282
int16_t numObject
Definition: create_og.h:183
int32_t yMaxRange
Definition: create_og.h:285
int16_t * maxObjXGrid
Definition: create_og.h:395
void PTK_Alg_StereoOG_createBB(PTK_Alg_StereoOG_CreateOGObj *cntxt, PTK_Alg_StereoOG_Object *object, PTK_Alg_StereoOG_obs3DBox *obsBB)
Create 3D bounding boxes for detected objects.
float dcy
Definition: create_og.h:249
float bottomRightGridX
Definition: create_og.h:170
void PTK_Alg_StereoOG_resetTemporalReference(PTK_Alg_StereoOG_CreateOGObj *cntxt)
Reset temporal object reference.
int16_t * correspondence
Definition: create_og.h:449
PTK_Alg_StereoOG_CreateOGAllParams params
Definition: create_og.h:489
void PTK_Alg_StereoOG_findCorrespondence(PTK_Alg_StereoOG_CreateOGObj *cntxt, PTK_Alg_StereoOG_Object *srcObj, PTK_Alg_StereoOG_Object *refObj, uint8_t direction)
Find corresponding objects in two frames.
Stereo OG Map creation process - 3D bounding box property.
Definition: create_og.h:118
PTK_Alg_StereoOG_OccupancyGrid og
Definition: create_og.h:495
void PTK_Alg_StereoOG_applyTemporalFilter(PTK_Alg_StereoOG_CreateOGObj *cntxt)
Apply temporal filtering of objects.
void PTK_Alg_StereoOG_mergeObjects(PTK_Alg_StereoOG_CreateOGObj *cntxt)
Merge neighboring objects.
PTK_Alg_StereoOG_OGConn ogConn
Definition: create_og.h:516
float pr1y
Definition: create_og.h:146
PTK_Alg_StereoOG_Object object2
Definition: create_og.h:501
int32_t xGridNum
Definition: create_og.h:288
PTK_AlgHandle PTK_Alg_StereoOG_CreateOGInit(PTK_Alg_StereoOG_CreateOGAllParams *params, const PTK_Api_MemoryRsp *memRsp)
Initializes the library based on the given algorithm configuration parameters and allocated memory bl...
PTK_Alg_StereoOG_GridProp gridProp
Definition: create_og.h:492
PTK_Alg_StereoOG_CreateOGCamParams camParams
Definition: create_og.h:318
PTK_Alg_StereoOG_BoxProp * PTK_Alg_StereOG_get3DBB(PTK_Alg_StereoOG_obs3DBox *obsBB)
Get bounding box pointer.
Declarations for PTK_Matrix struct+functions.
float PTK_Alg_StereoOG_computeDistanceObjects(uint8_t mode, PTK_Alg_StereoOG_Object *obj1, PTK_Alg_StereoOG_Object *obj2, int16_t idx1, int16_t idx2)
Merge neighboring objects.
float rearDepth
Definition: create_og.h:163
int32_t PTK_Alg_StereoOG_getGridPropMem(PTK_Alg_StereoOG_CreateOGObj *cntxt, uint8_t *memPtr)
Get memory size for GridProp mem.
int32_t xGridSize
Definition: create_og.h:270
int32_t baseline
Definition: create_og.h:243
Stereo OG Map creation process - Object struct.
Definition: create_og.h:377
Definition of a point.
Definition: point.h:136
uint32_t bbOffset
Definition: create_og.h:186
int8_t * numClass
Definition: create_og.h:333
PTK_3D_Matrix K
Definition: create_og.h:255
int16_t thObjCnt
Definition: create_og.h:297
Definition: create_og.h:103
PTK_Alg_StereoOG_CreateOGParams ogParams
Definition: create_og.h:321
PTK_3D_Matrix invK
Definition: create_og.h:258
float pf4x
Definition: create_og.h:137
Stereo OG Map creation process - OGConn struct.
Definition: create_og.h:463
void PTK_Alg_StereoOG_associateCorrespondence(PTK_Alg_StereoOG_CreateOGObj *cntxt, PTK_Alg_StereoOG_Object *curObj, PTK_Alg_StereoOG_Object *prevObj)
Associate the objects in the current frame to the previous frame&#39;s object. The assocaited objects shu...
API memory allocation response.
Definition: api_memory_if.h:158
int32_t xMinRange
Definition: create_og.h:276
int8_t * visited
Definition: create_og.h:471
int16_t * maxHeight
Definition: create_og.h:389
int32_t yGridNum
Definition: create_og.h:291
Definition: create_og.h:102
uint8_t enableTemporalObjSmoothing
Definition: create_og.h:208
void PTK_Alg_StereoOG_createOG(PTK_Alg_StereoOG_CreateOGObj *cntxt, PTK_PointCloud *pc, PTK_Alg_StereoOG_obs3DBox *obsBB)
Root function to create OG map from point clouds.
float * dy
Definition: create_og.h:455
int32_t PTK_Alg_StereoOG_getOGConnMem(PTK_Alg_StereoOG_CreateOGObj *cntxt, uint8_t *memPtr)
Get memory size for connected component analysis.
int32_t camHeight
Definition: create_og.h:225
float pf4y
Definition: create_og.h:139
float pr4x
Definition: create_og.h:156
int16_t width
Definition: create_og.h:196
float pf3y
Definition: create_og.h:135
PTK_Alg_StereoOG_Object object1
Definition: create_og.h:498
PTK_Alg_StereoOG_Object * auxObject
Definition: create_og.h:510
uint8_t * classId
Definition: create_og.h:365
int32_t * neighborQueue
Definition: create_og.h:474
API memory allocation request.
Definition: api_memory_if.h:125
uint8_t objectDistanceMode
Definition: create_og.h:214
float pf3x
Definition: create_og.h:133
float pf2x
Definition: create_og.h:129
PTK_Alg_StereoOG_Object * prevObject
Definition: create_og.h:513
PTK_Alg_StereoOG_Object object3
Definition: create_og.h:504
int16_t getNeighbor8Idx(PTK_Alg_StereoOG_CreateOGParams *ogParams, PTK_Alg_StereoOG_OGConn *ogConn, int32_t idx, int32_t xIdx, int32_t yIdx)
Find 8 neighboring grids.
bool PTK_Alg_StereoOG_mergeTwoObjects(PTK_Alg_StereoOG_Object *curObj, PTK_Alg_StereoOG_Object *newObj, int32_t gridSize, int16_t index)
Merge neighboring objects.
Stereo OG Map creation process - All algorithm Parameters.
Definition: create_og.h:312
float f
Definition: create_og.h:252
Stereo algorithm - camera Parameters.
Definition: create_og.h:222
void PTK_Alg_StereoOG_CCA(PTK_Alg_StereoOG_CreateOGObj *cntxt)
Connected component analysis.
Definition: create_og.h:92
Definition: create_og.h:93
float pr3y
Definition: create_og.h:154
float topLeftGridX
Definition: create_og.h:166
uint32_t PTK_Alg_StereoOG_getObsBBSize(const PTK_Alg_StereoOG_CreateOGParams *ogParams)
Get memory size for object 3D bounding box on image without allocating memory.
float sinPitch
Definition: create_og.h:237
uint8_t * invisibleSpan
Definition: create_og.h:446
float camPitch
Definition: create_og.h:231
Stereo OG Map creation process - config Parameters.
Definition: create_og.h:193
Stereo OG Map creation process - OG struct.
Definition: create_og.h:353
int32_t yGridSize
Definition: create_og.h:273
float bottomRightGridY
Definition: create_og.h:172