Drawing results
The input ImageTensor (or ImageTensorU8) can render inference results directly onto the image: bounding boxes, segmentations, barcodes, and optional labels. The in-memory output is uint8 RGB in [batch, height, width, 3] (BHWC) layout.
Overlay behavior
- Labels are multi-line chips placed above each box when possible (below the box if there is no room above), so the object stays visible.
- Nested OD → classification: the label leads with the top classification score(s); the detector class line is omitted when classifications are present. OCR text children are shown as
"…". - Color: for OD → classification, both the box outline and the label use the top nested classification class color (not the detector class, and not split colors). Otherwise the geometry's own class color is used.
- Box outline is expanded slightly outward and supports a configurable line width so thick strokes do not cover the object.
- Python
- C / C++
import denkflow
pipeline = denkflow.Pipeline.from_denkflow("path/to/model.denkflow", pat="YOUR-PAT")
simplified = denkflow.SimplifiedPipeline(pipeline)
image_tensor = denkflow.ImageTensor.from_file("path/to/image.jpg")
results = simplified.run(image_tensor, confidence_threshold=0.5)
annotated = image_tensor.to_images_with_annotations(
results,
annotation_label_font_size=16.0,
top_classifications=1,
bounding_box_line_width=2,
save_path="annotated.png", # optional; batch > 1 is saved as a grid
)
Parameters:
segmentation_fill_alpha:Nonefor outline-only segmentations; a value in(0, 1]fills at that opacity.annotation_label_font_size:Noneto skip labels; otherwise a size relative to a 1080px-tall reference image.top_classifications: how many nested classification scores (highest first) to show on each label (0omits them; default1).bounding_box_line_width: outline thickness in pixels (default1).draw_orientation_lines: draws orientation lines on rotated boxes.save_path: optional path to write the annotated image(s). Format is taken from the extension. With a batch larger than one, images are arranged into a near-square grid and saved as a single file.
ImageTensorU8 exposes the same to_images_with_annotations(...) method.
// run_from_tensor / run_from_file consume the tensor; load a second tensor for annotation.
DenkflowImageTensor* annotation_tensor = NULL;
denkflow_image_tensor_from_file(&annotation_tensor, image_path);
/* The result is a DenkflowImage: RGB pixels in BHWC layout. */
DenkflowImage* annotated = NULL;
denkflow_image_tensor_to_images_with_inference_results(
annotation_tensor,
inference_results,
false, /* draw_orientation_lines */
0.0f, /* segmentation_fill_alpha: 0 = outline segmentations */
16.0f, /* annotation_label_font_size: 0 = no labels */
1, /* top_classifications */
2, /* bounding_box_line_width (0 is treated as 1) */
"annotated.png",/* save_path: NULL to skip writing a file */
&annotated);
/* Access the pixels via annotated->buffer, annotated->batch,
annotated->height, annotated->width, annotated->channels. */
denkflow_image_free(&annotated);
denkflow_image_tensor_free(&annotation_tensor);
Parameters (same semantics as Python):
segmentation_fill_alpha:0.0disables fill (outline only);(0, 1]fills at that opacity.annotation_label_font_size:0.0skips labels; otherwise relative to a 1080px-tall reference image.top_classifications: nested classification scores on each label (0omits them).bounding_box_line_width: outline thickness in pixels (0→1).save_path: optional filesystem path (NULLto skip). Batch size > 1 is saved as one near-square grid. Format comes from the file extension.
For ImageTensorU8 inputs, use denkflow_image_tensor_u8_to_images_with_inference_results with the same argument list.
run_from_file and run_from_tensor consume the image, so a separate tensor is loaded for annotation. The returned DenkflowImage holds the RGB pixels in [batch, height, width, channels] (BHWC) order and is released with denkflow_image_free.