简体   繁体   中英

Can't show the image with white text, opencv

The original image is

在此处输入图片说明

font                   = cv2.FONT_HERSHEY_SIMPLEX
bottomLeftCornerOfText = (10,150)
fontScale              = 1
fontColor              = (255,255,255)

cv2.putText(img=img,text='Hello World!', 
    org = bottomLeftCornerOfText,
    fontFace=font, 
    fontScale=fontScale,
    color=fontColor,
    lineType=cv2.LINE_AA,
    thickness=1)

After running the code above, I got image like this

在此处输入图片说明

Only text showed and the background image disappeared. I also tried other colors like blue and green, they all worked fine, both image and text were kept. I wonder why white text doesn't work here and how can I fix it.

Is the image type float from 0.0 to 1.0? Is it one channel grayscale? You are assigning text color with 3 channels and 255 valued... Probably you're having trouble because of one of those.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM