Skip to content

added Cyrillic;#3265

Merged
opencv-pushbot merged 3 commits intoopencv:2.4from
BKNio:putText_develop
Oct 11, 2014
Merged

added Cyrillic;#3265
opencv-pushbot merged 3 commits intoopencv:2.4from
BKNio:putText_develop

Conversation

@BKNio
Copy link
Copy Markdown
Contributor

@BKNio BKNio commented Sep 24, 2014

Added added Cyrillic support for putText and getTextSize

@BKNio
Copy link
Copy Markdown
Contributor Author

BKNio commented Sep 24, 2014

@vpisarev Vadim, please have a look
@kirill-kornyakov FYI

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this part is duplicated twice. Can you put it into an inline function?

added Cyrillic;

replace binary format with hex;

move duplicated code to inline function;
@BKNio
Copy link
Copy Markdown
Contributor Author

BKNio commented Sep 25, 2014

@vpisarev done

@mshabunin
Copy link
Copy Markdown
Contributor

Hi, @BKNio. Looks like letter ё (yo) does not work.
image
Maybe I'm doing something wrong?

@BKNio
Copy link
Copy Markdown
Contributor Author

BKNio commented Sep 25, 2014

Hi, @mshabunin

Yep, it doesn't work, because Hershey doesn't have Ё and ё

@mshabunin
Copy link
Copy Markdown
Contributor

Maybe we should use е glyph instead? I think it will be better than p and ?.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe these if must be enclosed each in other since it's more optimal

@BKNio
Copy link
Copy Markdown
Contributor Author

BKNio commented Sep 26, 2014

@mshabunin fixed

mes

@mshabunin
Copy link
Copy Markdown
Contributor

Thanks, it looks better now.
I have some more thoughts about this functionality:

  • since we are now partially supporting UTF-8, we should test it (modules/highgui/test/test_drawing.cpp could be such place for 2.4 branch)
  • you've removed font check, now drawing cyrillic with different font (or italic) causes invalid reads and segmentation fault
  • malformed UTF-8 string can cause invalid reads

For example, drawing

string text = "\xC0"; // CYRILLIC CAPITAL LETTER A in CP1251 encoding

causes

==22270== Invalid read of size 1
==22270==    at 0x4F66056: cv::putText(cv::Mat&, std::string const&, cv::Point_<int>, int, double, cv::Scalar_<double>, int, int, bool) (drawing.cpp:2012)

@vpisarev
Copy link
Copy Markdown
Contributor

@BKNio, @mshabunin, so what's the decision? In my opinion, this is useful patch and we should finish it. At minimum, there should be a check whether the font contains cyrillic glyphs or not. The handling of malformed strings would be nice to have, but such a check can be added in a subsequent pull request.

@vpisarev
Copy link
Copy Markdown
Contributor

Let's put it in and then submit further fixes when needed.
👍

@vpisarev vpisarev assigned vpisarev and unassigned mshabunin Oct 11, 2014
@opencv-pushbot opencv-pushbot merged commit 5a797ae into opencv:2.4 Oct 11, 2014
vpisarev added a commit that referenced this pull request Oct 11, 2014
@BKNio BKNio deleted the putText_develop branch October 14, 2014 08:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

port/backport done Label for maintainers. Authors of PR can ignore this

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants