python类EVENT_LBUTTONUP的实例源码

naiverstokes:fastmarch.py 文件源码 项目:inpainting 作者: kvfrans 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def on_mouse(self, event, x, y, flags, param):
            pt = (x, y)
            if event == cv2.EVENT_LBUTTONDOWN:
                self.prev_pt = pt
            elif event == cv2.EVENT_LBUTTONUP:
                self.prev_pt = None

            if self.prev_pt and flags & cv2.EVENT_FLAG_LBUTTON:
                for dst, color in zip(self.dests, self.colors_func()):
                    cv2.line(dst, self.prev_pt, pt, color, 50)
                self.dirty = True
                self.prev_pt = pt
                self.show()
findbutton.py 文件源码 项目:srcsim2017 作者: ZarjRobotics 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def handle_mouse(event, x, y, flags, param):
    global details
    global cloud
    global ME
    if event == cv2.EVENT_LBUTTONUP:
        point = PointStamped()
        point.header = cloud.header
        point.point.x = details[y, x][0]
        point.point.y = details[y, x][1]
        point.point.z = details[y, x][2]

        print x, y, details[y,x]
        result = ME.transform.tf_buffer.transform(point, 'rightIndexFingerPitch1Link')
        print result

#leftimg,_ = ME.eyes.get_images()
#img = zarj.navigation.PERSPECTIVE_AHEAD.build_rangefinding_image(leftimg)
#cv2.imshow("leftimg", img)

#img = zarj.navigation.PERSPECTIVE_AHEAD.build_rangefinding_image(raw_img)
paint.py 文件源码 项目:Course-Projects 作者: manujagobind 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def draw(event, x, y, flags, param):
    global drawing, ix, iy, shape, canvas, brush

    if event == cv2.EVENT_LBUTTONDOWN:
        drawing = True
        ix, iy = x, y
    elif event == cv2.EVENT_MOUSEMOVE:
        if drawing == True:
            if shape == 1:
                cv2.circle(canvas, (x, y), pencil, color, -1)
            elif shape == 2:
                cv2.circle(canvas, (x, y), brush, color, -1)
            elif shape == 3:
                cv2.circle(canvas, (x, y), eraser, (255, 255, 255), -1)
            elif shape == 5:
                cv2.rectangle(canvas, (ix, iy), (x, y), color, -1)
            elif shape == 6:
                cv2.circle(canvas, (x, y), calc_radius(x, y), color, -1)
    elif event == cv2.EVENT_LBUTTONUP:
        drawing = False
        if shape == 1:
            cv2.circle(canvas, (x, y), pencil, color, -1)
        elif shape == 2:
            cv2.circle(canvas, (x, y), brush, color, -1)
        elif shape == 3:
            cv2.circle(canvas, (x, y), eraser, (255, 255, 255), -1)
        elif shape == 4:
            cv2.line(canvas, (ix, iy), (x, y), color, pencil)
        elif shape == 5:
            cv2.rectangle(canvas, (ix, iy), (x, y), color, -1)
        elif shape == 6:
            cv2.circle(canvas, (x, y), calc_radius(x, y), color, -1)
color_picker.py 文件源码 项目:Opencv-Python-Examples- 作者: arijitx 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def draw_circle(event,x,y,flags,param):
    global ix,iy,drawing,mode
    global img
    im=img.copy()
    if event == cv2.EVENT_LBUTTONDOWN:
        drawing = True
        ix,iy = x,y

    elif event == cv2.EVENT_LBUTTONUP:
        drawing = False
        if mode == True:
            cv2.rectangle(im,(ix,iy),(x,y),(0,255,0),1)
        cv2.imshow('image',im)
        cv2.imshow('res',color_picker([(ix,iy),(x,y)]))
read_mask.py 文件源码 项目:FaceSwap 作者: Aravind-Suresh 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def markPoint(event, x, y, flags, param):
    global idx
    global data
    global input

    if event == cv2.EVENT_LBUTTONUP:
        data.append((x, y))
        cv2.circle(input, (x, y), 3, (0,0,255), 2)
        cv2.putText(input, str(idx), (x, y+4), cv2.FONT_HERSHEY_SIMPLEX, 0.4, (0, 0, 0), 2, cv2.LINE_AA)
        cv2.imshow("Mark points", input)
        idx = idx + 1
things.py 文件源码 项目:srcsim2017 作者: ZarjRobotics 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def handle_mouse(self, event, x, y, flags, param):
        if event == cv2.EVENT_LBUTTONUP:
            print x
            print y
            print self.img[y, x]
army.py 文件源码 项目:srcsim2017 作者: ZarjRobotics 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def handle_mouse(self, event, x, y, flags, param):
        if event == cv2.EVENT_LBUTTONUP:
            point = PointStamped()
            point.header = self.cloud.header
            point.point.x = self.details[y, x][0]
            point.point.y = self.details[y, x][1]
            point.point.z = self.details[y, x][2]

            print x, y, self.details[y,x]
            result = self.zarj.transform.tf_buffer.transform(point, 'rightIndexFingerPitch1Link')
            print result
camera_tune.py 文件源码 项目:FindYourCandy 作者: BrainPad 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def mouse_event(event, x, y, flags, param):
    global should_exit
    if event == cv2.EVENT_LBUTTONUP:
        print("mouse_event:L-click")
        should_exit = True
renk_paleti_cizim.py 文件源码 项目:OpenCV-Drawing-withTrackbar 作者: farcompen 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def sekil_ciz(event, x, y, flags, param):
    global ix, iy
    if event == cv2.EVENT_LBUTTONDOWN:
        ix, iy = x, y
    elif event == cv2.EVENT_LBUTTONUP:
        cv2.line(resim, (ix, iy), (x, y), (mavi_position, yesil_position, kirmizi_position), 3)
opencv_gui_dev1.py 文件源码 项目:ghetto_omr 作者: pohzhiee 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def draw_rectangle(event,x,y,flags,param):
    if event == cv2.EVENT_LBUTTONDOWN:
        drawing = True
        param.drawing=True
        param.setxy(x,y)
        param.printxy()

    elif event == cv2.EVENT_MOUSEMOVE:
        if param.drawing == True:
            a=layering(param.layer_data,param.layer_index)
            img_temp_rect=a.copy()
            img_temp_rect=cv2.rectangle(img_temp_rect,(param.ix,param.iy),(x,y),(0,255,0),2)
            cv2.imshow('image',img_temp_rect)


    elif event == cv2.EVENT_LBUTTONUP:
        param.drawing = False
        shape_dimension1 = np.asarray((param.ix,param.iy))
        shape_dimension2=np.asarray((x,y))

        param.layer_data.resize(param.layer_data.shape[0]+1,4)

        k = param.layer_data.shape
        param.layer_data[k[0]-1, 0] = 1
        param.layer_data[k[0]-1, 1] = shape_dimension1
        param.layer_data[k[0]-1, 2] = shape_dimension2
        param.layer_data[k[0]-1,3]=param.layer_index+1
        param.layer_index=param.layer_index+1
        print param.layer_data
        a=layering(param.layer_data,param.layer_index)
grasp_pos_rgbd_cluster.py 文件源码 项目:Kinect-ASUS-Xtion-Pro-Live-Calibration-Tutorials 作者: taochenshh 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def draw_rect(self,event,x,y,flags,param):
        if event == cv2.EVENT_LBUTTONDOWN:
            self.drawing = True
            self.rect_done = False
            self.ix1 = x
            self.iy1 = y

        elif event == cv2.EVENT_MOUSEMOVE:
            if self.drawing == True:
                self.ix2 = x
                self.iy2 = y


        elif event == cv2.EVENT_LBUTTONUP:
            self.drawing = False
            self.ix2 = x
            self.iy2 = y

            tempimg = self.rgb_image.copy()
            cv2.rectangle(tempimg,(self.ix1,self.iy1),(self.ix2,self.iy2),(0,255,0),2)
            center_point = self.get_center_point()

            cv2.circle(tempimg, tuple(center_point.astype(int)), 3, (0,0,255),-1)
            cv2.imshow('RGB Image', tempimg)
            cv2.waitKey(5)
            self.rect_done = True
grasp_pos.py 文件源码 项目:Kinect-ASUS-Xtion-Pro-Live-Calibration-Tutorials 作者: taochenshh 项目源码 文件源码 阅读 37 收藏 0 点赞 0 评论 0
def draw_rect(self,event,x,y,flags,param):
        if event == cv2.EVENT_LBUTTONDOWN:
            self.drawing = True
            self.rect_done = False
            self.ix1 = x
            self.iy1 = y

        elif event == cv2.EVENT_MOUSEMOVE:
            if self.drawing == True:
                self.ix2 = x
                self.iy2 = y


        elif event == cv2.EVENT_LBUTTONUP:
            self.drawing = False
            self.ix2 = x
            self.iy2 = y

            tempimg = self.rgb_image.copy()
            cv2.rectangle(tempimg,(self.ix1,self.iy1),(self.ix2,self.iy2),(0,255,0),2)
            center_point = self.get_center_point()

            cv2.circle(tempimg, tuple(center_point.astype(int)), 3, (0,0,255),-1)
            cv2.imshow('RGB Image', tempimg)
            cv2.waitKey(5)
            self.rect_done = True
