0
I’m having trouble showing a specific text in an image, I believe the problem is in the source used (cv2.QT_FONT_BOLD), because when I change the source to another as cv2.FONT_HERSHEY_COMPLEX_SMALL, it works normally.
texto = "{}".format(str(round(3.141592*raio*100*fator_conv**2,2))) #cm²
texto2 = "{}".format(str(round(2*raio*fator_conv*100,2))) #cm
cv2.putText(img, texto, (int(cx-0.5*raio),int(cy-0.5*raio)), cv2.FONT_HERSHEY_COMPLEX_SMALL, 1.5, (0, 0, 255))
cv2.putText(img, texto2, (int(cx-0.5*raio), int(cy+0.5*raio)), cv2.QT_FONT_BOLD, 1.5, (255, 0, 0))
The program shows the following error:
Traceback (most recent call last):
File "D:/Projetos/codigos/Detect_HOG+SVM/deteccao_2.py", line 168, in <module>
cv2.putText(img, texto2, (int(cx-0.5*raio), int(cy+0.5*raio)), cv2.QT_FONT_BOLD, 1.5, (255, 0, 0))
cv2.error: OpenCV(3.4.2) C:\projects\opencv-python\opencv\modules\imgproc\src\drawing.cpp:2216: error: (-211:One of arguments' values is out of range) Unknown font type in function 'cv::getFontData'
Process finished with exit code 1
I thought it was because I didn’t have pyqt5 installed in Anaconda’s virtual environment, I installed it and it’s still the same error. I read some tutorials on how to use Qt with python, added
from PyQt5 import QtCore, QtGui
But it didn’t work out. Does anyone have any idea where I might be failing?
Thank you so much for the help! It worked here, I used the cv2.addText function()
– zampnrs