当前位置: 首页>>代码示例>>Python>>正文


Python cv2.EVENT_LBUTTONUP属性代码示例

本文整理汇总了Python中cv2.EVENT_LBUTTONUP属性的典型用法代码示例。如果您正苦于以下问题:Python cv2.EVENT_LBUTTONUP属性的具体用法?Python cv2.EVENT_LBUTTONUP怎么用?Python cv2.EVENT_LBUTTONUP使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在cv2的用法示例。


在下文中一共展示了cv2.EVENT_LBUTTONUP属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: draw_rectangle

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import EVENT_LBUTTONUP [as 别名]
def draw_rectangle(event, x, y, flags, param):
        global start_x, start_y, end_x, end_y, drawing, expected_value
        if event == cv2.EVENT_LBUTTONDOWN:
            # menu position
            if y < 40:
                # menu map
                if x > 8 and x < 148:
                    SaveImage(event)
                if x > 153 and x < 190:
                    OnClose(event)
                if x > 195 and x < 252:
                    print "OpenSource Development: https://github.com/arturaugusto/display_ocr.\nBased on examples availables at https://code.google.com/p/python-tesseract/.\nGPLv2 License"
            else:
                drawing = True
                start_x, start_y = x, y
                end_x, end_y = x, y
        elif event == cv2.EVENT_LBUTTONUP:
            drawing = False
            #start_x,start_y = -1,-1
            #end_x,end_y = -1,-1
        elif event == cv2.EVENT_MOUSEMOVE and drawing:
            if y < 40:
                end_x, end_y = x, 41
            else:
                end_x, end_y = x, y 
开发者ID:arturaugusto,项目名称:display_ocr,代码行数:27,代码来源:OCR.py

示例2: on_mouse

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import EVENT_LBUTTONUP [as 别名]
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, 5)
            self.dirty = True
            self.prev_pt = pt
            self.show()


# palette data from matplotlib/_cm.py 
开发者ID:makelove,项目名称:OpenCV-Python-Tutorial,代码行数:18,代码来源:common.py

示例3: _callBack

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import EVENT_LBUTTONUP [as 别名]
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


# 描画用の空画像作成 
开发者ID:tody411,项目名称:PyIntroduction,代码行数:20,代码来源:mouse_painting.py

示例4: on_mouse

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import EVENT_LBUTTONUP [as 别名]
def on_mouse(event, x, y, flags, params):
    global mousedown, mouseupdown, drawnBox, boxToDraw, initialize
    if event == cv2.EVENT_LBUTTONDOWN:
        drawnBox[[0,2]] = x
        drawnBox[[1,3]] = y
        mousedown = True
        mouseupdown = False
    elif mousedown and event == cv2.EVENT_MOUSEMOVE:
        drawnBox[2] = x
        drawnBox[3] = y
    elif event == cv2.EVENT_LBUTTONUP:
        drawnBox[2] = x
        drawnBox[3] = y
        mousedown = False
        mouseupdown = True
        initialize = True
    boxToDraw = drawnBox.copy()
    boxToDraw[[0,2]] = np.sort(boxToDraw[[0,2]])
    boxToDraw[[1,3]] = np.sort(boxToDraw[[1,3]]) 
开发者ID:moorejee,项目名称:Re3,代码行数:21,代码来源:webcam_demo.py

示例5: mouse_event

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import EVENT_LBUTTONUP [as 别名]
def mouse_event(self, event, x, y, flags, param): 
        x, y = np.int16([x, y]) 
 
        # Detecting the mouse button down event 
        if event == cv2.EVENT_LBUTTONDOWN: 
            self.drag_start = (x, y) 
            self.tracking_state = 0 
 
        if self.drag_start:
            if event == cv2.EVENT_MOUSEMOVE:
                h, w = self.frame.shape[:2] 
                xo, yo = self.drag_start 
                x0, y0 = np.maximum(0, np.minimum([xo, yo], [x, y]))               
                x1, y1 = np.minimum([w, h], np.maximum([xo, yo], [x, y])) 
                self.selection = None 
 
                if x1-x0 > 0 and y1-y0 > 0:
                    self.selection = (x0, y0, x1, y1) 
 
            elif event == cv2.EVENT_LBUTTONUP:
                self.drag_start = None 
                if self.selection is not None: 
                    self.tracking_state = 1 
 
    # Method to start tracking the object 
