python类EVENT_LBUTTONDOWN的实例源码

gui_4.py 文件源码 项目:CE264-Computer_Vision 作者: RobinCPC 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def draw_circle( event, x,y,flags, param):
    global ix, iy, drawing, mode

    if event == cv2.EVENT_LBUTTONDOWN:
        drawing = True
        ix, iy = x, y
    elif event == cv2.EVENT_MOUSEMOVE:
        if drawing == True:
            if mode == True:
                cv2.rectangle( img, (ix, iy), (x,y),(0,255,0), 1)  # -1 for last argument like CV_FILLED
            else:
                cv2.circle( img, (x,y), 5, (0,0,255), -1)
    elif event == cv2.EVENT_LBUTTONUP:
        drawing = False
        if mode == True:
            cv2.rectangle( img, (ix, iy), (x,y), (0,255,0), 1)
        else:
            cv2.circle(img, (x,y), 5, (0,0,255),-1)
demo.py 文件源码 项目:general-deep-image-completion 作者: adamstseng 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def draw(event, x, y, flags, param):
    global ix, iy, drawing

    if event == cv2.EVENT_LBUTTONDOWN:
        drawing = True
        ix, iy = x, y
    elif event == cv2.EVENT_MOUSEMOVE:
        if drawing:
            cv2.line(img, (ix, iy), (x, y), (0.9, 0.01, 0.9), pen_size)
            ix, iy = x, y
    elif event == cv2.EVENT_LBUTTONUP:
        drawing = False
        cv2.line(img, (ix, iy), (x, y), (0.9, 0.01, 0.9), pen_size)
demo.py 文件源码 项目:general-deep-image-completion 作者: adamstseng 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def draw(event, x, y, flags, param):
    global ix, iy, drawing

    if event == cv2.EVENT_LBUTTONDOWN:
        drawing = True
        ix, iy = x, y
    elif event == cv2.EVENT_MOUSEMOVE:
        if drawing:
            cv2.line(img, (ix, iy), (x, y), (0.9, 0.01, 0.9), pen_size)
            ix, iy = x, y
    elif event == cv2.EVENT_LBUTTONUP:
        drawing = False
        cv2.line(img, (ix, iy), (x, y), (0.9, 0.01, 0.9), pen_size)
cameracalibrator.py 文件源码 项目:camera_calibration_frontend 作者: groundmelon 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def on_mouse(self, event, x, y, flags, param):
        if event == cv2.EVENT_LBUTTONDOWN and self.displaywidth < x:
            if self.c.goodenough:
                if 180 <= y < 280:
                    self.c.do_calibration()

            if 280 <= y < 380:
                self.c.do_save()

            if self.c.calibrated:
                if 380 <= y < 480:
                    # Only shut down if we set camera info correctly, #3993
                    if self.do_upload():
                        rospy.signal_shutdown('Quit')
mouse_painting.py 文件源码 项目:PyIntroduction 作者: tody411 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def _callBack(self, event, x, y, flags, param):
        # ????????????????
        if event == cv2.EVENT_LBUTTONDOWN:
            self._doEvent(self._press_func, x, y)
            self._is_drag = True

        # ????????????
        elif event == cv2.EVENT_MOUSEMOVE:
            if self._is_drag:
                self._doEvent(self._drag_func, x, y)

        # ????????????????
        elif event == cv2.EVENT_LBUTTONUP:
            self._doEvent(self._release_func, x, y)
            self._is_drag = False


# ?????????
viewer.py 文件源码 项目:video_labeler 作者: hahnyuan 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def video_click(self,e, x, y, flags, param):
        if e == cv2.EVENT_LBUTTONDOWN:
            self.video_stat.is_drug = 1
            self.video_stat.p0 = (x, y)
            print("rect start", x, y)
        elif e == cv2.EVENT_LBUTTONUP:
            self.video_stat.is_drug = 0
            self.video_stat.p1 = (x, y)
            print("rect end", x, y)
            self.video_stat.append_box(self.label_stat.get_label_name())
        elif e== cv2.EVENT_RBUTTONDOWN:
            self.video_stat.remove_point_box((x,y))
        self.video_stat.p=(x,y)
viewer.py 文件源码 项目:video_labeler 作者: hahnyuan 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def label_click(self,e, x, y, flags, param):
        if e == cv2.EVENT_LBUTTONDOWN:
            self.label_stat.select(y)
