ReUseX  0.0.1
3D Point Cloud Processing for Building Reuse
Loading...
Searching...
No Matches
ReUseX::vision::osd::CvxText Class Reference

FreeType-based text renderer for OpenCV images. More...

#include <cvx_text.hpp>

Public Member Functions

 CvxText (const char *font_path)
 Load the primary font face from the given file path.
virtual ~CvxText ()
void putText (cv::Mat &img, const std::string &text, cv::Point org, cv::Scalar color, int font_size)
 Render a UTF-8 string onto an OpenCV image.
void getTextSize (const std::string &text, int font_size, int *w, int *h, int *baseline)
 Compute the approximate bounding-box dimensions of a rendered string.

Detailed Description

FreeType-based text renderer for OpenCV images.

CvxText renders UTF-8 encoded strings onto cv::Mat images using a TrueType font loaded via the FreeType library. Multiple font faces can be managed through a single instance — the first call to putText or getTextSize for a given font path will load and cache the face automatically.

Definition at line 19 of file cvx_text.hpp.

Constructor & Destructor Documentation

◆ CvxText()

ReUseX::vision::osd::CvxText::CvxText ( const char * font_path)
explicit

Load the primary font face from the given file path.

Parameters
font_pathPath to a TrueType (.ttf) or OpenType font file.
Exceptions
std::runtime_errorif the FreeType library or face cannot be initialized.

Referenced by getTextSize().

◆ ~CvxText()

virtual ReUseX::vision::osd::CvxText::~CvxText ( )
virtual

Member Function Documentation

◆ getTextSize()

void ReUseX::vision::osd::CvxText::getTextSize ( const std::string & text,
int font_size,
int * w,
int * h,
int * baseline )

Compute the approximate bounding-box dimensions of a rendered string.

Parameters
textUTF-8 string to measure.
font_sizeGlyph height in pixels.
[out]wApproximate rendered width in pixels.
[out]hApproximate rendered height (ascent) in pixels.
[out]baselineDistance from the baseline to the bottom of the bounding box.

References CvxText().

◆ putText()

void ReUseX::vision::osd::CvxText::putText ( cv::Mat & img,
const std::string & text,
cv::Point org,
cv::Scalar color,
int font_size )

Render a UTF-8 string onto an OpenCV image.

Parameters
imgDestination image (modified in-place).
textUTF-8 string to render.
orgTop-left drawing origin in image coordinates.
colorBGR text color.
font_sizeGlyph height in pixels.

The documentation for this class was generated from the following file: