به جای opencv از PIL استفاده کنید.
from PIL import Image, ImageDraw, ImageFont
import arabic_reshaper
from bidi.algorithm import get_display
# Create a new image
img = Image.new('RGB', (500, 500), color='white')
# Create a drawing context
draw = ImageDraw.Draw(img)
# Set the font
font = ImageFont.truetype(r"B Titr Bold_p30download.com.ttf", size=32, encoding='unic')
# Set the text
text = 'این یک متن فارسی است'
# Reshape and reorder the text
reshaped_text = arabic_reshaper.reshape(text)
display_text = get_display(reshaped_text)
# Get the text size
text_size = draw.textsize(display_text, font=font)
# Calculate the position to draw the text
x = (img.width - text_size[0]) / 2
y = (img.height - text_size[1]) / 2
# Draw the text
draw.text((x, y), display_text, fill='black', font=font)
# Save the image
img.save(r'd:\persian_text.png')