chess_detection.py 文件源码

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

项目:WeiQiRecognition 作者: JDython 项目源码 文件源码
def img_pre_treatment(file_path):
    im = cv2.imread(file_path)
    resize_pic=cv2.resize(im,(640,480),interpolation=cv2.INTER_CUBIC)
    resize_pic = cv2.GaussianBlur(resize_pic,(5,5),0)
    cv2.imwrite('static/InterceptedIMG/resize.jpg',resize_pic)
    kernel = np.ones((3,3),np.uint8)
    resize_pic = cv2.erode(resize_pic,kernel,iterations = 3)
    resize_pic = cv2.dilate(resize_pic,kernel,iterations = 3)
    cv2.imshow('image',resize_pic)
    k = cv2.waitKey(0) & 0xFF
    if k == 27:
        cv2.destroyAllWindows()
    gray = cv2.cvtColor(resize_pic,cv2.COLOR_BGR2GRAY)
    ret, binary = cv2.threshold(gray,90,255,cv2.THRESH_BINARY)
    cv2.imshow('image',binary)
    k = cv2.waitKey(0) & 0xFF
    if k == 27:
        cv2.destroyAllWindows()
    return resize_pic,binary
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号