ReUseX  0.0.1
3D Point Cloud Processing for Building Reuse
Loading...
Searching...
No Matches
cvx_text.hpp
Go to the documentation of this file.
1#pragma once
2#include <opencv2/opencv.hpp>
3
4#include <map>
5#include <string>
6#include <vector>
7
8// FreeType headers
9#include <ft2build.h>
10#include FT_FREETYPE_H
11
13
20class CvxText {
21 public:
26 explicit CvxText(const char *font_path);
27
28 virtual ~CvxText();
29
36 void putText(cv::Mat &img, const std::string &text, cv::Point org,
37 cv::Scalar color, int font_size);
38
47 void getTextSize(const std::string &text, int font_size, int *w, int *h,
48 int *baseline);
49
50 private:
51 CvxText(const CvxText &) = delete;
52 CvxText &operator=(const CvxText &) = delete;
53
55 FT_Face getFace(const char *font_path);
56
58 void utf8_to_ucs4(const std::string &str, std::vector<long> &ucs4);
59
60 private:
61 FT_Library m_library;
62 std::map<std::string, FT_Face> m_faces;
63};
64
65} // namespace ReUseX::vision::osd
CvxText(const char *font_path)
Load the primary font face from the given file path.
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.
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.