Skip to main content

apple_vision/ffi/
mod.rs

1//! Raw FFI declarations matching the Swift bridge in
2//! `swift-bridge/Sources/VisionBridge/*.swift`.
3
4#![allow(missing_docs, non_camel_case_types, clippy::pub_underscore_fields)]
5
6use core::ffi::{c_char, c_void};
7
8/// Mirrors `VNRecognizedTextRaw` in the Swift bridge. Layout-compatible.
9#[repr(C)]
10pub struct RecognizedTextRaw {
11    pub text: *mut c_char,
12    pub confidence: f32,
13    pub bbox_x: f64,
14    pub bbox_y: f64,
15    pub bbox_w: f64,
16    pub bbox_h: f64,
17}
18
19/// Mirrors `VNRequestObservationRaw` in the Swift bridge. Layout-compatible.
20#[repr(C)]
21pub struct RequestObservationRaw {
22    pub uuid: *mut c_char,
23    pub text: *mut c_char,
24    pub confidence: f32,
25    pub has_time_range: bool,
26    pub time_range_start_seconds: f64,
27    pub time_range_duration_seconds: f64,
28    pub bbox_x: f64,
29    pub bbox_y: f64,
30    pub bbox_w: f64,
31    pub bbox_h: f64,
32}
33
34/// Mirrors `VNDetectedFaceRaw` in the Swift bridge. Layout-compatible.
35#[repr(C)]
36pub struct DetectedFaceRaw {
37    pub bbox_x: f64,
38    pub bbox_y: f64,
39    pub bbox_w: f64,
40    pub bbox_h: f64,
41    pub confidence: f32,
42    pub roll: f32,
43    pub yaw: f32,
44    pub pitch: f32,
45}
46
47/// Mirrors `VNDetectedBarcodeRaw` in the Swift bridge. Layout-compatible.
48#[repr(C)]
49pub struct DetectedBarcodeRaw {
50    pub payload: *mut c_char,
51    pub symbology: *mut c_char,
52    pub confidence: f32,
53    pub bbox_x: f64,
54    pub bbox_y: f64,
55    pub bbox_w: f64,
56    pub bbox_h: f64,
57}
58
59/// Mirrors `VNSaliencyRegionRaw` in the Swift bridge. Layout-compatible.
60#[repr(C)]
61pub struct SaliencyRegionRaw {
62    pub confidence: f32,
63    pub bbox_x: f64,
64    pub bbox_y: f64,
65    pub bbox_w: f64,
66    pub bbox_h: f64,
67}
68
69/// Mirrors `VNFaceLandmarksRaw` in the Swift bridge. Layout-compatible.
70///
71/// All `*_count` fields are NUMBER OF POINTS; each point buffer is an
72/// interleaved `[x0, y0, x1, y1, …]` array of doubles, length
73/// `count * 2`. A NULL pointer + 0 count means the region wasn't
74/// produced for this face.
75#[repr(C)]
76pub struct FaceLandmarksRaw {
77    pub bbox_x: f64,
78    pub bbox_y: f64,
79    pub bbox_w: f64,
80    pub bbox_h: f64,
81    pub confidence: f32,
82    pub roll: f32,
83    pub yaw: f32,
84    pub pitch: f32,
85
86    pub face_contour: *mut f64,
87    pub face_contour_count: usize,
88    pub left_eye: *mut f64,
89    pub left_eye_count: usize,
90    pub right_eye: *mut f64,
91    pub right_eye_count: usize,
92    pub left_eyebrow: *mut f64,
93    pub left_eyebrow_count: usize,
94    pub right_eyebrow: *mut f64,
95    pub right_eyebrow_count: usize,
96    pub nose: *mut f64,
97    pub nose_count: usize,
98    pub nose_crest: *mut f64,
99    pub nose_crest_count: usize,
100    pub median_line: *mut f64,
101    pub median_line_count: usize,
102    pub outer_lips: *mut f64,
103    pub outer_lips_count: usize,
104    pub inner_lips: *mut f64,
105    pub inner_lips_count: usize,
106    pub left_pupil: *mut f64,
107    pub left_pupil_count: usize,
108    pub right_pupil: *mut f64,
109    pub right_pupil_count: usize,
110}
111
112/// Mirrors `VNPoseObservationRaw` in the Swift bridge. Layout-compatible.
113#[repr(C)]
114pub struct PoseObservationRaw {
115    pub bbox_x: f64,
116    pub bbox_y: f64,
117    pub bbox_w: f64,
118    pub bbox_h: f64,
119    pub confidence: f32,
120    pub joint_names: *mut *mut c_char,
121    pub joint_xs: *mut f64,
122    pub joint_ys: *mut f64,
123    pub joint_confidences: *mut f32,
124    pub joint_count: usize,
125}
126
127/// Mirrors `VNContourRaw` in the Swift bridge. Layout-compatible.
128#[repr(C)]
129pub struct ContourRaw {
130    pub point_xs: *mut f64,
131    pub point_ys: *mut f64,
132    pub point_count: usize,
133    pub child_count: isize,
134    pub aspect_ratio: f32,
135}
136
137/// Mirrors `VNRecognizedAnimalRaw` in the Swift bridge. Layout-compatible.
138#[repr(C)]
139pub struct RecognizedAnimalRaw {
140    pub identifier: *mut c_char,
141    pub confidence: f32,
142    pub bbox_x: f64,
143    pub bbox_y: f64,
144    pub bbox_w: f64,
145    pub bbox_h: f64,
146}
147
148/// Mirrors `VNClassificationRaw` in the Swift bridge. Layout-compatible.
149#[repr(C)]
150pub struct ClassificationRaw {
151    pub identifier: *mut c_char,
152    pub confidence: f32,
153}
154
155/// Mirrors `VNRectangleObservationRaw` in the Swift bridge. Layout-compatible.
156#[repr(C)]
157pub struct RectangleObservationRaw {
158    pub bbox_x: f64,
159    pub bbox_y: f64,
160    pub bbox_w: f64,
161    pub bbox_h: f64,
162    pub confidence: f32,
163    pub tl_x: f64,
164    pub tl_y: f64,
165    pub tr_x: f64,
166    pub tr_y: f64,
167    pub bl_x: f64,
168    pub bl_y: f64,
169    pub br_x: f64,
170    pub br_y: f64,
171}
172
173/// Mirrors `VNFeaturePrintRaw` in the Swift bridge. Layout-compatible.
174#[repr(C)]
175pub struct FeaturePrintRaw {
176    pub element_type: i32,
177    pub element_count: usize,
178    pub bytes: *mut c_void,
179}
180
181/// Mirrors `VNHumanObservationRaw` in the Swift bridge. Layout-compatible.
182#[repr(C)]
183pub struct HumanObservationRaw {
184    pub bbox_x: f64,
185    pub bbox_y: f64,
186    pub bbox_w: f64,
187    pub bbox_h: f64,
188    pub confidence: f32,
189    pub upper_body_only: bool,
190}
191
192/// Mirrors `VNAestheticsScoresRaw` in the Swift bridge. Layout-compatible.
193#[repr(C)]
194pub struct AestheticsScoresRaw {
195    pub overall_score: f32,
196    pub is_utility: bool,
197}
198
199/// Mirrors `VNFaceQualityRaw` in the Swift bridge. Layout-compatible.
200#[repr(C)]
201pub struct FaceQualityRaw {
202    pub bbox_x: f64,
203    pub bbox_y: f64,
204    pub bbox_w: f64,
205    pub bbox_h: f64,
206    pub confidence: f32,
207    pub capture_quality: f32,
208    pub has_quality: bool,
209}
210
211/// Mirrors `VNSegmentationMaskRaw` in the Swift bridge. Layout-compatible.
212#[repr(C)]
213pub struct SegmentationMaskRaw {
214    pub width: usize,
215    pub height: usize,
216    pub bytes_per_row: usize,
217    pub bytes: *mut c_void,
218}
219
220/// Result container for async array operations. Freed by `vn_async_array_result_free`.
221#[repr(C)]
222pub struct AsyncArrayResultRaw {
223    pub array: *mut c_void,
224    pub count: usize,
225}
226
227/// Result container for async segmentation operations. Freed by `vn_async_seg_result_free`.
228#[repr(C)]
229pub struct AsyncSegResultRaw {
230    pub width: usize,
231    pub height: usize,
232    pub bytes_per_row: usize,
233    pub bytes: *mut u8,
234}
235
236/// Mirrors `VNCoreMLFeatureValueRaw` in the Swift bridge. Layout-compatible.
237#[repr(C)]
238pub struct CoreMLFeatureValueRaw {
239    pub feature_name: *mut c_char,
240    pub type_name: *mut c_char,
241    pub kind: i32,
242    pub int64_value: i64,
243    pub double_value: f64,
244    pub string_value: *mut c_char,
245    pub multi_array_shape: *mut usize,
246    pub multi_array_shape_count: usize,
247    pub multi_array_values: *mut f64,
248    pub multi_array_value_count: usize,
249}
250
251extern "C" {
252    pub fn vn_string_free(s: *mut c_char);
253
254    pub fn vn_recognize_text_in_path(
255        path: *const c_char,
256        recognition_level: i32,
257        uses_language_correction: bool,
258        out_array: *mut *mut c_void,
259        out_count: *mut usize,
260        out_error_message: *mut *mut c_char,
261    ) -> i32;
262
263    pub fn vn_recognize_text_in_pixel_buffer(
264        pixel_buffer: *mut c_void,
265        recognition_level: i32,
266        uses_language_correction: bool,
267        out_array: *mut *mut c_void,
268        out_count: *mut usize,
269        out_error_message: *mut *mut c_char,
270    ) -> i32;
271
272    pub fn vn_recognized_text_free(array: *mut c_void, count: usize);
273
274    pub fn vn_image_request_handler_perform_text_request(
275        image_path: *const c_char,
276        recognition_level: i32,
277        uses_language_correction: bool,
278        prefer_background_processing: bool,
279        uses_cpu_only: bool,
280        revision: usize,
281        has_revision: bool,
282        out_array: *mut *mut c_void,
283        out_count: *mut usize,
284        out_error_message: *mut *mut c_char,
285    ) -> i32;
286
287    pub fn vn_sequence_request_handler_create(
288        out_handle: *mut *mut c_void,
289        out_error_message: *mut *mut c_char,
290    ) -> i32;
291
292    pub fn vn_sequence_request_handler_perform_text_request(
293        handle: *mut c_void,
294        image_path: *const c_char,
295        recognition_level: i32,
296        uses_language_correction: bool,
297        prefer_background_processing: bool,
298        uses_cpu_only: bool,
299        revision: usize,
300        has_revision: bool,
301        out_array: *mut *mut c_void,
302        out_count: *mut usize,
303        out_error_message: *mut *mut c_char,
304    ) -> i32;
305
306    pub fn vn_sequence_request_handler_free(handle: *mut c_void);
307
308    pub fn vn_video_processor_analyze_text_request(
309        video_path: *const c_char,
310        recognition_level: i32,
311        uses_language_correction: bool,
312        prefer_background_processing: bool,
313        uses_cpu_only: bool,
314        revision: usize,
315        has_revision: bool,
316        cadence_kind: i32,
317        cadence_value: f64,
318        out_array: *mut *mut c_void,
319        out_count: *mut usize,
320        out_error_message: *mut *mut c_char,
321    ) -> i32;
322
323    pub fn vn_request_observations_free(array: *mut c_void, count: usize);
324
325    pub fn vn_detect_faces_in_path(
326        path: *const c_char,
327        out_array: *mut *mut c_void,
328        out_count: *mut usize,
329        out_error_message: *mut *mut c_char,
330    ) -> i32;
331
332    pub fn vn_detect_faces_in_pixel_buffer(
333        pixel_buffer: *mut c_void,
334        out_array: *mut *mut c_void,
335        out_count: *mut usize,
336        out_error_message: *mut *mut c_char,
337    ) -> i32;
338
339    pub fn vn_detected_faces_free(array: *mut c_void, count: usize);
340
341    pub fn vn_detect_barcodes_in_path(
342        path: *const c_char,
343        out_array: *mut *mut c_void,
344        out_count: *mut usize,
345        out_error_message: *mut *mut c_char,
346    ) -> i32;
347
348    pub fn vn_detected_barcodes_free(array: *mut c_void, count: usize);
349
350    pub fn vn_attention_saliency_in_path(
351        path: *const c_char,
352        out_array: *mut *mut c_void,
353        out_count: *mut usize,
354        out_error_message: *mut *mut c_char,
355    ) -> i32;
356
357    pub fn vn_saliency_regions_free(array: *mut c_void, count: usize);
358
359    pub fn vn_detect_face_landmarks_in_path(
360        path: *const c_char,
361        out_array: *mut *mut c_void,
362        out_count: *mut usize,
363        out_error_message: *mut *mut c_char,
364    ) -> i32;
365
366    pub fn vn_face_landmarks_free(array: *mut c_void, count: usize);
367
368    pub fn vn_detect_human_body_pose_in_path(
369        path: *const c_char,
370        out_array: *mut *mut c_void,
371        out_count: *mut usize,
372        out_error_message: *mut *mut c_char,
373    ) -> i32;
374
375    pub fn vn_detect_human_hand_pose_in_path(
376        path: *const c_char,
377        max_hands: usize,
378        out_array: *mut *mut c_void,
379        out_count: *mut usize,
380        out_error_message: *mut *mut c_char,
381    ) -> i32;
382
383    pub fn vn_pose_observations_free(array: *mut c_void, count: usize);
384
385    pub fn vn_detect_contours_in_path(
386        path: *const c_char,
387        contrast_adjustment: f32,
388        detects_dark_on_light: bool,
389        out_array: *mut *mut c_void,
390        out_count: *mut usize,
391        out_error_message: *mut *mut c_char,
392    ) -> i32;
393
394    pub fn vn_contours_free(array: *mut c_void, count: usize);
395
396    pub fn vn_recognize_animals_in_path(
397        path: *const c_char,
398        out_array: *mut *mut c_void,
399        out_count: *mut usize,
400        out_error_message: *mut *mut c_char,
401    ) -> i32;
402
403    pub fn vn_recognized_animals_free(array: *mut c_void, count: usize);
404
405    pub fn vn_classify_image_in_path(
406        path: *const c_char,
407        out_array: *mut *mut c_void,
408        out_count: *mut usize,
409        out_error_message: *mut *mut c_char,
410    ) -> i32;
411    pub fn vn_classifications_free(array: *mut c_void, count: usize);
412
413    pub fn vn_detect_rectangles_in_path(
414        path: *const c_char,
415        max_observations: usize,
416        minimum_aspect_ratio: f32,
417        maximum_aspect_ratio: f32,
418        minimum_size: f32,
419        minimum_confidence: f32,
420        out_array: *mut *mut c_void,
421        out_count: *mut usize,
422        out_error_message: *mut *mut c_char,
423    ) -> i32;
424
425    pub fn vn_detect_document_segmentation_in_path(
426        path: *const c_char,
427        out_array: *mut *mut c_void,
428        out_count: *mut usize,
429        out_error_message: *mut *mut c_char,
430    ) -> i32;
431
432    pub fn vn_rectangle_observations_free(array: *mut c_void, count: usize);
433
434    pub fn vn_detect_horizon_in_path(
435        path: *const c_char,
436        out_angle: *mut f64,
437        out_has_value: *mut bool,
438        out_error_message: *mut *mut c_char,
439    ) -> i32;
440
441    pub fn vn_generate_image_feature_print_in_path(
442        path: *const c_char,
443        out_feature: *mut FeaturePrintRaw,
444        out_error_message: *mut *mut c_char,
445    ) -> i32;
446    pub fn vn_feature_print_free(feature: *mut FeaturePrintRaw);
447
448    pub fn vn_detect_human_rectangles_in_path(
449        path: *const c_char,
450        upper_body_only: bool,
451        out_array: *mut *mut c_void,
452        out_count: *mut usize,
453        out_error_message: *mut *mut c_char,
454    ) -> i32;
455    pub fn vn_human_observations_free(array: *mut c_void, count: usize);
456
457    pub fn vn_calculate_aesthetics_scores_in_path(
458        path: *const c_char,
459        out_scores: *mut AestheticsScoresRaw,
460        out_has_value: *mut bool,
461        out_error_message: *mut *mut c_char,
462    ) -> i32;
463
464    pub fn vn_detect_face_capture_quality_in_path(
465        path: *const c_char,
466        out_array: *mut *mut c_void,
467        out_count: *mut usize,
468        out_error_message: *mut *mut c_char,
469    ) -> i32;
470
471    pub fn vn_face_quality_observations_free(array: *mut c_void, count: usize);
472
473    pub fn vn_generate_person_segmentation_in_path(
474        path: *const c_char,
475        quality_level: i32,
476        out_mask: *mut SegmentationMaskRaw,
477        out_has_value: *mut bool,
478        out_error_message: *mut *mut c_char,
479    ) -> i32;
480
481    pub fn vn_generate_foreground_instance_mask_in_path(
482        path: *const c_char,
483        out_mask: *mut SegmentationMaskRaw,
484        out_instance_count: *mut usize,
485        out_has_value: *mut bool,
486        out_error_message: *mut *mut c_char,
487    ) -> i32;
488
489    pub fn vn_segmentation_mask_free(mask: *mut SegmentationMaskRaw);
490
491    pub fn vn_generate_optical_flow_in_paths(
492        path_a: *const c_char,
493        path_b: *const c_char,
494        computation_accuracy: i32,
495        out_mask: *mut SegmentationMaskRaw,
496        out_has_value: *mut bool,
497        out_error_message: *mut *mut c_char,
498    ) -> i32;
499
500    pub fn vn_coreml_classify_in_path(
501        path: *const c_char,
502        model_path: *const c_char,
503        out_array: *mut *mut c_void,
504        out_count: *mut usize,
505        out_error_message: *mut *mut c_char,
506    ) -> i32;
507
508    pub fn vn_coreml_request_classify_in_path(
509        path: *const c_char,
510        model_path: *const c_char,
511        input_image_feature_name: *const c_char,
512        has_input_image_feature_name: bool,
513        image_crop_and_scale_option: i32,
514        roi_x: f64,
515        roi_y: f64,
516        roi_w: f64,
517        roi_h: f64,
518        has_region_of_interest: bool,
519        prefer_background_processing: bool,
520        uses_cpu_only: bool,
521        revision: usize,
522        has_revision: bool,
523        out_array: *mut *mut c_void,
524        out_count: *mut usize,
525        out_error_message: *mut *mut c_char,
526    ) -> i32;
527
528    pub fn vn_coreml_feature_value_in_path(
529        path: *const c_char,
530        model_path: *const c_char,
531        input_image_feature_name: *const c_char,
532        has_input_image_feature_name: bool,
533        image_crop_and_scale_option: i32,
534        roi_x: f64,
535        roi_y: f64,
536        roi_w: f64,
537        roi_h: f64,
538        has_region_of_interest: bool,
539        prefer_background_processing: bool,
540        uses_cpu_only: bool,
541        revision: usize,
542        has_revision: bool,
543        out_feature: *mut CoreMLFeatureValueRaw,
544        out_has_value: *mut bool,
545        out_error_message: *mut *mut c_char,
546    ) -> i32;
547
548    pub fn vn_coreml_feature_value_free(feature: *mut CoreMLFeatureValueRaw);
549
550    // ---- async API ----
551    pub fn vn_async_array_result_free(ptr: *mut c_void);
552    pub fn vn_async_seg_result_free(ptr: *mut c_void);
553
554    pub fn vn_recognize_text_in_path_async(
555        path: *const c_char,
556        recognition_level: i32,
557        uses_language_correction: bool,
558        cb: extern "C" fn(*const c_void, *const i8, *mut c_void),
559        ctx: *mut c_void,
560    );
561    pub fn vn_detect_faces_in_path_async(
562        path: *const c_char,
563        cb: extern "C" fn(*const c_void, *const i8, *mut c_void),
564        ctx: *mut c_void,
565    );
566    pub fn vn_detect_barcodes_in_path_async(
567        path: *const c_char,
568        cb: extern "C" fn(*const c_void, *const i8, *mut c_void),
569        ctx: *mut c_void,
570    );
571    pub fn vn_generate_person_segmentation_async(
572        path: *const c_char,
573        quality_level: i32,
574        cb: extern "C" fn(*const c_void, *const i8, *mut c_void),
575        ctx: *mut c_void,
576    );
577
578    pub fn vn_test_helper_render_text_png(
579        text: *const c_char,
580        width: i32,
581        height: i32,
582        output_path: *const c_char,
583    ) -> i32;
584
585    pub fn vn_test_helper_render_text_video(
586        first_text: *const c_char,
587        second_text: *const c_char,
588        width: i32,
589        height: i32,
590        fps: i32,
591        frames_per_text: i32,
592        output_path: *const c_char,
593    ) -> i32;
594}
595
596// ===== v0.13 missing requests =====
597
598/// Mirrors `VNAnimalJointRaw` in the Swift bridge.
599#[repr(C)]
600pub struct AnimalJointRaw {
601    pub name: *mut c_char,
602    pub x: f64,
603    pub y: f64,
604    pub confidence: f32,
605    pub _pad: f32,
606}
607
608/// Mirrors `VNHumanJoint3DRaw`.
609#[repr(C)]
610pub struct HumanJoint3DRaw {
611    pub name: *mut c_char,
612    pub x: f32,
613    pub y: f32,
614    pub z: f32,
615    pub confidence: f32,
616    pub local_x: f32,
617    pub local_y: f32,
618    pub local_z: f32,
619    pub parent_joint: *mut c_char,
620}
621
622/// Mirrors `VNSimpleRectRaw`.
623#[repr(C)]
624pub struct SimpleRectRaw {
625    pub x: f64,
626    pub y: f64,
627    pub w: f64,
628    pub h: f64,
629    pub confidence: f32,
630    pub _pad: f32,
631}
632
633/// Mirrors `VNTextObservationRaw`.
634#[repr(C)]
635pub struct TextObservationRaw {
636    pub bbox_x: f64,
637    pub bbox_y: f64,
638    pub bbox_w: f64,
639    pub bbox_h: f64,
640    pub confidence: f32,
641    pub _pad: f32,
642    pub character_boxes: *mut SimpleRectRaw,
643    pub character_box_count: usize,
644}
645
646/// Mirrors `VNTrajectoryRaw`.
647#[repr(C)]
648pub struct TrajectoryRaw {
649    pub detected_x: f64,
650    pub detected_y: f64,
651    pub projected_x: f64,
652    pub projected_y: f64,
653    pub equation_a: f64,
654    pub equation_b: f64,
655    pub equation_c: f64,
656    pub confidence: f32,
657    pub _pad: f32,
658}
659
660/// Mirrors `VNTranslationalAlignmentRaw`.
661#[repr(C)]
662pub struct TranslationalAlignmentRaw {
663    pub tx: f64,
664    pub ty: f64,
665}
666
667/// Mirrors `VNHomographicAlignmentRaw` (3×3 row-major matrix).
668#[repr(C)]
669pub struct HomographicAlignmentRaw {
670    pub m00: f32,
671    pub m01: f32,
672    pub m02: f32,
673    pub m10: f32,
674    pub m11: f32,
675    pub m12: f32,
676    pub m20: f32,
677    pub m21: f32,
678    pub m22: f32,
679    pub _pad: f32,
680}
681
682extern "C" {
683    pub fn vn_detect_animal_body_pose_in_path(
684        path: *const c_char,
685        out_joints: *mut *mut AnimalJointRaw,
686        out_count: *mut isize,
687        out_err: *mut *mut c_char,
688    ) -> i32;
689    pub fn vn_animal_joints_free(ptr: *mut AnimalJointRaw, count: isize);
690
691    pub fn vn_detect_human_body_pose_3d_in_path(
692        path: *const c_char,
693        out_joints: *mut *mut HumanJoint3DRaw,
694        out_count: *mut isize,
695        out_err: *mut *mut c_char,
696    ) -> i32;
697    pub fn vn_human_joints_3d_free(ptr: *mut HumanJoint3DRaw, count: isize);
698
699    pub fn vn_detect_text_rectangles_in_path(
700        path: *const c_char,
701        reports_character_boxes: bool,
702        out_rects: *mut *mut SimpleRectRaw,
703        out_count: *mut isize,
704        out_err: *mut *mut c_char,
705    ) -> i32;
706    pub fn vn_detect_text_observations_in_path(
707        path: *const c_char,
708        reports_character_boxes: bool,
709        roi_x: f64,
710        roi_y: f64,
711        roi_w: f64,
712        roi_h: f64,
713        has_region_of_interest: bool,
714        prefer_background_processing: bool,
715        uses_cpu_only: bool,
716        revision: usize,
717        has_revision: bool,
718        out_observations: *mut *mut TextObservationRaw,
719        out_count: *mut usize,
720        out_err: *mut *mut c_char,
721    ) -> i32;
722    pub fn vn_text_observations_free(ptr: *mut c_void, count: usize);
723    pub fn vn_objectness_saliency_in_path(
724        path: *const c_char,
725        out_rects: *mut *mut SimpleRectRaw,
726        out_count: *mut isize,
727        out_err: *mut *mut c_char,
728    ) -> i32;
729    pub fn vn_simple_rects_free(ptr: *mut SimpleRectRaw, count: isize);
730
731    pub fn vn_person_instance_mask_in_path(
732        path: *const c_char,
733        out_width: *mut isize,
734        out_height: *mut isize,
735        out_bytes_per_row: *mut isize,
736        out_data: *mut *mut u8,
737        out_err: *mut *mut c_char,
738    ) -> i32;
739    pub fn vn_mask_buffer_free(ptr: *mut u8, size: isize);
740
741    pub fn vn_detect_trajectories_in_path(
742        path: *const c_char,
743        trajectory_length: isize,
744        out_trajectories: *mut *mut TrajectoryRaw,
745        out_count: *mut isize,
746        out_err: *mut *mut c_char,
747    ) -> i32;
748    pub fn vn_trajectories_free(ptr: *mut TrajectoryRaw, count: isize);
749
750    pub fn vn_register_translational_in_paths(
751        target_path: *const c_char,
752        floating_path: *const c_char,
753        out: *mut TranslationalAlignmentRaw,
754        out_err: *mut *mut c_char,
755    ) -> i32;
756    pub fn vn_register_homographic_in_paths(
757        target_path: *const c_char,
758        floating_path: *const c_char,
759        out: *mut HomographicAlignmentRaw,
760        out_err: *mut *mut c_char,
761    ) -> i32;
762}
763
764// ===== tracking requests =====
765
766extern "C" {
767    pub fn vn_object_tracker_create(
768        initial_path: *const c_char,
769        initial_bbox: *mut c_void,
770        out_handle: *mut *mut c_void,
771        out_err: *mut *mut c_char,
772    ) -> i32;
773    pub fn vn_object_tracker_track(
774        handle: *mut c_void,
775        next_path: *const c_char,
776        out_bbox: *mut c_void,
777        out_err: *mut *mut c_char,
778    ) -> i32;
779    pub fn vn_object_tracker_release(handle: *mut c_void);
780
781    pub fn vn_rectangle_tracker_create(
782        initial_path: *const c_char,
783        initial_observation: *mut c_void,
784        out_handle: *mut *mut c_void,
785        out_err: *mut *mut c_char,
786    ) -> i32;
787    pub fn vn_rectangle_tracker_track(
788        handle: *mut c_void,
789        next_path: *const c_char,
790        out_observation: *mut c_void,
791        out_err: *mut *mut c_char,
792    ) -> i32;
793    pub fn vn_rectangle_tracker_release(handle: *mut c_void);
794
795    pub fn vn_optical_flow_tracker_create(
796        reference_path: *const c_char,
797        out_handle: *mut *mut c_void,
798        out_err: *mut *mut c_char,
799    ) -> i32;
800    pub fn vn_optical_flow_tracker_track(
801        handle: *mut c_void,
802        next_path: *const c_char,
803        out_mask: *mut c_void,
804        out_err: *mut *mut c_char,
805    ) -> i32;
806    pub fn vn_optical_flow_tracker_release(handle: *mut c_void);
807
808    pub fn vn_translational_image_tracker_create(
809        reference_path: *const c_char,
810        out_handle: *mut *mut c_void,
811        out_err: *mut *mut c_char,
812    ) -> i32;
813    pub fn vn_translational_image_tracker_track(
814        handle: *mut c_void,
815        next_path: *const c_char,
816        out_alignment: *mut c_void,
817        out_err: *mut *mut c_char,
818    ) -> i32;
819    pub fn vn_translational_image_tracker_release(handle: *mut c_void);
820
821    pub fn vn_homographic_image_tracker_create(
822        reference_path: *const c_char,
823        out_handle: *mut *mut c_void,
824        out_err: *mut *mut c_char,
825    ) -> i32;
826    pub fn vn_homographic_image_tracker_track(
827        handle: *mut c_void,
828        next_path: *const c_char,
829        out_alignment: *mut c_void,
830        out_err: *mut *mut c_char,
831    ) -> i32;
832    pub fn vn_homographic_image_tracker_release(handle: *mut c_void);
833}
834
835pub mod status {
836    pub const OK: i32 = 0;
837    pub const INVALID_ARGUMENT: i32 = -1;
838    pub const IMAGE_LOAD_FAILED: i32 = -2;
839    pub const REQUEST_FAILED: i32 = -3;
840    pub const UNKNOWN: i32 = -99;
841}
842
843// silence unused
844const _: () = {
845    let _ = core::mem::size_of::<*mut c_void>();
846};