1.3 KiB
1.3 KiB
C API integration
Include include/yolo_runtime.h, link with libyolo_runtime.so.3, and initialize
all versioned input fields before inference.
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.
Each Seg result contains its own binary ROI mask and mask_bbox. Use
mask_origin_x/y to place the ROI in the original image. If a valid Seg
detection has no foreground mask pixels, mask_data is NULL and the mask
dimensions, origin, stride, and mask_bbox are all zero; the detection bbox
remains valid. Mask memory remains owned by the Runtime and is valid until the
next inference on the same handle.