tag_bb.py 文件源码 项目:canshi 作者: hungsing92 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def click_and_crop(event, x, y, flags, param):
    global bbs, x_upper, id

    if event == cv2.EVENT_LBUTTONDOWN:
        if x_upper:
            bbs.append([x,y,0,0, 0,0,0,0])
        else:
            bbs[-1][4] = x
            bbs[-1][5] = y

    elif event == cv2.EVENT_LBUTTONUP:
        if x_upper:
            bbs[-1][2] = abs(x - bbs[-1][0])            
            bbs[-1][3] = abs(y - bbs[-1][1])
            bbs[-1][0] = min(x, bbs[-1][0])
            bbs[-1][1] = min(y, bbs[-1][1])
            cv2.rectangle(image, (bbs[-1][0],bbs[-1][1]), (bbs[-1][0]+bbs[-1][2],bbs[-1][1]+bbs[-1][3]), (0,0,255), 2)
            #cv2.putText(image, 'Upper %d' % id, (bbs[-1][0],bbs[-1][1]), cv2.FONT_HERSHEY_SIMPLEX, 0.75, (0,0,255))
        else:
            bbs[-1][6] = abs(x - bbs[-1][4])
            bbs[-1][7] = abs(y - bbs[-1][5])
            bbs[-1][4] = min(x, bbs[-1][4])
            bbs[-1][5] = min(y, bbs[-1][5])
            cv2.rectangle(image, (bbs[-1][4],bbs[-1][5]), (bbs[-1][4]+bbs[-1][6],bbs[-1][5]+bbs[-1][7]), (0,255,0), 2)
            cv2.putText(image, 'Body %d' % id, (bbs[-1][4],bbs[-1][5]), cv2.FONT_HERSHEY_SIMPLEX, 0.75, (0,255,0))


        cv2.imshow("image", image)        
        x_upper = not x_upper
simple-ide.py 文件源码 项目:ATX 作者: NetEaseGame 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def make_mouse_callback(imgs, ref_pt):
    # initialize the list of reference points and boolean indicating
    # whether cropping is being performed or not
    cropping = [False]
    clone = imgs[0]

    def _click_and_crop(event, x, y, flags, param):
        # grab references to the global variables
        # global ref_pt, cropping

        # if the left mouse button was clicked, record the starting
        # (x, y) coordinates and indicate that cropping is being
        # performed
        if event == cv2.EVENT_LBUTTONDOWN:
            ref_pt[0] = (x, y)
            cropping[0] = True

        # check to see if the left mouse button was released
        elif event == cv2.EVENT_LBUTTONUP:
            # record the ending (x, y) coordinates and indicate that
            # the cropping operation is finished
            ref_pt[1] = (x, y)
            cropping[0] = False

            # draw a rectangle around the region of interest
            imgs[1] = image = clone.copy()
            cv2.rectangle(image, ref_pt[0], ref_pt[1], (0, 255, 0), 2)
            cv2.imshow("image", image)
        elif event == cv2.EVENT_MOUSEMOVE and cropping[0]:
            img2 = clone.copy()
            cv2.rectangle(img2, ref_pt[0], (x, y), (0, 255, 0), 2)
            imgs[1] = image = img2
            cv2.imshow("image", image)
    return _click_and_crop
simple-ide.py 文件源码 项目:AutomatorX 作者: xiaoyaojjian 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def make_mouse_callback(imgs, ref_pt):
    # initialize the list of reference points and boolean indicating
    # whether cropping is being performed or not
    cropping = [False]
    clone = imgs[0]

    def _click_and_crop(event, x, y, flags, param):
        # grab references to the global variables
        # global ref_pt, cropping

        # if the left mouse button was clicked, record the starting
        # (x, y) coordinates and indicate that cropping is being
        # performed
        if event == cv2.EVENT_LBUTTONDOWN:
            ref_pt[0] = (x, y)
            cropping[0] = True

        # check to see if the left mouse button was released
        elif event == cv2.EVENT_LBUTTONUP:
            # record the ending (x, y) coordinates and indicate that
            # the cropping operation is finished
            ref_pt[1] = (x, y)
            cropping[0] = False

            # draw a rectangle around the region of interest
            imgs[1] = image = clone.copy()
            cv2.rectangle(image, ref_pt[0], ref_pt[1], (0, 255, 0), 2)
            cv2.imshow("image", image)
        elif event == cv2.EVENT_MOUSEMOVE and cropping[0]:
            img2 = clone.copy()
            cv2.rectangle(img2, ref_pt[0], (x, y), (0, 255, 0), 2)
            imgs[1] = image = img2
            cv2.imshow("image", image)
    return _click_and_crop
ogrid_node.py 文件源码 项目:lqRRT 作者: jnez71 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def do_draw(self, event, x, y, flags, param):
        draw_vals = {1: 100, 2: 0}

        if event == cv2.EVENT_LBUTTONUP or event == cv2.EVENT_RBUTTONUP:
            self.drawing = 0
        elif event == cv2.EVENT_LBUTTONDOWN:
            self.drawing = 1
        elif event == cv2.EVENT_RBUTTONDOWN:
            self.drawing = 2
        elif self.drawing != 0:
            cv2.circle(self.img, (x, y), 5, draw_vals[self.drawing], -1)
