diff options
| author | Onur Gündüz <ogunduz@gmail.com> | 2026-10-20 11:44:30 +0200 |
|---|---|---|
| committer | Onur Gündüz <ogunduz@gmail.com> | 2026-10-20 11:44:30 +0200 |
| commit | 9b9005101e6170a226acb265428aac429be6edbf (patch) | |
| tree | f89c76f4a5c2a00a72abe9b92468ac9f15083b94 /yunet.h | |
| download | facedet-9b9005101e6170a226acb265428aac429be6edbf.tar.gz facedet-9b9005101e6170a226acb265428aac429be6edbf.zip | |
Init
Diffstat (limited to 'yunet.h')
| -rw-r--r-- | yunet.h | 55 |
1 files changed, 55 insertions, 0 deletions
@@ -0,0 +1,55 @@ +#ifndef YUNET_H +#define YUNET_H + +#include <stddef.h> + +typedef struct yunet yunet; + +typedef struct { + float x, y, w, h; + float lmk[5][2]; + float score; +} yunet_detection; + +/* Each dimension must be a multiple of 32 between 32 and 4096. + * A context owns mutable scratch space and is not safe for concurrent calls. */ +yunet *yunet_create(int width, int height); +void yunet_free(yunet *m); + +/* The input is float32 BGR in CHW order, with values in [0, 255]. + * The returned buffer belongs to the context. */ +float *yunet_input(yunet *m); + +/* Interleaved RGB8 is converted to BGR CHW without resizing. The right and + * bottom padding are zero. Width and height cannot exceed the context size. + * The RGB buffer must contain at least (height-1)*row_bytes + width*3 bytes. */ +int yunet_set_rgb(yunet *m, const unsigned char *rgb, int width, int height, size_t row_bytes); +int yunet_run(yunet *m); + +/* Names are cls_s, obj_s, bbox_s, kps_s, with s in {8,16,32}. + * Maps use CHW order; cls and obj contain logits, not probabilities. + * The buffer belongs to the context and is valid until the next input change + * or run. NULL means that no result or no matching map is available. */ +const float *yunet_map(const yunet *m, const char *name, int *channels, int *height, int *width); + +/* Detector contexts only. Returns the number of detections, or -1 for + * invalid arguments/no result. Results are sorted by score after greedy NMS, in input pixel coordinates, + * without clipping. Landmarks: right eye, left eye, nose, right/left mouth. + * cap limits returned detections, not candidates considered before sorting. */ +int yunet_decode(const yunet *m, float score_threshold, float nms_iou, + yunet_detection *out, int cap); + +/* Returns NULL if optional refinement weights are unavailable or allocation + * fails. This context has a fixed 160x160 BGR input for landmark refinement. */ +yunet *yunet_create_refiner(void); + +/* Replaces landmarks only; boxes, scores, and ordering remain unchanged. + * Each box defines a centered square crop with side 1.3*max(width,height). + * Bilinear sampling uses pixel centers and zero outside the RGB image. + * RGB dimensions are 1..4096; buffer/stride requirements match yunet_set_rgb. + * Returns 0 on success, -1 on error. All detections remain unchanged on error. + * m must be a context returned by yunet_create_refiner. */ +int yunet_refine(yunet *m, const unsigned char *rgb, int width, int height, + size_t row_bytes, yunet_detection *faces, int count); + +#endif |
