def draw_text(img, text, position=(10, 10), font='FreeSans.ttf', font_size=14, color=(0, 0, 0)):
    """Draws text over the image. Requires PIL.

    Args:
        img: The image to use.
        text: The text string to overlay.
        position: The text (x, y) position. (Default value = (10, 10))
        font: The ttf or open type font to use. (Default value = 'FreeSans.ttf')
        font_size: The text font size. (Default value = 12)
        color: The (r, g, b) values for text color. (Default value = (0, 0, 0))

    Returns: Image overlayed with text.
    """
    _check_pil()

    font_files = _find_font_file(font)
    if len(font_files) == 0:
        logger.warn("Failed to lookup font '{}', falling back to default".format(font))
        font = ImageFont.load_default()
    else:
        font = ImageFont.truetype(font_files[0], font_size)

    # Don't mutate original image
    img = Image.fromarray(img)
    draw = ImageDraw.Draw(img)
    draw.text(position, text, fill=color, font=font)
    return np.asarray(img)
def draw_text ( img , text , position = ( 10 , 10 ) , font = 'FreeSans.ttf' , font_size = 14 , color = ( 0 , 0 , 0 ) ) : _check_pil ( ) font_files = _find_font_file ( font ) if len ( font_files ) == 0 : logger . warn ( "Failed to lookup font '{}', falling back to default" . format ( font ) ) font = ImageFont . load_default ( ) else : font = ImageFont . truetype ( font_files [ 0 ] , font_size ) img = Image . fromarray ( img ) draw = ImageDraw . Draw ( img ) draw . text ( position , text , fill = color , font = font ) return np . asarray ( img )
Draws text over the image. Requires PIL.

    Args:
        img: The image to use.
        text: The text string to overlay.
        position: The text (x, y) position. (Default value = (10, 10))
        font: The ttf or open type font to use. (Default value = 'FreeSans.ttf')
        font_size: The text font size. (Default value = 12)
        color: The (r, g, b) values for text color. (Default value = (0, 0, 0))

    Returns: Image overlayed with text.