Change font size and font color

I want to change the font color and size of the text written in cv2.imshow. Please tell the code… how to tackle this problem asap.
@randyzwitch

@randyzwitch please reply to my query asap !!!

Hi @UjjwalG,

Thank you for your patience :balloon:

It is not possible to change the color and font size of cv2 window titles. However, you can:

  1. Use st.markdown above your image to provide a title with the font family, size, and color of your choice and
  2. Display opencv2 images within your Streamlit app via st.image(image, channels="BGR")

Here is an example of how to do it, based on your code:

import streamlit as st
import cv2
import numpy as np

filename = "cat.png"
img = cv2.imread(filename, 1)
image = np.array([img])

original_title = '<p style="font-family:Courier; color:Blue; font-size: 20px;">Original image</p>'
st.markdown(original_title, unsafe_allow_html=True)
st.image(image, channels="BGR")

new_title = '<p style="font-family:sans-serif; color:Green; font-size: 42px;">New image</p>'
st.markdown(new_title, unsafe_allow_html=True)
st.image(image, channels="BGR")

Here’s the resulting output:

Hope this helps :grinning_face_with_smiling_eyes:

Happy Streamlit-ing! :balloon:
Snehan