1
I followed the face detection tutorial using Opencv and wrote in Python 3. This file is not used print
. I already know that Python 3 is international, is compatible with UTF-8 and does not need encodings. But even so, there was no accent on an image. Note that the file is saved in UTF-8.
I put it like this:
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# -*- coding: latin-1 -*-
# -*- coding: iso-8859-15 -*-
import os
import sys
# import the necessary packages
import argparse
import cv2
I’ve put three encodings to work on three different operating systems.
I changed from English to Portuguese, writing a sentence "It’s a cat":
# loop over the cat faces and draw a rectangle surrounding each
for (i, (x, y, w, h)) in enumerate(rects):
cv2.rectangle(image, (x, y), (x + w, y + h), (140, 175, 84), 2)
cv2.putText(image, "É um gato # {}".format(i + 1), (x, y - 10),
cv2.FONT_HERSHEY_SIMPLEX, 0.55, (0, 0, 255), 2) #5faf54
I ran the integrated terminal of Visual Studio Code on Ubuntu 16.04. It is no use to suggest that you run on the native terminal because the same thing happened.
I also tried to:
cv2.encode('utf-8')
And it didn’t work.
Appeared "?? a cat #1" in an image when running and compiling: