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 šŠčČžŽ
?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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"));
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
回答2:
You didn't specify what language are you using. From Python I'd use the PIL's text drawing function:
draw.text((0, 0), unicode("áéőúöüóí","utf-8"), font=font, fill=(255,255,255))