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"));
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
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))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With