TI Autonomous Driving Algorithms (TIADALG) Library User Guide
sfm_ti_tb.h
Go to the documentation of this file.
1 /*
2 * module name : Structure From Motion
3 *
4 * module descripton : Generates sparse 3D points from optical flow information in camera captured images
5 *
6 */
7 /*
8 
9 Copyright (c) {YEAR} Texas Instruments Incorporated
10 
11 All rights reserved not granted herein.
12 
13 Limited License.
14 
15 Texas Instruments Incorporated grants a world-wide, royalty-free, non-exclusive license under copyrights and patents it now or hereafter owns or controls to make, have made, use, import, offer to sell and sell ("Utilize") this software subject to the terms herein. With respect to the foregoing patent license, such license is granted solely to the extent that any such patent is necessary to Utilize the software alone. The patent license shall not apply to any combinations which include this software, other than combinations with devices manufactured by or for TI (�TI Devices�). No hardware patent is licensed hereunder.
16 
17 Redistributions must preserve existing copyright notices and reproduce this license (including the above copyright notice and the disclaimer and (if applicable) source code license limitations below) in the documentation and/or other materials provided with the distribution
18 
19 Redistribution and use in binary form, without modification, are permitted provided that the following conditions are met:
20 
21 * No reverse engineering, decompilation, or disassembly of this software is permitted with respect to any software provided in binary form.
22 
23 * any redistribution and use are licensed by TI for use only with TI Devices.
24 
25 * Nothing shall obligate TI to provide you with source code for the software licensed and provided to you in object code.
26 
27 If software source code is provided to you, modification and redistribution of the source code are permitted provided that the following conditions are met:
28 
29 * any redistribution and use of the source code, including any resulting derivative works, are licensed by TI for use only with TI Devices.
30 
31 * any redistribution and use of any object code compiled from the source code and any resulting derivative works, are licensed by TI for use only with TI Devices.
32 
33 Neither the name of Texas Instruments Incorporated nor the names of its suppliers may be used to endorse or promote products derived from this software without specific prior written permission.
34 
35 DISCLAIMER.
36 
37 THIS SOFTWARE IS PROVIDED BY TI AND TI�S LICENSORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL TI AND TI�S LICENSORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 
39 */
40 #ifndef SFM_TB_H
41 #define SFM_TB_H
42 
43 #pragma CHECK_MISRA ("none")
44 #include <stdio.h>
45 #include <stdint.h>
46 #include <stdlib.h>
47 #include <string.h>
48 #include <assert.h>
49 #include "math.h"
50 
51 #include <../common/profile.h>
52 #include <../common/tiadalg_img_proc.h>
53 #include "ti/drv/udma/udma.h"
54 
55 #ifndef HOST_EMULATION
56 #ifndef TIADALG_BIOS_BUILD
57 /* Needed for static MMU configuration */
58 extern const uint64_t pte_lvl0[512];
59 
60 #include "csl_dspcachec7.h"
61 #include "csl_c7xl2cc.h"
62 #include "enable_cache_mmu.h"
63 #endif
64 #endif
65 
66 #define ENABLE_TRACES 1
67 
68 //#define ENABLE_FILE_IO
69 
70 #ifndef __mmax
71 #define __mmax(x,y) (x>y)?x:y
72 #endif
73 
74 #ifndef __mmin
75 #define __mmin(x,y) (x>y)?y:x
76 #endif
77 
78 
79 #define MAX_NUM_IN_POINTS (1242*375) // need to change if resolution changes
80 
81 #define VLIB_TRIANG_MAX_POINTS_IN_TRACK (6)
82 
83 #define FRAME_DEPTH_3D_POINT_CLOUD (1)
84 /*
85 * Maximum number of output points
86 */
87 #define MAX_NUM_OUT_POINTS (MAX_NUM_IN_POINTS * FRAME_DEPTH_3D_POINT_CLOUD)
88 
89 #define PRINT_ERROR_MSG() printf("Error at line: %5d : in file %22s, of function : %s \n",__LINE__, __FILE__,__FUNCTION__)
90 
91 #ifdef TMS320C66X
92 /* Out of total 288 KB of SRAM, 128 KB is configured as cache,
93 6 KB as stack, hence remaining 288 - 128 - 6 = 154 is
94 configured as SRAM to be used by SFM algorithm
95 */
96 #define DMEM1_SIZE (154 * 1024)
97 
98 /* 16KB of L1D is configured as SRAM
99 */
100 #define DMEM0_SIZE (16 * 1024)
101 #else
102 
103 #define DMEM2_SIZE (1024 * 1024) // 1MB Of MSMC scratch
104 //#define DMEM1_SIZE (480 * 1024) // 480KB sram and 64 kb cache. total size of 512 + 32.
105 #define DMEM1_SIZE (448 * 1024) // 480KB sram and 64 kb cache. total size of 512 + 32.
106 #define DMEM0_SIZE (13 * 1024) // 13 KB sram, 3 kb udmaDrv, 32KB cache
107 
108 #endif
109 
110 #pragma DATA_SECTION(DMEM2_SCRATCH,".l3ScratchBuf")
111 /* This will be used for allocation of memory in DMEM1 --> L2*/
113 
114 #pragma DATA_SECTION(DMEM1_SCRATCH,".l2ScratchBuf")
115 /* This will be used for allocation of memory in DMEM1 --> L2*/
117 
118 #pragma DATA_SECTION (DMEM0_SCRATCH,".l1ScratchBuf");
119 /* This will be used for allocation of memory in DMEM0 --> L1D*/
121 
122 /*Global variable for udma driver*/
123 #pragma DATA_SECTION (udmaDrvObj,".l1ScratchBuf");
124 struct Udma_DrvObj udmaDrvObj;
125 
129 
130 #define MAX_INPUT_BUF_SIZE (MAX_NUM_IN_POINTS*(sizeof(int32_t) + 3) + 16) // dof element of 4 bytes and input RGB 3 bytes
131 #define MAX_OUTPUT_BUF_SIZE (MAX_NUM_IN_POINTS*sizeof(SFM_TI_output) + MAX_NUM_IN_POINTS*3 + 16) // 3 for RGB
132 #define MAX_IMG_BUF_SIZE ((1920*1088*3)>>1)
133 
134 #pragma DATA_SECTION (IN_BUF, ".ioBufs");
136 
137 #pragma DATA_SECTION (IMG_BUF, ".ioBufs");
139 
140 #pragma DATA_SECTION (OUT_BUF, ".ioBufs");
142 
143 //#define ENABLE_YUV_WRITE
144 
145 #ifdef ENABLE_FILE_IO
146 #define ENABLE_PLY_TXT_WRITE
147 //#define ENABLE_PLY_BIN_WRITE
148 
149 
150 FILE* fp_in_feat;
151 
152 FILE * fp_in_cam;
153 FILE * fp_out;
154 FILE* fp_in1;
155 FILE* fp_out1;
156 float* dist;
157 uint8_t* imgPtr;
158 
159 #endif //ENABLE_FILE_IO
160 
161 //#define TIADALG_UC_AVV_BUILD
162 
163 #ifdef TIADALG_UC_AVV_BUILD
164 
165 //UC VARIABLES:
166 #define MULTICORE_SYNC_BASE (0x41C28000)
167 #define SMALL_WAIT_TIME (0x64)
168 #define MULTICORE_SYNC_VAL (0x12345678)
169 #define TIADALG_DBUG_CTRL_BASE (0xD9900000)
170 #define C7_1_RD_OFFSET (0xB)
171 #define C7_1_WR_OFFSET (0x3)
172 #define MULTICORE_CSI_COUNTER (0x41C28050)
173 #define MULTICORE_QoS_Control (0x41C2805D)
174 #endif
175 
176 typedef struct IM_Fxns
177 {
178  IVISION_Fxns * ivision;
179 
180 } IM_Fxns;
181 
182 
183 int32_t sfmTest(ssfm_Config * testcaseParams);
184 int32_t TestApp_AllocMemRecords(IALG_MemRec * memRec,int32_t numMemRec);
185 int32_t TestApp_FreeMemRecords(IALG_MemRec * memRec,int32_t numMemRec);
186 int32_t TestApp_AllocIOBuffers(IVISION_InBufs * inBufs,
187  IVISION_OutBufs * outBufs,
188  int32_t totInPixs,
189  uint16_t inNumTracks,
190  int32_t inImgClrFmt);
191 
192 int32_t TestApp_ReadInBuf(
193  void * dst0,
194  void * dst1,
195  int32_t currFrameNum,
196  int32_t enAlgPtCldVis,
197  char * dofFolderName,
198  char* inImgName,
199  int32_t img_width,
200  int32_t img_height,
201  int32_t inImgClrFmt);
202 
203 int32_t TestApp_ReadInCameraPrm(float * dstExt,
204  float * dstInt,
205  int32_t currFrameNum,
206  int32_t startFrameNum,
207  char * fileName,
208  int32_t maxFrameNum);
209 
210 #if defined(ENABLE_FILE_IO) || defined (ENABLE_YUV_WRITE)
211 int32_t TestApp_WriteOutImgBuf(SFM_TI_output * src,int32_t currFrameNum,
212  int32_t startFrameNum,
213  char * featFileName,char* inImgFileName,
214  char* outImgFileName,int32_t maxFrameNum,
215  int32_t imgWidth, int32_t imgHeight,
216  int32_t outNumPoints);
217 #endif
218 
219 int32_t TestApp_WriteOutPlyBuf(SFM_TI_output * src,int32_t currFrameNum,
220  int32_t startFrameNum,
221  char * featFileName,char* inImgFileName,
222  char* outImgFileName,int32_t maxFrameNum,
223  int32_t imgWidth, int32_t imgHeight,
224  int32_t outNumPoints);
225 
226 void TestApp_WritePlyHeader(FILE* fp_out, int32_t outNumPoints);
227 int32_t sfmCompare(ssfm_Config * testcaseParams);
228 int32_t TestApp_memContamination(IALG_MemRec * memRec,int32_t numMemRec, int32_t frmIdx);
229 
230 #if (!HOST_EMULATION)
231 void SetMAR();
232 void InitCache();
233 #define L1D_SRAM_ADDR (0x00F00000)
234 
235 #define MAR148() (*(volatile uint32_t *)0x01848250)
236 #endif
237 
238 void * algo_tb_udma_init( void);
239 
240 void ALGO_printf(const char *str);
241 
242 #endif
int32_t TestApp_memContamination(IALG_MemRec *memRec, int32_t numMemRec, int32_t frmIdx)
int32_t TestApp_ReadInCameraPrm(float *dstExt, float *dstInt, int32_t currFrameNum, int32_t startFrameNum, char *fileName, int32_t maxFrameNum)
uint8_t DMEM0_SCRATCH[DMEM0_SIZE]
Definition: sfm_ti_tb.h:120
int32_t TestApp_ReadInBuf(void *dst0, void *dst1, int32_t currFrameNum, int32_t enAlgPtCldVis, char *dofFolderName, char *inImgName, int32_t img_width, int32_t img_height, int32_t inImgClrFmt)
#define DMEM2_SIZE
Definition: sfm_ti_tb.h:103
#define DMEM1_SIZE
Definition: sfm_ti_tb.h:105
#define MAX_IMG_BUF_SIZE
Definition: sfm_ti_tb.h:132
IVISION_Fxns * ivision
Definition: sfm_ti_tb.h:178
void InitCache()
void * algo_tb_udma_init(void)
#define MAX_INPUT_BUF_SIZE
Definition: sfm_ti_tb.h:130
void TestApp_WritePlyHeader(FILE *fp_out, int32_t outNumPoints)
struct Udma_DrvObj udmaDrvObj
Definition: sfm_ti_tb.h:124
TIMemObject memObj_DMEM1
Definition: sfm_ti_tb.h:127
#define MAX_OUTPUT_BUF_SIZE
Definition: sfm_ti_tb.h:131
TIMemObject memObj_DMEM2
Definition: sfm_ti_tb.h:126
void ALGO_printf(const char *str)
int32_t TestApp_AllocIOBuffers(IVISION_InBufs *inBufs, IVISION_OutBufs *outBufs, int32_t totInPixs, uint16_t inNumTracks, int32_t inImgClrFmt)
#define DMEM0_SIZE
Definition: sfm_ti_tb.h:106
Definition: sfm_ti_config.h:54
uint8_t OUT_BUF[MAX_OUTPUT_BUF_SIZE]
Definition: sfm_ti_tb.h:141
FILE * fp_in_cam
Definition: tiadalg_vl_test.h:85
int32_t sfmCompare(ssfm_Config *testcaseParams)
int32_t TestApp_WriteOutPlyBuf(SFM_TI_output *src, int32_t currFrameNum, int32_t startFrameNum, char *featFileName, char *inImgFileName, char *outImgFileName, int32_t maxFrameNum, int32_t imgWidth, int32_t imgHeight, int32_t outNumPoints)
int32_t TestApp_FreeMemRecords(IALG_MemRec *memRec, int32_t numMemRec)
int32_t TestApp_AllocMemRecords(IALG_MemRec *memRec, int32_t numMemRec)
void SetMAR()
Definition: sfm_ti_tb.h:176
uint8_t DMEM2_SCRATCH[DMEM2_SIZE]
Definition: sfm_ti_tb.h:112
uint8_t DMEM1_SCRATCH[DMEM1_SIZE]
Definition: sfm_ti_tb.h:116
FILE * fp_out
Definition: tiadalg_vl_test.h:87
uint8_t IMG_BUF[MAX_IMG_BUF_SIZE]
Definition: sfm_ti_tb.h:138
int32_t sfmTest(ssfm_Config *testcaseParams)
This structure is memory object structure,.
Definition: ti_mem_manager.h:99
TIMemObject memObj_DMEM0
Definition: sfm_ti_tb.h:128
uint8_t IN_BUF[MAX_INPUT_BUF_SIZE]
Definition: sfm_ti_tb.h:135
const uint64_t pte_lvl0[512]
This structure defines the format of output buffer given out from algorithm.
Definition: tiadalg_structure_from_motion.h:416

© Copyright 2018 Texas Instruments Incorporated. All rights reserved.
Document generated by doxygen 1.8.6