29 lines
1019 B
Markdown
29 lines
1019 B
Markdown
# C API integration
|
|
|
|
Include `include/yolo_runtime.h`, link with `libyolo_runtime.so.2`, and initialize
|
|
all versioned input fields before inference.
|
|
|
|
```c
|
|
yolo_runtime_t* runtime = NULL;
|
|
if (yolo_runtime_get_abi_version() != YOLO_RUNTIME_ABI_VERSION) return 1;
|
|
if (yolo_runtime_create("models/my_model/my_model.yaml", &runtime) != 0) return 2;
|
|
|
|
yolo_image_view_t image = {0};
|
|
image.struct_size = sizeof(image);
|
|
image.abi_version = YOLO_IMAGE_VIEW_ABI_VERSION;
|
|
image.data = rgb_pixels;
|
|
image.width = width;
|
|
image.height = height;
|
|
image.row_stride_bytes = width * 3;
|
|
image.pixel_format = YOLO_PIXEL_FORMAT_RGB888;
|
|
|
|
yolo_result_list_t results = {0};
|
|
int status = yolo_runtime_infer_image(runtime, &image, &results);
|
|
yolo_runtime_destroy(runtime);
|
|
```
|
|
|
|
The caller owns image memory until the call returns. Classification results do
|
|
not contain a bounding box. OBB results set `bbox.has_angle` and `bbox.angle`.
|
|
Segmentation mask memory remains owned by the Runtime and is valid until the
|
|
next inference on the same handle.
|