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 <map>
3#include <opencv2/opencv.hpp>
4#include <string>
5#include <vector>
6
7// FreeType headers
8#include <ft2build.h>
9#include FT_FREETYPE_H
10
12
19class CvxText {
20 public:
25 explicit CvxText(const char *font_path);
26
27 virtual ~CvxText();
28
35 void putText(cv::Mat &img, const std::string &text, cv::Point org,
36 cv::Scalar color, int font_size);
37
46 void getTextSize(const std::string &text, int font_size, int *w, int *h,
47 int *baseline);
48
49 private:
50 CvxText(const CvxText &) = delete;
51 CvxText &operator=(const CvxText &) = delete;
52
54 FT_Face getFace(const char *font_path);
55
57 void utf8_to_ucs4(const std::string &str, std::vector<long> &ucs4);
58
59 private:
60 FT_Library m_library;
61 std::map<std::string, FT_Face> m_faces;
62};
63
64} // 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.