tofi_util.h
Go to the documentation of this file.
1 // Copyright (C) Microsoft Corporation. All rights reserved.
2 // Portions Copyright (c) 2020 Analog Devices, Inc.
3 // This software is proprietary and confidential to Analog Devices, Inc. and its
4 // licensors.
5 
6 #ifndef TOFI_UTIL_H
7 #define TOFI_UTIL_H
8 
9 #if __cplusplus
10 extern "C" {
11 #endif
12 // Copyright (C) Microsoft Corporation. All rights reserved.
13 
14 #include <ctype.h>
15 #include <errno.h>
16 #include <stdint.h>
17 #include <stdio.h>
18 #include <stdlib.h>
19 #include <string.h>
20 
21 #include "tofi_error.h"
22 
23 #define MAX_PHASES 3
24 #define MAX_FREQUENCIES 3
25 #define MAX_IMAGE_WIDTH 1024
26 #define MAX_IMAGE_HEIGHT 1024
27 #define MAX_KERNEL_SIZE 7
28 #define CLK_FREQ ((long double)1200000.0)
29 
30 #ifndef ION_HEAP_ID_SYSTEM
31 #define ION_HEAP_ID_SYSTEM 25
32 #endif
33 
34 #ifdef HEXAGON
35 #include "hvx.cfg.h"
36 #include "rpcmem.h"
37 typedef uint16_t ConfBuf;
38 #else
39 typedef float ConfBuf;
40 #endif
41 
42 typedef struct {
43  float a;
44  float b;
45 } Point2F;
46 
47 typedef struct {
48  int32_t a;
49  int32_t b;
50 } Point2I;
51 
52 typedef struct {
53  int16_t a;
54  int16_t b;
55  int16_t c;
56 } Point3I;
57 
58 typedef struct {
59  float a;
60  float b;
61  float c;
62 } Point3F;
63 
64 typedef struct {
65  unsigned char *p_data;
66  size_t size;
67 } FileData;
68 
69 #ifdef BUILD_FIXED
70 typedef Point2I Point2;
71 typedef Point3I Point3;
72 typedef int16_t DataBuffer;
73 #else
74 typedef Point2F Point2;
75 typedef Point3F Point3;
76 typedef float DataBuffer;
77 #endif
78 
79 // Function to Transform XYZ to Z
80 // Params:
81 // uint32_t n_rows (in): Number of rows
82 // uint32_t n_cols (in): Number of columns
83 // void * p_xyz_image_data(in): pointer to XYZ image data
84 // void *p_zdepth_image_data (out): pointer to Z Depth Image
85 // Returns:
86 // uint32_t (out): ADI_TOFI_SUCCESS(0) on success, ADI_TOFI_ERROR(1) on
87 // failure
88 uint32_t TransformationXyzToZ(uint32_t n_rows, uint32_t n_cols,
89  const Point3I *p_xyz_image_data,
90  uint16_t *p_zdepth_image_data);
91 
92 // Function to return the size of the file
93 // returns size if success, returns 0 if fails
94 uint32_t GetDataFileSize(char *file_name);
95 
96 // Return FileData structure with contents
97 // to file and size.
98 FileData LoadFileContents(char *file_name);
99 
100 // Writes Data to file, returns ADI_TOFI_SUCCESS on success
101 // returns ADI_TOFI_ERROR on failure
102 uint32_t WriteDataToFile(char *file_name, uint8_t *buffer,
103  uint32_t buffer_size);
104 uint32_t GetProcessPath(char *process_path, uint32_t path_size);
105 
106 uint32_t Gcd(uint32_t a, uint32_t b);
107 
108 #if __cplusplus
109 }
110 #endif
111 
112 #endif
Point2I::a
int32_t a
Definition: tofi_util.h:48
FileData
Definition: tofi_util.h:64
Point3F::b
float b
Definition: tofi_util.h:60
Point2F::b
float b
Definition: tofi_util.h:44
Point3F::a
float a
Definition: tofi_util.h:59
GetProcessPath
uint32_t GetProcessPath(char *process_path, uint32_t path_size)
Definition: tofi_util.c:138
GetDataFileSize
uint32_t GetDataFileSize(char *file_name)
Definition: tofi_util.c:66
ConfBuf
float ConfBuf
Definition: tofi_util.h:39
Point3F
Definition: tofi_util.h:58
LoadFileContents
FileData LoadFileContents(char *file_name)
Definition: tofi_util.c:78
b
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:3228
tofi_error.h
Point2I
Definition: tofi_util.h:47
DataBuffer
float DataBuffer
Definition: tofi_util.h:76
Point3I::a
int16_t a
Definition: tofi_util.h:53
Point3I::c
int16_t c
Definition: tofi_util.h:55
Point2
Point2F Point2
Definition: tofi_util.h:74
Point2F::a
float a
Definition: tofi_util.h:43
WriteDataToFile
uint32_t WriteDataToFile(char *file_name, uint8_t *buffer, uint32_t buffer_size)
Definition: tofi_util.c:116
buffer
Definition: buffer_processor.h:43
FileData::size
size_t size
Definition: tofi_util.h:66
versiongenerate.buffer_size
int buffer_size
Definition: versiongenerate.py:65
Point3
Point3F Point3
Definition: tofi_util.h:75
Point3I::b
int16_t b
Definition: tofi_util.h:54
TransformationXyzToZ
uint32_t TransformationXyzToZ(uint32_t n_rows, uint32_t n_cols, const Point3I *p_xyz_image_data, uint16_t *p_zdepth_image_data)
Definition: tofi_util.c:53
Point3F::c
float c
Definition: tofi_util.h:61
Point2F
Definition: tofi_util.h:42
Gcd
uint32_t Gcd(uint32_t a, uint32_t b)
Definition: tofi_util.c:159
Point3I
Definition: tofi_util.h:52
FileData::p_data
unsigned char * p_data
Definition: tofi_util.h:65
a
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:3228
Point2I::b
int32_t b
Definition: tofi_util.h:49


libaditof
Author(s):
autogenerated on Wed May 21 2025 02:07:00