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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
/**
* Error code returned by all functions.
*/
typedef enum OdError OdError;
/**
* Opaque face pipeline handle. Created by `face_pipeline_create*`.
*/
typedef struct FacePipelineHandle FacePipelineHandle;
/**
* Opaque model handle. Created by any `od_model_create_*` function.
*/
typedef struct ModelHandle ModelHandle;
/**
* Single detection result (flat, no pointers, safe for CGO memcpy).
*/
typedef struct OdDetection OdDetection;
/**
* Detection results batch. Caller must free via `od_detections_free`.
*/
typedef struct OdDetections OdDetections;
/**
* Single face detection + recognition result (flat, safe for CGO memcpy).
*/
typedef struct FaceDetectionResult FaceDetectionResult;
/**
* Face detection results batch. Caller must free via `face_pipeline_results_free`.
*/
typedef struct FaceDetectionResults FaceDetectionResults;
/**
* Create a model from an ONNX file (ORT backend, CPU).
*
* # Parameters
* - `model_path`: null-terminated path to `.onnx` file
* - `input_w`, `input_h`: model input dimensions (e.g. 416, 416)
*
* # Returns
* Opaque pointer, or null on error.
*
* # Safety
* `model_path` must be a valid null-terminated C string.
*/
struct ModelHandle *;
/**
* Create a model from an ONNX file with CUDA execution provider.
*
* # Safety
* `model_path` must be a valid null-terminated C string.
*/
struct ModelHandle *;
/**
* Create a model from an ONNX file with TensorRT execution provider (via ORT).
*
* # Safety
* `model_path` must be a valid null-terminated C string.
*/
struct ModelHandle *;
/**
* Create a model from a serialized TensorRT engine file (native TensorRT, no ORT).
*
* # Safety
* `engine_path` must be a valid null-terminated C string.
*/
struct ModelHandle *;
/**
* Create a model from an RKNN model file (Rockchip NPU).
*
* # Parameters
* - `model_path`: null-terminated path to `.rknn` file
* - `num_classes`: number of classes the model was trained on
*
* # Safety
* `model_path` must be a valid null-terminated C string.
*/
struct ModelHandle *;
/**
* Free a model handle.
*
* # Safety
* `handle` must have been returned by `od_model_create*` and not yet freed.
*/
void ;
/**
* Run detection on an RGB image.
*
* Works with any backend: the handle dispatches to the correct runtime internally.
*
* # Parameters
* - `handle`: model handle from any `od_model_create_*` function
* - `pixels_rgb`: pointer to `width * height * 3` bytes (RGB, row-major, HWC)
* - `img_w`, `img_h`: image dimensions in pixels
* - `conf_threshold`: confidence threshold (e.g. 0.3)
* - `nms_threshold`: NMS IoU threshold (e.g. 0.4)
* - `out`: pointer to `OdDetections` struct, filled on success
*
* # Returns
* `OdError::Ok` on success. On error, `out` is zeroed.
*
* # Safety
* - `handle` must be valid.
* - `pixels_rgb` must point to at least `img_w * img_h * 3` bytes.
* - `out` must be a valid pointer.
*/
enum OdError ;
/**
* Free detection results.
*
* # Safety
* `detections` must point to a valid `OdDetections` returned by `od_model_detect`.
*/
void ;
/**
* Create a face pipeline (YuNet detector + ArcFace recognizer, ORT CPU).
*
* # Parameters
* - `detector_path`: null-terminated path to YuNet `.onnx` file
* - `recognizer_path`: null-terminated path to ArcFace `.onnx` file (e.g. `w600k_mbf.onnx`)
*
* # Returns
* Opaque pointer, or null on error.
*
* # Safety
* Both paths must be valid null-terminated C strings.
*/
struct FacePipelineHandle *;
/**
* Create a face pipeline with CUDA acceleration.
*
* # Safety
* Both paths must be valid null-terminated C strings.
*/
struct FacePipelineHandle *;
/**
* Create a face pipeline with TensorRT acceleration (via ORT).
*
* # Safety
* Both paths must be valid null-terminated C strings.
*/
struct FacePipelineHandle *;
/**
* Returns the expected aligned face size (square side, read from the ONNX model).
*
* E.g. 112 for MobileFaceNet (w600k_mbf.onnx).
* Go-side should call this instead of hardcoding a constant.
*
* # Safety
* `handle` must be a valid pointer returned by `face_pipeline_create*`.
*/
uint32_t ;
/**
* Run face detection + recognition on an RGB image.
*
* # Parameters
* - `handle`: face pipeline handle
* - `pixels_rgb`: pointer to `width * height * 3` bytes (RGB, row-major, HWC)
* - `img_w`, `img_h`: image dimensions in pixels
* - `conf_threshold`: detection confidence threshold (e.g. 0.7)
* - `nms_threshold`: NMS IoU threshold (e.g. 0.3)
* - `out`: pointer to `FaceDetectionResults` struct, filled on success
*
* # Returns
* `OdError::Ok` on success. On error, `out` is zeroed.
*
* # Safety
* - `handle` must be valid.
* - `pixels_rgb` must point to at least `img_w * img_h * 3` bytes.
* - `out` must be a valid pointer.
*/
enum OdError ;
/**
* Extract embedding from a pre-aligned face image.
*
* The image must be aligned to the size returned by `face_pipeline_aligned_size()`
* (typically 112x112).
*
* # Parameters
* - `handle`: face pipeline handle
* - `pixels_rgb`: pointer to aligned face RGB data (size x size x 3 bytes)
* - `size`: aligned face size (e.g. 112)
* - `out_embedding`: pointer to caller-allocated `[f32; 512]` buffer
*
* # Returns
* `OdError::Ok` on success.
*
* # Safety
* - `handle` must be valid.
* - `pixels_rgb` must point to at least `size * size * 3` bytes.
* - `out_embedding` must point to at least 512 f32 elements.
*/
enum OdError ;
/**
* Free a face pipeline handle.
*
* # Safety
* `handle` must have been returned by `face_pipeline_create*` and not yet freed.
*/
void ;
/**
* Free face detection results.
*
* # Safety
* `results` must point to a valid `FaceDetectionResults` returned by `face_pipeline_process`.
*/
void ;
/* OD_BRIDGE_H */