void putText( Mat& img, const string& text, Point org, int fontFace,double fontScale, Scalar color, int thickness=1, int lineType=8 );
参数1:, Mat& img,待写字的图片,
参数2:,const string& text,待写入的字,
参数3:, Point org, 第一个字符左下角坐标,
参数4:,int fontFace,字体类型,FONT_HERSHEY_SIMPLEX ,FONT_HERSHEY_PLAIN ,FONT_HERSHEY_DUPLEX 等等等。
参数5:,double fontScale,字体大小,
参数6:,Scalar color,字体颜色,颜色用Scalar()表示,
参数7:, int thickness,字体粗细,
参数8:, int lineType,线型,默认值8.
Mat src = Mat::zeros(900, 1200, CV_8UC1);
//SIMPLEX单工的 duplex双重的 TRIPLEX 三重的。COMPLEX 复杂的。script[skrɪpt]手书
putText(src, "FONT_HERSHEY_PLAIN", Point(20, 100), FONT_HERSHEY_PLAIN, 2, Scalar(255, 255, 255),1);
putText(src, "FONT_HERSHEY_SIMPLEX", Point(20, 200), FONT_HERSHEY_SIMPLEX, 2, Scalar(255, 255, 255),1);
putText(src, "FONT_HERSHEY_DUPLEX", Point(20, 300), FONT_HERSHEY_DUPLEX, 2, Scalar(255, 255, 255),1);
putText(src, "FONT_HERSHEY_TRIPLEX", Point(20, 400), FONT_HERSHEY_TRIPLEX, 2, Scalar(255, 255, 255),1);
putText(src, "FONT_HERSHEY_COMPLEX", Point(20, 500), FONT_HERSHEY_COMPLEX, 2, Scalar(255, 255, 255),1);
putText(src, "FONT_HERSHEY_SCRIPT_SIMPLEX", Point(20, 600), FONT_HERSHEY_SCRIPT_SIMPLEX, 2, Scalar(255, 255, 255),1);
putText(src, "FONT_HERSHEY_SCRIPT_COMPLEX", Point(20, 700), FONT_HERSHEY_SCRIPT_COMPLEX, 2, Scalar(255, 255, 255),1);
putTextHusky(src, "你好!中国", Point(20, 800), Scalar(255, 255, 255),60);
imshow("font", src);
imwrite("font.jpg", src);