社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  Python

如何在Python中将文本作为水印垂直打印到图像上

Muhammad Awais • 3 年前 • 1457 次点击  

我这是我的密码

# Json file in which Easyocr anotations have saved.
img = cv2.imread('dummy.jpg')
img1 = img.copy()
#rotoated because anotation have according to vertical alignment of image i have matched the orientation
img1=cv2.rotate(img1,rotateCode=cv2.ROTATE_90_CLOCKWISE)
rects = []
with open('dummy.json') as jsn:
    jsn_dict = json.load(jsn)
for k in jsn_dict['textAnnotations']:
    vertices= k['boundingPoly']['vertices']
    cv2.rectangle(img1,list(vertices[2].values()),list(vertices[0].values()),[0,255,0],10)
# I want to put predicted text on top of bounding boxes vertically because my image is rotated anti clockwise
    cv2.putText(img1, k['description'], list(vertices[0].values()),cv2.FONT_HERSHEY_SIMPLEX,5,[0,255,0],5)

我在上面提到的代码中标记识别的文本, 第一步是,我将图像放入OCR模型,它根据图像返回一些值,其中每个检测到的文本有三个值。这些值是边界框的顶点、已识别的文本和精度百分比。但我的问题是,我的图像被Exif方向值旋转,但cv2将其读取为零角度,而我的文本是水平打印的。我想在图像上垂直打印文本。我试了很多次,但都没能解决我的问题。我希望我已经解释清楚了

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/129415
 
1457 次点击  
文章 [ 2 ]  |  最新文章 3 年前