开发者ID:PacktPublishing,项目名称:OpenCV-3-x-with-Python-By-Example,代码行数:27,代码来源:object_tracker.py

示例6: mouse_event

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import EVENT_LBUTTONUP [as 别名]
def mouse_event(self, event, x, y, flags, param):
        x, y = np.int16([x, y]) 
 
        # Detecting the mouse button down event 
        if event == cv2.EVENT_LBUTTONDOWN: 
            self.drag_start = (x, y) 
            self.tracking_state = 0 
 
        if self.drag_start:
            if event == cv2.EVENT_MOUSEMOVE:
                h, w = param["frame"].shape[:2] 
                xo, yo = self.drag_start 
                x0, y0 = np.maximum(0, np.minimum([xo, yo], [x, y]))               
                x1, y1 = np.minimum([w, h], np.maximum([xo, yo], [x, y])) 
                self.selected_rect = None 
 
                if x1-x0 > 0 and y1-y0 > 0:
                    self.selected_rect = (x0, y0, x1, y1) 
 
            elif event == cv2.EVENT_LBUTTONUP:
                self.drag_start = None 
                if self.selected_rect is not None: 
                    self.callback_func(self.selected_rect)
                    self.selected_rect = None
                    self.tracking_state = 1 
开发者ID:PacktPublishing,项目名称:OpenCV-3-x-with-Python-By-Example,代码行数:27,代码来源:pose_estimation.py

示例7: draw_rectangle

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import EVENT_LBUTTONUP [as 别名]
def draw_rectangle(event, x, y, flags, params): 
    global x_init, y_init, drawing
    def update_pts():
        params["top_left_pt"] = (min(x_init, x), min(y_init, y))
        params["bottom_right_pt"] = (max(x_init, x), max(y_init, y))
        img[y_init:y, x_init:x] = 255 - img[y_init:y, x_init:x]
    if event == cv2.EVENT_LBUTTONDOWN: 
        drawing = True 
        x_init, y_init = x, y 
 
    elif event == cv2.EVENT_MOUSEMOVE and drawing:
        update_pts() 
 
    elif event == cv2.EVENT_LBUTTONUP: 
        drawing = False 
        update_pts() 
开发者ID:PacktPublishing,项目名称:OpenCV-3-x-with-Python-By-Example,代码行数:18,代码来源:04_interacting_video.py

示例8: draw_circle

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import EVENT_LBUTTONUP [as 别名]
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)
            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) 
开发者ID:yzy1996,项目名称:Python-Code,代码行数:22,代码来源:opencv_draw.py