eos_bindings_playground.py 文件源码 项目:thesis_scripts 作者: PhilippKopp 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def click(event, x, y, flags, param):
    global current_landmark

    if event == cv2.EVENT_LBUTTONUP:
        current_landmark = [x, y]
click_bb.py 文件源码 项目:thesis_scripts 作者: PhilippKopp 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def click(event, x, y, flags, param):
    global upper_left_point
    global lower_right_point
    global current_mouse_pos

    if event == cv2.EVENT_LBUTTONDOWN:
        upper_left_point = [x, y]

    if event == cv2.EVENT_LBUTTONUP:
        lower_right_point = [x, y]

    if event == cv2.EVENT_MOUSEMOVE:
        current_mouse_pos = [x, y]
test_camera.py 文件源码 项目:PyDLSSVM 作者: djosix 项目源码 文件源码 阅读 38 收藏 0 点赞 0 评论 0
def reset_tracker(event, x, y, flags, param):
    global tracker, init_rect, is_cropping
    if event == cv2.EVENT_LBUTTONDOWN and not is_cropping:
        is_cropping = True
        init_rect[0:2] = [x, y]
    elif event == cv2.EVENT_LBUTTONUP and is_cropping:
        is_cropping = False
        init_rect[2:4] = [x, y]
        init_rect[0::2].sort()
        init_rect[1::2].sort()
        init_rect[2:4] -= init_rect[0:2]
        if all(init_rect[2:4] > [5, 5]):
            print("Reset target:", init_rect)
            tracker.set_target(init_rect)
setup.py 文件源码 项目:CVMazeRunner 作者: M-Niedoba 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def get_mouse_point(event,x,y,flags,param):
    global point
    if event == cv2.EVENT_LBUTTONUP:
        print("Point {0},{1} selected".format(x,y))
        point = (x,y)
lane_plane.py 文件源码 项目:hazcam 作者: alex-sherman 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def on_click(plane, event, x, y, flags, param):
    if event == cv2.EVENT_LBUTTONUP:
        print((x, y), plane.get_plane_point(x, y))
main.py 文件源码 项目:ConditionalGAN 作者: seungjooli 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def test(m):
    class DrawingState:
        def __init__(self):
            self.x_prev = 0
            self.y_prev = 0
            self.drawing = False
            self.update = True

    def interactive_drawing(event, x, y, flags, param):
        image = param[0]
        state = param[1]
        if event == cv2.EVENT_LBUTTONDOWN:
            state.drawing = True
            state.x_prev, state.y_prev = x, y
        elif event == cv2.EVENT_MOUSEMOVE:
            if state.drawing:
                cv2.line(image, (state.x_prev, state.y_prev), (x, y), (1, 1, 1), 1)
                state.x_prev = x
                state.y_prev = y
                state.update = True
        elif event == cv2.EVENT_LBUTTONUP:
            state.drawing = False
        elif event == cv2.EVENT_RBUTTONDOWN:
            image.fill(0)
            state.update = True

    cv2.namedWindow('Canvas')
    image_input = np.zeros((FLAGS.input_height, FLAGS.input_width, 3), np.float32)
    state = DrawingState()
    cv2.setMouseCallback('Canvas', interactive_drawing, [image_input, state])
    while cv2.getWindowProperty('Canvas', 0) >= 0:
        if state.update:
            reshaped_image_input = np.array([image_input])
            image_output = m.test(reshaped_image_input)
            concatenated = np.concatenate((image_input, image_output[0]), axis=1)
            color_converted = cv2.cvtColor(concatenated, cv2.COLOR_RGB2BGR)
            cv2.imshow('Canvas', color_converted)
            state.update = False

        k = cv2.waitKey(1) & 0xFF
        if k == 27:  # esc
            break
    cv2.destroyAllWindows()
