The FreeType2 class provides high-quality text rendering capabilities using FreeType fonts. You can create a renderer, load font data from files or memory buffers, and draw text onto images. It supports both synchronous and asynchronous operations for loading data and rendering text.
import 'package:opencv_dart/opencv_dart.dart' as cv;
// Create a FreeType2 instance and load a font file
final ft2 = cv.FreeType2.create(filename: 'path/to/font.ttf');
// Draw text on an image
// img: InputOutputArray (e.g., a Mat)
// text: The string to render
// org: Point for the text origin
// fontHeight: Size in pixels
// color: Scalar color
// thickness: Negative for filled glyphs, positive for line thickness
// lineType: e.g., cv.LINE_8
// bottomLeftOrigin: If true, origin is bottom-left
ft2.putText(
img,
'Hello World',
cv.Point(10, 50),
24,
cv.Scalar(255, 255, 255),
thickness: -1
);