Skip to main content

cv2.putText with new lines

Project description

cv2.putText with new lines

Tested against Windows 10 / Python 3.11 / Anaconda

pip install cv2multilinewrite

Code from: https://stackoverflow.com/a/73471951/15096247

import cv2
import numpy as np

image = 200 * np.ones((550, 410, 3), dtype=np.uint8)

image = add_text_to_image(
    image,
    "New line\nDouble new line\n\nLine too longggggggggggggggggggggg",
    top_left_xy=(0, 10),
)
image = add_text_to_image(
    image,
    "Different font scale",
    font_scale=0.5,
    font_color_rgb=(0, 255, 0),
    top_left_xy=(0, 150),
)
image = add_text_to_image(
    image,
    "New line with bg\nDouble new line\n\nLine too longggggggggggggggggggggg",
    bg_color_rgb=(255, 255, 255),
    font_color_rgb=(255, 0, 0),
    top_left_xy=(0, 200),
)
image = add_text_to_image(
    image,
    "Different line specing,\noutline and font face",
    font_color_rgb=(0, 255, 255),
    outline_color_rgb=(0, 0, 0),
    top_left_xy=(0, 350),
    line_spacing=1.5,
    font_face=cv2.FONT_HERSHEY_SCRIPT_SIMPLEX,
)
import matplotlib.pyplot as plt

plt.imshow(image)
plt.show()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cv2multilinewrite-0.10.tar.gz (55.3 kB view details)

Uploaded Source

Built Distribution

cv2multilinewrite-0.10-py3-none-any.whl (55.8 kB view details)

Uploaded Python 3

File details

Details for the file cv2multilinewrite-0.10.tar.gz.

File metadata

  • Download URL: cv2multilinewrite-0.10.tar.gz
  • Upload date:
  • Size: 55.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for cv2multilinewrite-0.10.tar.gz
Algorithm Hash digest
SHA256 a94863d08311b1c2e6c0f245921cf0870f85ae48e5f31cdd7b799c8728e740d3
MD5 d434cca42f02d06feda841ae06297b8e
BLAKE2b-256 232277503bbe3c4264400ab13d6bc1f92e8a0e759aa60956d792a2efc18aa9e8

See more details on using hashes here.

File details

Details for the file cv2multilinewrite-0.10-py3-none-any.whl.

File metadata

File hashes

Hashes for cv2multilinewrite-0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 882b88759d025d22f82b09268b5bdef0c8ee1246c76842ba73adc9c6b9b03e59
MD5 664a59f141a44d2579709b9605abca1b
BLAKE2b-256 1fd789f7c3da5cd68714039d179d2deab0ad33d7332e44b319d9add9a9259969

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page