Backto OpenCV Index
在图像上绘制文字,
void putText( InputOutputArray img, const String& text, Point org,
int fontFace, double fontScale, Scalar color,
int thickness = 1, int lineType = LINE_8,
bool bottomLeftOrigin = false );
fontFace 字体
其中, fontFace 指的是字体. OpenCV 采用的是适合屏幕显示的 HersheyFonts, 采用了其中的9个基本款. 分别是
FONT_HERSHEY_SIMPLEX = 0
FONT_HERSHEY_PLAIN = 1
FONT_HERSHEY_DUPLEX = 2
FONT_HERSHEY_COMPLEX = 3
FONT_HERSHEY_TRIPLEX = 4
FONT_HERSHEY_COMPLEX_SMALL = 5
FONT_HERSHEY_SCRIPT_SIMPLEX = 6
FONT_HERSHEY_SCRIPT_COMPLEX = 7
FONT_ITALIC = 16
显示效果如下
图像生成代码,
#include <opencv2\opencv.hpp>
int main() {
const cv::String text = "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz0123456789";
cv::Mat frame = cv::Mat::zeros(1080, 1920, CV_8UC3);//black background