piwall.py 文件源码

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

项目:piwall-cvtools 作者: infinnovation 项目源码 文件源码
def __init__(self, img, squares, all = True):
        #w = ImageViewer(img)
        square_contours = [square.contour for square in squares]
        #pdb.set_trace()
        best_contours_tuples = classify_multi_monitors_contour_set(square_contours)
        best_contours = [contour.astype('int32') for (contour, index) in best_contours_tuples]
        #pdb.set_trace()
        #print('Iterate over %d contours' % len(square_contours))
        if all:
            cycle = True
            while (cycle):
                for (i, c) in enumerate(square_contours):
                    src = img.copy()
                    cv2.drawContours( src, square_contours, i, (0, 255, 0), 1 )
                    cv2.drawContours( src, best_contours, -1, (0,0,255),3)
                    print('contour %d overlaid on basic image' % i)
                    cv2.imshow('view', src)
                    time.sleep(0.2)
                    k = cv2.waitKey(30) & 0xFF
                    if k == 27:
                        cycle = False
        else:
            cycle = True
            src = img.copy()
            while (cycle):
                cv2.drawContours( src, best_contours, -1, (0,0,255),3)
                cv2.imshow('view', src)
                time.sleep(0.2)
                k = cv2.waitKey(30) & 0xFF
                if k == 27:
                    cycle = False

        cv2.destroyWindow('view')

#####################################################################################################################
# Contours and Sets of Contours : various problems in computer vision relevant to the project.
#
# All "Heuristics" functions have the same signature ; img, cnts, *args, **kwargs
#####################################################################################################################
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号