Ejemplo n.º 1
0
def mouse_callback(event, x, y, flags, image):
    global first_anchor
    global second_anchor
    global box_drawing
    global temp
    global box
    global scene
    if event == cv2.EVENT_MOUSEMOVE:
        if box_drawing and first_anchor:
            box = (first_anchor, (x, y))
            temp = image.copy()
            draw_box(temp, *box)
    if event == cv2.EVENT_LBUTTONDOWN:
        temp = image.copy()
        box_drawing = not box_drawing
        if not first_anchor:
            first_anchor = (x, y)
        else:
            second_anchor = (x, y)
        if first_anchor and second_anchor:
            subimage = get_subimage(image, *box)
            # cv2.imshow('subimage', subimage)
            # plot_hist_hls(subimage)
            if scene:
                scene.clear()
            scene = Scene(subimage)
            scene.analysis()
            if scene.info:
                scene.highlight_contours()
            first_anchor = None
            second_anchor = None
Ejemplo n.º 2
0
def mouse_callback(event, x, y, flags, image):
    global first_anchor
    global second_anchor
    global box_drawing
    global temp
    global box
    global scene
    if event == cv2.EVENT_MOUSEMOVE:
        if box_drawing and first_anchor:
            box = (first_anchor, (x, y))
            temp = image.copy()
            draw_box(temp, *box)
    if event == cv2.EVENT_LBUTTONDOWN:
        temp = image.copy()
        box_drawing = not box_drawing
        if not first_anchor:
            first_anchor = (x, y)
        else:
            second_anchor = (x, y)
        if first_anchor and second_anchor:
            subimage = get_subimage(image, *box)
            #cv2.imshow('subimage', subimage)
            #plot_hist_hls(subimage)
            if scene: scene.clear()
            scene = Scene(subimage)
            scene.analysis()
            if scene.info:
                scene.highlight_contours()
            first_anchor = None
            second_anchor = None
Ejemplo n.º 3
0
            if scene.info:
                scene.highlight_contours()
            first_anchor = None
            second_anchor = None


main_window = 'main'
temp = image.copy()

if debug:
    while True:
        cv2.setMouseCallback(main_window, mouse_callback, image)
        cv2.imshow(main_window, temp)
        if cv2.waitKey(10) & 0xff == 27:
            cv2.destroyAllWindows()
            break
else:
    while True:
        cv2.imshow(main_window, image)
        key = cv2.waitKey(10)
        #print key
        scene = Scene(image)
        if key & 0xff == 32:
            if not scene.info:
                scene.analysis()
            else:
                scene.highlight_contours()
        elif key & 0xff == 27:
            cv2.destroyAllWindows()
            break
Ejemplo n.º 4
0
            if scene.info:
                scene.highlight_contours()
            first_anchor = None
            second_anchor = None


main_window = "main"
temp = image.copy()

if debug:
    while True:
        cv2.setMouseCallback(main_window, mouse_callback, image)
        cv2.imshow(main_window, temp)
        if cv2.waitKey(10) & 0xFF == 27:
            cv2.destroyAllWindows()
            break
else:
    while True:
        cv2.imshow(main_window, image)
        key = cv2.waitKey(10)
        # print key
        scene = Scene(image)
        if key & 0xFF == 32:
            if not scene.info:
                scene.analysis()
            else:
                scene.highlight_contours()
        elif key & 0xFF == 27:
            cv2.destroyAllWindows()
            break