contours.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:Notes2ppt 作者: gsengupta2810 项目源码 文件源码
def label_contour(image, c, i, color=(0, 255, 0), thickness=2):
    # compute the center of the contour area and draw a circle
    # representing the center
    M = cv2.moments(c)
    cX = int(M["m10"] / M["m00"])
    cY = int(M["m01"] / M["m00"])

    # draw the contour and label number on the image
    cv2.drawContours(image, [c], -1, color, thickness)
    cv2.putText(image, "#{}".format(i + 1), (cX - 20, cY), cv2.FONT_HERSHEY_SIMPLEX,
                1.0, (255, 255, 255), 2)

    # return the image with the contour number drawn on it
    return image
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号