I am coming to a problem that I am trying to output Armenian letter when I am using my hand which is a sign language application. So, then I am getting "???" why signing a letter. I believe the putText() of opencv is not either deprecated or having issues or maybe not implementing the proper way. Please help. thanks!
Here is my code:
dict_letter = {0: 'Ա', 1: 'Բ', 2: 'Գ', 3: 'Դ', 4: 'Ե', 5: 'Զ', 6: 'Է', 7: 'Ը', 8: 'Թ', 9: 'Ժ', 10: 'Ի', 11: 'Լ', 12: 'Խ', 13: 'Ծ', 14: 'Կ', 15: 'Հ',
16: 'Ձ', 17: 'Ղ', 18: 'Ճ', 19: 'Մ', 20: 'Յ', 21: 'Ն', 22: 'Շ', 23: 'Ո', 24: 'Չ', 25: 'Պ', 26: 'Ջ', 27: 'Ռ', 28: 'Ս', 29: 'Վ', 30: 'Տ', 31: 'Ր',
32: 'Ց', 33: 'Փ', 34: 'Ք', 35: 'Ֆ'}
img = cv2.putText(image_hand,
f"{dict_letter[pred]} - {str(probabs)}",
(x_square, y_square - 5), cv2.FONT_HERSHEY_SIMPLEX,
0.6, (0,0,0), 2)
CodePudding user response:
The builtin vector fonts don't come with those glyphs. Or at least you can't rely on that. There are extensions of the Hershey vector fonts for some unicode. I don't know if OpenCV ships with those.
You can try the freetype
module from the contrib
repository. It has bugs too. Right-to-left script is/was broken. Random usage example: https://github.com/opencv/opencv/issues/14579 (createFreeType2
, loadFontData
on the instance, then use .putText
)
In OpenCV v5 (no release date yet) there will be proper font support.
CodePudding user response:
The function putText() in OpenCV uses Hershey fonts. This is the full set of available characters in Hershey. If your special language characters are not available in the set, it means this is the reason why it doesn't work.