extract_signals.py 文件源码 项目:traffic-light-detection 作者: ranveeraggarwal 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def click_and_crop(event, x, y, flags, param):
    # grab references to the global variables
    global refPt, cropping, i

    # if the left mouse button was clicked, record the starting
    # (x, y) coordinates and indicate that cropping is being
    # performed
    if event == cv2.EVENT_LBUTTONDOWN:
        if refPt == []:
            refPt = [(x, y)]
        else:
            refPt.append((x,y))
        cropping = True
        i += 1

    if event == cv2.EVENT_MOUSEMOVE and cropping:
        image2 = image.copy()
        cv2.rectangle(image2, refPt[2*i-2], (x,y), (0,255,0), 2)
        cv2.imshow("image",image2)

    # check to see if the left mouse button was released
    elif event == cv2.EVENT_LBUTTONUP:
        # record the ending (x, y) coordinates and indicate that
        # the cropping operation is finished
        refPt.append((x, y))
        cropping = False

        # draw a rectangle around the region of interest
        cv2.rectangle(image, refPt[2*i-2], refPt[2*i-1], (0, 255, 0), 2)
        # cv2.rectangle(image2, refPt[2*i-2], refPt[2*i-1], (0, 255, 0), 2)
        cv2.imshow("image", image)

# construct the argument parser and parse the arguments
detection_crop_window.py 文件源码 项目:Kaggle_the_Nature_Conservancy_Fisheries_Monitoring 作者: Sapphirine 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def click_and_crop(event, x, y, flags, param):
    global refPt, cropping
    if event == cv2.EVENT_LBUTTONDOWN:    # indicates that the left mouse button is pressed
        refPt = [(x, y)]
        cropping = True
    elif event == cv2.EVENT_RBUTTONDOWN:   # indicates that the right mouse button is pressed
        refPt.append((x, y))
        cropping = False
        cv2.rectangle(image, refPt[0], refPt[1], (0, 255, 0), 2)
        cv2.imshow("image", image)


# <=====================================================================================>
# Here is the process to crop the window and get the position of the graph
# after the classification of the fish boat
naiverstokes:fastmarch.py 文件源码 项目:inpainting 作者: kvfrans 项目源码 文件源码 阅读 30 收藏 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()
get_OD_coodinates.py 文件源码 项目:retinal-exudates-detection 作者: getsanjeev 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def click_and_crop(event, x, y, flags, param):
    # grab references to the global variables
    global refPt, cropping

    # if the left mouse button was clicked, record the starting
    # (x, y) coordinates and indicate that cropping is being
    # performed
    if event == cv2.EVENT_LBUTTONDOWN:
        refPt.append((x, y))
paint.py 文件源码 项目:Course-Projects 作者: manujagobind 项目源码 文件源码 阅读 33 收藏 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 项目源码 文件源码 阅读 25 收藏 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)]))
fengjing_HSV_??.py 文件源码 项目:Opencv_learning 作者: wjb711 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def draw_circle(event,x,y,flags,param):
    #if event == cv2.EVENT_LBUTTONDBLCLK:
    if event == cv2.EVENT_LBUTTONDOWN:
        print ('mouse x and y is ')
        print (x,y)
        px = im1[y,x]
        print ('RGB Value:')
        print (px)
        px_hsv = cv2.cvtColor(im1, cv2.COLOR_BGR2HSV)
        H=px_hsv.item(y,x,0)
        S=px_hsv.item(y,x,1)
        V=px_hsv.item(y,x,2)
        print ('HSV Value: H?S??V')
        print (H,S,V)
fengjing_HSV_??.py 文件源码 项目:Opencv_learning 作者: wjb711 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def draw_circle(event,x,y,flags,param):
    #if event == cv2.EVENT_LBUTTONDBLCLK:
    if event == cv2.EVENT_LBUTTONDOWN:
        print ('mouse x and y is ')
        print (x,y)
        px = im1[y,x]
        print ('RGB Value:')
        print px
        px_hsv = cv2.cvtColor(im1, cv2.COLOR_BGR2HSV)
        H=px_hsv.item(y,x,0)
        S=px_hsv.item(y,x,1)
        V=px_hsv.item(y,x,2)
        print ('HSV Value: H?S??V')
        print (H,S,V)
fengjing_HSV_test.py 文件源码 项目:Opencv_learning 作者: wjb711 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def draw_circle(event,x,y,flags,param):
    #if event == cv2.EVENT_LBUTTONDBLCLK:
    if event == cv2.EVENT_LBUTTONDOWN:
        print ('mouse x and y is ')
        print (x,y)
        px = im1[y,x]
        print ('RGB Value:')
        print px
        px_hsv = cv2.cvtColor(im1, cv2.COLOR_BGR2HSV)
        H=px_hsv.item(y,x,0)
        S=px_hsv.item(y,x,1)
        V=px_hsv.item(y,x,2)
        print ('HSV Value: H?S??V')
        print (H,S,V)


问题


面经


文章

微信
公众号

扫码关注公众号