gui.py 文件源码

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

项目:piwall-cvtools 作者: infinnovation 项目源码 文件源码
def main(wall_file = None):
    global image, draw_tile, clone
    image = np.zeros((600, 600, 3), dtype = "uint8")
    clone = image.copy()

    cv2.namedWindow("image")
    cv2.setMouseCallback("image", mouse_callback)

    if wall_file:
        _load_wall(wall_file)

    # keep looping until the 'q' key is pressed
    while True:
        # display the image and wait for a keypress
        cv2.imshow("image", image)
        key = cv2.waitKey(1) & 0xFF

        # if the 'r' key is pressed, reset the cropping region
        if key == ord("r"):
            image = clone.copy()

        elif key == ord("g"):
            print("savig the .piwall file")
            target = open(generated_piwall, 'w')
            dotpiwall = DotPiwall("test", wall)
            #print(str(dotpiwall))
            target.write(str(dotpiwall))
            target.close()

        elif key == ord("d"):
            draw_tile = not draw_tile

        elif key == ord("h"):
            help_popup()

        elif key == ord("s"):
            save_wall_popup()

        elif key == ord("l"):
            load_wall_popup()

        elif key == ord("w"):
            print(wall)
            print('gui tiles %d' % len(tiles))

            # if the 'c' key is pressed, break from the loop
        elif key == ord("c") or key == ord("q"):
            break

        # if there are two reference points, then crop the region of interest
        # from teh image and display it
    if len(refPt) == 2:
        roi = clone[refPt[0][1]:refPt[1][1], refPt[0][0]:refPt[1][0]]
        cv2.imshow("ROI", roi)
        cv2.waitKey(0)

    # close all open windows
    cv2.destroyAllWindows()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号