python opencv 画形状

# 标签格式 bbox = [xl, yl, xr, yr]
bbox1 = [72,41,208,330]
bbox2 = [100,80,248,334]

_mask = np.zeros((image.shape), dtype=np.uint8)
cv2.rectangle(_mask , (bbox1[0], bbox1[1]), (bbox1[2], bbox1[3]),color=(0,0,255), thickness=-1 ) 
#thickness=-1 表示矩形框内颜色填充
center = (100,10)
radius = 10

_mask = np.zeros((image.shape), dtype=np.uint8)
cv2.circle(_mask , center, radius, color=(0,0,255),thickness=-1)
points = [[14.222222222222229, 1076.111111111111], [133.1111111111111, 849.4444444444445],
          [240.8888888888889, 776.1111111111111], [252.0, 737.2222222222222],
          [253.1111111111111, 619.4444444444445], [298.66666666666663, 569.4444444444445],
          [298.66666666666663, 530.5555555555555], [270.8888888888889, 483.88888888888886],
          [247.55555555555554, 355.0], [242.0, 221.66666666666666], [282.0, 188.33333333333331],
          [332.0, 206.11111111111111], [388.66666666666663, 243.88888888888889],
          [433.1111111111111, 182.77777777777777], [457.55555555555554, 93.88888888888889],
          [480.8888888888889, 2.7777777777777777], [512.0, 6.111111111111111],
          [536.4444444444445, 82.77777777777777], [596.4444444444445, 168.33333333333334],
          [683.1111111111111, 171.66666666666666], [746.4444444444443, 227.22222222222223],
          [794.2222222222222, 296.1111111111111], [850.8888888888889, 359.44444444444446],
          [837.5555555555554, 413.88888888888886], [840.8888888888889, 465.0], [792.0, 519.4444444444445],
          [867.5555555555554, 686.1111111111111], [899.7777777777778, 1010.5555555555555],
          [879.7777777777778, 1076.111111111111]]

_mask = np.zeros((image.shape), dtype=np.uint8)
# 填充图形(三角形及以上的多边形)
cv2.fillPoly(_mask , points, color=(0, 165, 255))
cv2.polylines(_mask , points, isClosed=True, thickness=5, color=(144, 238, 144))

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容