python图像物体的自动标注尺寸

编程入门 行业动态 更新时间:2024-10-27 21:25:10

python图像<a href=https://www.elefans.com/category/jswz/34/1765220.html style=物体的自动标注尺寸"/>

python图像物体的自动标注尺寸

一、 题目描述

测量所给图片的高度,即上下边缘间的距离。

思路:

将图片进行阈值操作得到二值化图片。

截取只包含上下边框的部分,以便于后续的轮廓提取

轮廓检测

得到结果

二、 实现过程

1.用于给图片添加中文字符

#用于给图片添加中文字符

def ImgText_CN(img, text, left, top, textColor=(0, 255, 0), textSize=20):

if (isinstance(img, np.ndarray)): #判断是否为OpenCV图片类型

img = Image.fromarray(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))

draw = ImageDraw.Draw(img)

fontText = ImageFont.truetype(r'C:\Windows\Fonts\simsun.ttc', textSize, encoding="utf-8") ##中文字体

draw.text((left, top), text, textColor, font=fontText) #写文字

return cv2.cvtColor(np.asarray(img), cv2.COLOR_RGB2BGR)

2.实现图片反色功能

#实现图片反色功能

def PointInvert(img):

height, width = img.shape #获取图片尺寸

for i in range(height):

for j

更多推荐

python图像物体的自动标注尺寸

本文发布于:2024-03-09 13:08:22,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1725041.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:物体   图像   尺寸   python

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!