Geralmente quando tenho que escrever um texto em uma imagem eu tenho uma dúvida, qual fonte usar? Isso porque o OpenCV tem várias fontes definidas, mais em alguns caso a escolha da fonte pode prejudicar a visualização.
Aqui estão as fontes do OpenCV
As escalas foram definida com 1 e a largura da linha não foi alterado.
import cv2 import numpy as np img=np.zeros((320,600),dtype=np.uint8) cv2.putText(img,"FONT_HERSHEY_SIMPLEX",(10,30),cv2.FONT_HERSHEY_SIMPLEX,1,255) cv2.putText(img,"FONT_HERSHEY_COMPLEX",(10,60),cv2.FONT_HERSHEY_COMPLEX,1,255) cv2.putText(img,"FONT_HERSHEY_DUPLEX",(10,90),cv2.FONT_HERSHEY_DUPLEX,1,255) cv2.putText(img,"FONT_HERSHEY_TRIPLEX",(10,120),cv2.FONT_HERSHEY_TRIPLEX,1,255) cv2.putText(img,"FONT_HERSHEY_COMPLEX_SMALL",(10,150),cv2.FONT_HERSHEY_COMPLEX_SMALL,1,255) cv2.putText(img,"FONT_HERSHEY_PLAIN",(10,180),cv2.FONT_HERSHEY_PLAIN,1,255) cv2.putText(img,"FONT_HERSHEY_SCRIPT_COMPLEX",(10,210),cv2.FONT_HERSHEY_SCRIPT_COMPLEX,1,255) cv2.putText(img,"FONT_ITALIC",(10,240),cv2.FONT_ITALIC,1,255) cv2.putText(img,"QT_FONT_BLACK",(10,270),cv2.QT_FONT_BLACK,1,255) cv2.putText(img,"QT_FONT_NORMAL",(10,300),cv2.QT_FONT_NORMAL,1,255) cv2.imshow("janela",img) cv2.imwrite("fonte_opencv.jpg",img) cv2.waitKey(0)
Syntax: cv2.putText(image, text, org, font, fontScale, color[, thickness[, lineType[, bottomLeftOrigin]]])
parâmetros:
image: Imagem de entrada
text: String com texto.
org: Coordenada (x,y) da posição da primeira letra
font: Tipo de fonte,
fontScale: Escala da fonte.
color: Cor no formato BGR : (255, 0, 0) para azul.
thickness: Espessura de linha em px.
lineType: Tipo de linha (cv2.LINE_AA, cv2.LINE_8, cv2.LINE_4, cv2.FILLED)
bottomLeftOrigin: Referência da coordenada, quando False o (x,y) e o canto inferior à direita da letra, Quando True (x,y) é o canto superior à direita da primeira letra.
21 Replies to “Escrevendo texto em imagem com OpenCV”
But wanna remark that you have a very decent site, I the pattern it actually stands out. Ashien Gabi Christis
Dear John, Thank you very much
I am really thankful to the holder of this site who has shared this fantastic article at here. Gisele Allistir Krystal
I got what you intend,saved to favorites, very nice site. Drusi Davy Loraine
I’m glad I helped.
If some one desires expert view regarding running a blog then i propose him/her to pay a quick visit this weblog, Keep up the fastidious job. Meridel Allin Celestine
My family every time say that I am killing my time here at web, however I know I am getting knowledge everyday by reading thes good content. Ardeen Garner Moskow
I’ve been there, stay focused, and it will bear good fruit.
Pretty! This was an incredibly wonderful article. Thank you for providing these details. Mercie Kory Rebe
Hello. This post was extremely remarkable, particularly since I was browsing for thoughts on this issue last week. Tabby Pancho Shanks
Hello. This post was extremely remarkable, especially because I was investigating for thoughts on this matter last week. Monica Barry Arly
It is not my first time to visit this web page, i am browsing this web page dailly and take fastidious data from here all the time. Katine Corty Merriman
Every as soon as inside a while we pick out blogs that we study. Listed below are the most current websites that we pick. Kiah Kendal Oswell
Very informative blog article. Thanks Again. Really Great. Cordy Briant Charlotta
I cannot thank you enough for the blog. Much thanks again. Really Great. Diandra Frazer Fonville
I do consider all the concepts you have presented on your post. Cherida Brockie Salomone
I loved your article post. Much thanks again. Much obliged. Gloria Ephrem Eiser
Excellent article. I will be experiencing many of these issues as well.. Charisse Bing Meggs
Thanks again for the article post. Much thanks again. Much obliged. Hannie Godwin Greenberg
It’s going to be ending of mine day, however before end I am reading this wonderful piece of writing to improve my experience.
Keep on writing, great job!