示例9: paint_draw

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import EVENT_LBUTTONUP [as 别名]
def paint_draw(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:
            cv2.line(image, (ix, iy), (x, y), (255, 255, 255), 5)
            ix = x
            iy = y
    elif event == cv2.EVENT_LBUTTONUP:
        drawing = False
        cv2.line(image, (ix, iy), (x, y), (255, 255, 255), 5)
        ix = x
        iy = y
    return x, y 
开发者ID:uvipen,项目名称:QuickDraw,代码行数:18,代码来源:draw.py

示例10: mouse_callback

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import EVENT_LBUTTONUP [as 别名]
def mouse_callback(self, event, x, y, flags, params):
        """
        Callback method for drawing circles on an image
        """

        # left mouse button is pressed
        if event == cv2.EVENT_LBUTTONDOWN:
            self.mouse_pressed = True

        # mouse pointer has moved over the window
        elif event == cv2.EVENT_MOUSEMOVE:
            if self.mouse_pressed:
                cv2.circle(img=self.img, center=(x, y), radius=20, color=self.char_color, thickness=-1)

        # left mouse button is released
        elif event == cv2.EVENT_LBUTTONUP:
            self.mouse_pressed = False
            cv2.circle(img=self.img, center=(x, y), radius=20, color=self.char_color, thickness=-1) 
开发者ID:samkit-jain,项目名称:Handwriting-Recognition,代码行数:20,代码来源:drawer.py

示例11: on_mouse

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import EVENT_LBUTTONUP [as 别名]
def on_mouse(event, x, y, flags, params):
    global mousedown, mouseupdown, drawnBox, boxToDraw, initialize, boxToDraw_xywh
    if event == cv2.EVENT_LBUTTONDOWN:
        drawnBox[[0,2]] = x
        drawnBox[[1,3]] = y
        mousedown = True
        mouseupdown = False
    elif mousedown and event == cv2.EVENT_MOUSEMOVE:
        drawnBox[2] = x
        drawnBox[3] = y
    elif event == cv2.EVENT_LBUTTONUP:
        drawnBox[2] = x
        drawnBox[3] = y
        mousedown = False
        mouseupdown = True
        initialize = True
    boxToDraw = drawnBox.copy()
    boxToDraw[[0, 2]] = np.sort(boxToDraw[[0, 2]])
    boxToDraw[[1, 3]] = np.sort(boxToDraw[[1, 3]])
    boxToDraw_xywh = xyxy_to_xywh(boxToDraw) 
开发者ID:xl-sr,项目名称:THOR,代码行数:22,代码来源:webcam_demo.py

示例12: click_and_crop

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import EVENT_LBUTTONUP [as 别名]
def click_and_crop(event, x, y, flags, param):
    global coors, is_clicked, loop

    # if the button is pressed
    if event == cv2.EVENT_LBUTTONDOWN and not is_clicked:
        coors.append((x, y))
        is_clicked = True

    # if the button is released
    elif event == cv2.EVENT_LBUTTONUP and is_clicked:
        coors.append((x, y))
        is_clicked = False

    # if we have two coordinates
    if len(coors) == 2 and not is_clicked:
        # take the selection and write it to file
        cv2.imwrite(filename + '.png', img[coors[0][1]:coors[1][1], coors[0][0]:coors[1][0]])
        
        # stop looping
        loop = False 
开发者ID:powerhouseofthecell,项目名称:machine_feeling,代码行数:22,代码来源:im_capture.py

示例13: drawShape

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import EVENT_LBUTTONUP [as 别名]
def drawShape(event, x, y, flags, params):
    global mode, drawing, xi, yi

    if event == cv2.EVENT_LBUTTONDOWN:
        drawing = True
        xi, yi = x, y

    elif event == cv2.EVENT_MOUSEMOVE:
        if drawing == True:
            if mode == True:
                cv2.rectangle(image, (xi, yi), (x, y), (0, 255, 0), -1)
            else:
                cv2.circle(image, (x, y), 5, (255, 0, 0), -1)

    elif event == cv2.EVENT_LBUTTONUP:
        drawing = False
        if mode == True:
            cv2.rectangle(image, (xi, yi), (x, y), (0, 255, 0), -1)
        else:
            cv2.circle(image, (x, y), 5, (255, 0, 0), -1) 
开发者ID:amarlearning,项目名称:Finger-Detection-and-Tracking,代码行数:22,代码来源:DrawShape.py

示例14: on_mouse

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import EVENT_LBUTTONUP [as 别名]
def on_mouse(self, event, x, y, flags, param):
        pt = (x, y)
        if event == cv.EVENT_LBUTTONDOWN:
            self.prev_pt = pt
        elif event == cv.EVENT_LBUTTONUP:
            self.prev_pt = None

        if self.prev_pt and flags & cv.EVENT_FLAG_LBUTTON:
            for dst, color in zip(self.dests, self.colors_func()):
                cv.line(dst, self.prev_pt, pt, color, 5)
            self.dirty = True
            self.prev_pt = pt
            self.show()


# palette data from matplotlib/_cm.py 
开发者ID:thunil,项目名称:TecoGAN,代码行数:18,代码来源:common.py

示例15: draw_circle

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import EVENT_LBUTTONUP [as 别名]
def draw_circle(event, x, y, flags, param):
    if event == cv2.EVENT_LBUTTONDBLCLK:
        print("event: EVENT_LBUTTONDBLCLK")
        cv2.circle(image, (x, y), 10, colors['magenta'], -1)

    if event == cv2.EVENT_MOUSEMOVE:
        print("event: EVENT_MOUSEMOVE")

    if event == cv2.EVENT_LBUTTONUP:
        print("event: EVENT_LBUTTONUP")

    if event == cv2.EVENT_LBUTTONDOWN:
        print("event: EVENT_LBUTTONDOWN")


# We create the canvas to draw: 600 x 600 pixels, 3 channels, uint8 (8-bit unsigned integers)
# We set the background to black using np.zeros(): 
开发者ID:PacktPublishing,项目名称:Mastering-OpenCV-4-with-Python,代码行数:19,代码来源:mouse_drawing.py


注:本文中的cv2.EVENT_LBUTTONUP属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。