python opencv 画米字形状
【摘要】
效果图:
代码:
import cv2 img=cv2.imread('2621.jpg') if img.shape[1] > 15000: x_scale = 15000 / img.shape[1] img = cv2.resize(img, None, fx=x_scale, fy=x...
效果图:
代码:
import cv2
img=cv2.imread('2621.jpg')
if img.shape[1] > 15000:
x_scale = 15000 / img.shape[1]
img = cv2.resize(img, None, fx=x_scale, fy=x_scale, interpolation=cv2.INTER_AREA)
height,width=img.shape[:2]
thickness = 1
lineType = 4
points=[[0,0,width,height]]
points.append([0,0,width//2,height//2])
points.append([width//2,0,width,height//2])
points.append([0,height//2,width//2,height])
points.append([width//2,height//2,width,height])
for point in points:
x1,y1,x2,y2=point
ptStart = (x1, y1)
ptEnd = (x2,y2)
lines=[[(x1, y2),(x2,y1)]]
lines.append([(x1, y1),(x2,y2)])
lines.append([(x1, (y1+ y2)//2),(x2, (y1+ y2)//2)])
lines.append([((x1+x2)//2, y1),((x1+x2)//2,y2)])
for data in lines:
cv2.line(img, data[0], data[1], (0, 0, 255), thickness, lineType)
cv2.imwrite("result.jpg",img)
# cv2.imshow("sadf",img)
# cv2.waitKey()
文章来源: blog.csdn.net,作者:AI视觉网奇,版权归原作者所有,如需转载,请联系作者。
原文链接:blog.csdn.net/jacke121/article/details/123415231
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)