gui.py 文件源码 项目:piwall-cvtools 作者: infinnovation 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def mouse_callback(event, x, y, flags, param):
    global refPt, image, tiles, wall, selected_tile, l_mouse_button_down, mouse_over_tile,\
        clone, offsets

    if event == cv2.EVENT_LBUTTONDOWN:
        l_mouse_button_down = True
        refPt = [(x, y)]
        if not draw_tile:
            if find_hovered_tile(x,y):
                mouse_over_tile = True
                offsets = (x - selected_tile.wx - selected_tile.l, y-selected_tile.wy - selected_tile.t)
            else:
                mouse_over_tile = False

    elif event == cv2.EVENT_LBUTTONUP:
        l_mouse_button_down = False
        if draw_tile:
            #Restrict to create tiles that are at least 100 sqpixel big
            if (abs(refPt[0][0] - x) * abs(refPt[0][1] - y) >= 100):
                newTile = Tile(abs(refPt[0][0] - x), abs(refPt[0][1] - y))
                wall.add_tile(newTile, min(refPt[0][0], x), min(refPt[0][1], y))
                wall.draw(image)
                tiles.append(newTile)
        else:
            print("dragging the tile")

    elif event == cv2.EVENT_RBUTTONUP:
        if find_hovered_tile(x,y):
            tile_popup()

    elif event == cv2.EVENT_MOUSEMOVE:
        # TODO: Implement the t r b resize too
        if l_mouse_button_down and mouse_over_tile and x >= selected_tile.wx and x <= selected_tile.wx + 5:
            new_w = selected_tile.w + selected_tile.wx + selected_tile.l - x
            # TODO: Fix when the bezel is resized to the left
            print(
            "selected_tile.w = {} selected_tile.wx = {} x = {} new_w = {}".format(selected_tile.w, selected_tile.wx, x,
                                                                                  new_w))
            if new_w >= MINIMUM_RESIZE_WIDTH:
                selected_tile.w = new_w
                selected_tile.wx = x - selected_tile.l
                image = clone.copy()
                wall.draw(image)
                print("RESIZING")
        elif l_mouse_button_down and mouse_over_tile and not draw_tile:
            selected_tile.wx = x - offsets[0]
            selected_tile.wy = y - offsets[1]
            image = clone.copy()
            wall.draw(image)
        #TODO: Implement an else that will start drawing the tile while in the draw mode
android_layout.py 文件源码 项目:ATX 作者: NetEaseGame 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def on_mouse(event, x, y, flags, param):
        layout, downpos, ismove = param

        # record downpos
        if event == cv2.EVENT_LBUTTONDOWN:
            print 'click at', x*2, y*2 # picture is half-sized.
            param[1] = (x, y)
            param[2] = False
            return
        # check if is moving
        if event == cv2.EVENT_MOUSEMOVE:
            if ismove: return
            if downpos is None:
                param[2] = False
                return
            _x, _y = downpos
            if (_x-x)**2 + (_y-y)**2 > 64:
                param[2] = True
            return
        if event != cv2.EVENT_LBUTTONUP:
            return

        # update layout.highlight
        b = layout.tree.bounds
        l, t = b.left, b.top
        w, h = b.right - b.left, b.bottom - b.top
        highlight = np.zeros((h, w, 3), np.uint8)

        if downpos and ismove: # drag
            node = layout.find_scrollable_node(x*2+l, y*2+t)
            print 'scroll to', x*2, y*2
            if node:
                b = node.bounds
                print 'scrollable node', b, node.index, node.className,
                print 'resource_id:', node.resourceId,
                print 'text:', node.text.encode(encoding, 'ignore'),
                print 'desc:', node.description.encode(encoding, 'ignore')
                cv2.rectangle(highlight, (b.left-l, b.top-t), (b.right-l, b.bottom-t), (0,255,255), 4)
        else:
            node = layout.find_clickable_node(x*2+l, y*2+t)
            if node:
                b = node.bounds
                print 'clickable node', b, node.index, node.className,
                print 'resource_id:', node.resourceId,
                print 'text:', node.text.encode(encoding, 'ignore'),
                print 'desc:', node.description.encode(encoding, 'ignore')
                print device(className=node.className, index=node.index).info
                cv2.rectangle(highlight, (b.left-l, b.top-t), (b.right-l, b.bottom-t), (0,0,255), 4)
                cond, order = layout.find_selector(node)
                if cond:
                    print 'selector', cond, order
                    subnode = layout._filter_nodes(cond)[order or 0]
                    b = subnode.bounds
                    cv2.rectangle(highlight, (b.left-l, b.top-t), (b.right-l, b.bottom-t), (0,180,255), 4)

        param[0].highlight = highlight
        param[1], param[2] = None, False


问题


面经


文章

微信
公众号

扫码关注公众号