|
23 | 23 |
|
24 | 24 | :heavy_check_mark: All the binaries are compiled from source on github action, **no virus**, **no backdoor**, **no secret code**. |
25 | 25 |
|
| 26 | +:heavy_check_mark: ***NEW FEATURE*** [`cv::putText` supports full-width CJK characters](#cvputtext-supports-full-width-cjk-characters) |
| 27 | + |
26 | 28 | |opencv 4.10.0 package size|The official opencv|opencv-mobile| |
27 | 29 | |:-:|:-:|:-:| |
28 | 30 | |source zip|95.2 MB|8.25 MB| |
@@ -481,6 +483,40 @@ zip -r -9 opencv-mobile-4.10.0-mypackage.zip install |
481 | 483 |
|
482 | 484 | * C++ RTTI and exceptions are disabled for minimal build on mobile platforms and webassembly build. Be careful when you write ```cv::Mat roi = image(roirect);``` :P |
483 | 485 |
|
| 486 | +## `cv::putText` supports full-width CJK characters |
| 487 | + |
| 488 | +1. Open https://nihui.github.io/opencv-mobile/patches/fontface.html or `opencv-mobile-X.Y.Z/fontface.html` in your browser. |
| 489 | +2. In the opened page, enter all the text to be drawn, select the TTF font file (optional), click the `Convert to Font Header` button to download the fontface header. This step is completely local operation, without connecting to a remote server, your data is private and safe. |
| 490 | +3. Include the generated fontface header, initialize a fontface instance, and pass it as the argument to `cv::putText`. The source file must be encoded in UTF-8. |
| 491 | + |
| 492 | +Since all characters have been converted to embedded bitmap, the drawing routine does not depend on freetype library or any font files at runtime. |
| 493 | + |
| 494 | +```cpp |
| 495 | +#include <opencv2/core/core.hpp> |
| 496 | +#include <opencv2/highgui/highgui.hpp> |
| 497 | +#include <opencv2/imgproc/imgproc.hpp> |
| 498 | +#include "myfontface.h" |
| 499 | + |
| 500 | +int main() |
| 501 | +{ |
| 502 | + cv::Mat bgr = cv::imread("atari.jpg", 1); |
| 503 | + |
| 504 | + // use this font |
| 505 | + MyFontFace myfont; |
| 506 | + |
| 507 | + // draw full-width text with myfont |
| 508 | + const char* zhtext = "称呼机器人为破铜烂铁,\n违反了禁止歧视机器人法!"; |
| 509 | + cv::putText(bgr, zhtext, cv::Point(30, 250), cv::Scalar(127, 0, 127), myfont, 20); |
| 510 | + |
| 511 | + // get bounding rect |
| 512 | + cv::Rect rr = cv::getTextSize(bgr.size(), zhtext, cv::Point(30, 250), myfont, 20); |
| 513 | + |
| 514 | + cv::imwrite("out.jpg", bgr); |
| 515 | + |
| 516 | + return 0; |
| 517 | +} |
| 518 | +``` |
| 519 | + |
484 | 520 | # opencv modules included |
485 | 521 |
|
486 | 522 | |module|comment| |
|
0 commit comments