OpenCV putText UTF-8字符 [英] OpenCV putText UTF-8 characters
本文介绍了OpenCV putText UTF-8字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人能替代OpenCV
putText(支持UTF-8字符)吗?如前所述,putText
仅适用于ASCII字符,而不适用于UTF-8
,例如šŠčČžŽ
?
Does anybody have alternative to OpenCV
putText (with UTF-8 characters supported) ? As already said, putText
is only working for ASCII characters, but not for UTF-8
such as šŠčČžŽ
?
推荐答案
If OpenCV was built with Qt support you can use cv::addText()
to write that string:
cv::Mat img = cv::imread("C:\\snowflake.jpg");
if (img.empty())
{
std::cout << "!!! Failed imread()" << std::endl;
return;
}
cv::addText(img, "áéőúöüóí", cv::Point(100, 50), cv::fontQt("Times"));
但是,如果OpenCV是在没有Qt支持的情况下构建的,则调用cv::addText()
将使您的应用程序崩溃,并在控制台上显示以下错误:
However, if OpenCV was built without Qt support, calling cv::addText()
will crash your application and the following error will be printed to the console:
OpenCV Error: The function/feature is not implemented (The library is compiled without QT support) in cv::fontQt, file C:\builds\2_4_PackSlave-win32-vc12-shared\opencv\modules\highgui\src\window.cpp, line 409
这篇关于OpenCV putText UTF-8字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文