【数学图像专辑001】CV+PLT的三角形画法信息标注

绘制三角形

题目:根据三角形顶点使用OPENCV绘制三角形

1、空三角画法的代码展示:

import numpy as np
from img_pakage.ocv import drawL_C_E_R_P,img_zero


img_pil = img_zero(800,800)
pts = np.array([(250,100),(350,500),(600,380)],np.int32)
drawL_C_E_R_P.polylines(img_pil,[pts],True,(255,255,2555),3,0)

threePoints = ['A','B','C']
for i in range(3):
    img_pil = drawL_C_E_R_P.draw_text(img_pil,pts[i][0],pts[i][1]-5,threePoints[i]+f'({pts[i][0]},{pts[i][1]})',(255,255,2555))
drawL_C_E_R_P.show(img_pil)


if __name__ =='__main__':
    pass

输出效果图:
【数学图像专辑001】CV+PLT的三角形画法信息标注_第1张图片

2、三角形空心效果图02展示:

import numpy as np
from img_pakage.ocv import drawL_C_E_R_P,img_zero


img_pil = img_zero(900,800)
pts = np.array([(250,100),(350,500),(600,380)],np.int32)
drawL_C_E_R_P.polylines(img_pil,[pts],True,(255,255,2555),3,1)

#圈点三角形三个顶点
threePoints = ['A','B','C']
for i in range(3):
    img_pil = drawL_C_E_R_P.draw_text(img_pil,pts[i][0]+35,pts[i][1]-15,threePoints[i]+f'({pts[i][0]},{pts[i][1]})',(255,255,2555))
    drawL_C_E_R_P.circle(img_pil, pts[i][0], pts[i][1], 25, (255, 255, 2555), 3)
drawL_C_E_R_P.show(img_pil,'三角形01',820,600,3)


if __name__ =='__main__':
    pass

输出效果:
【数学图像专辑001】CV+PLT的三角形画法信息标注_第2张图片

3、三角形实心效果图03:

import numpy as np
from img_pakage.ocv import drawL_C_E_R_P,img_zero


import numpy as np
from img_pakage.ocv import drawL_C_E_R_P,img_zero


img_pil = img_zero(900,800)
pts = np.array([(250,100),(350,500),(600,380)],np.int32)
drawL_C_E_R_P.polylines(img_pil,[pts],True,(255,255,2555),3,1)

#圈点三角形三个顶点
threePoints = ['A','B','C']
for i in range(3):
    img_pil = drawL_C_E_R_P.draw_text(img_pil,pts[i][0]+35,pts[i][1]-15,threePoints[i]+f'({pts[i][0]},{pts[i][1]})',(255,255,2555))
    drawL_C_E_R_P.circle(img_pil, pts[i][0], pts[i][1], 25, (255, 255, 2555), -1)
drawL_C_E_R_P.show(img_pil,'三角形实心效果图03',820,600,0)


if __name__ =='__main__':
    pass

输出:

【数学图像专辑001】CV+PLT的三角形画法信息标注_第3张图片

源代码文件下载链接

你可能感兴趣的:(数学图形,Python中级语法,python,开发语言)