當前位置: 首頁>>代碼示例>>Python>>正文


Python cv2.EVENT_FLAG_LBUTTON屬性代碼示例

本文整理匯總了Python中cv2.EVENT_FLAG_LBUTTON屬性的典型用法代碼示例。如果您正苦於以下問題:Python cv2.EVENT_FLAG_LBUTTON屬性的具體用法?Python cv2.EVENT_FLAG_LBUTTON怎麽用?Python cv2.EVENT_FLAG_LBUTTON使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在cv2的用法示例。


在下文中一共展示了cv2.EVENT_FLAG_LBUTTON屬性的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: on_mouse

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import EVENT_FLAG_LBUTTON [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

示例2: onmouse

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import EVENT_FLAG_LBUTTON [as 別名]
def onmouse(self, event, x, y, flags, param):
        x, y = np.int16([x, y]) # BUG
        if event == cv2.EVENT_LBUTTONDOWN:
            self.drag_start = (x, y)
            return
        if self.drag_start:
            if flags & cv2.EVENT_FLAG_LBUTTON:
                xo, yo = self.drag_start
                x0, y0 = np.minimum([xo, yo], [x, y])
                x1, y1 = np.maximum([xo, yo], [x, y])
                self.drag_rect = None
                if x1-x0 > 0 and y1-y0 > 0:
                    self.drag_rect = (x0, y0, x1, y1)
            else:
                rect = self.drag_rect
                self.drag_start = None
                self.drag_rect = None
                if rect:
                    self.callback(rect) 
開發者ID:makelove,項目名稱:OpenCV-Python-Tutorial,代碼行數:21,代碼來源:common.py

示例3: onmouse

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import EVENT_FLAG_LBUTTON [as 別名]
def onmouse(self, event, x, y, flags, param):
        x, y = np.int16([x, y]) # BUG
        if event == cv2.EVENT_LBUTTONDOWN:
            self.drag_start = (x, y)
        if self.drag_start:
            if flags & cv2.EVENT_FLAG_LBUTTON:
                xo, yo = self.drag_start
                x0, y0 = np.minimum([xo, yo], [x, y])
                x1, y1 = np.maximum([xo, yo], [x, y])
                self.drag_rect = None
                if x1-x0 > 0 and y1-y0 > 0:
                    self.drag_rect = (x0, y0, x1, y1)
            else:
                rect = self.drag_rect
                self.drag_start = None
                self.drag_rect = None
                if rect:
                    self.callback(rect) 
開發者ID:NetEase,項目名稱:airtest,代碼行數:20,代碼來源:common.py

示例4: _onmouse

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import EVENT_FLAG_LBUTTON [as 別名]
def _onmouse(self, *args):
        if args[0] == cv2.EVENT_LBUTTONDOWN:
            self.org_pitch, self.org_yaw, self.org_x, self.org_y, self.org_z =\
                self.pitch,self.yaw,self.x,self.y,self.z
            self.clickstart = (self.mousex, self.mousey)

        if args[0] == cv2.EVENT_RBUTTONDOWN:
            self.org_roll = self.roll
            self.clickstart = (self.mousex, self.mousey)

        if (args[3] & cv2.EVENT_FLAG_LBUTTON):
            self.pitch = self.org_pitch + (self.mousex - self.clickstart[0])/10
            self.yaw = self.org_yaw + (self.mousey - self.clickstart[1])

        if (args[3] & cv2.EVENT_FLAG_RBUTTON):
            self.roll = self.org_roll + (self.mousex - self.clickstart[0])/50

        my=args[1]
        mx=args[2]
        self.mousex=mx/float(256)
        self.mousey=my/float(256 * 2) 
開發者ID:alexsax,項目名稱:midlevel-reps,代碼行數:23,代碼來源:pcrender.py

示例5: on_mouse

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import EVENT_FLAG_LBUTTON [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

示例6: onmouse

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import EVENT_FLAG_LBUTTON [as 別名]
def onmouse(self, event, x, y, flags, param):
        x, y = np.int16([x, y]) # BUG
        if event == cv.EVENT_LBUTTONDOWN:
            self.drag_start = (x, y)
            return
        if self.drag_start:
            if flags & cv.EVENT_FLAG_LBUTTON:
                xo, yo = self.drag_start
                x0, y0 = np.minimum([xo, yo], [x, y])
                x1, y1 = np.maximum([xo, yo], [x, y])
                self.drag_rect = None
                if x1-x0 > 0 and y1-y0 > 0:
                    self.drag_rect = (x0, y0, x1, y1)
            else:
                rect = self.drag_rect
                self.drag_start = None
                self.drag_rect = None
                if rect:
                    self.callback(rect) 
開發者ID:thunil,項目名稱:TecoGAN,代碼行數:21,代碼來源:common.py

示例7: onmouse

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import EVENT_FLAG_LBUTTON [as 別名]
def onmouse(self, event, x, y, flags, param):
        x, y = np.int16([x, y]) # BUG
        if event == cv2.EVENT_LBUTTONDOWN:
            self.drag_start = (x, y)
            self.tracking_state = 0
        if self.drag_start:
            if flags & cv2.EVENT_FLAG_LBUTTON:
                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)
            else:
                self.drag_start = None
                if self.selection is not None:
                    self.tracking_state = 1 
開發者ID:fatcloud,項目名稱:PyCV-time,代碼行數:20,代碼來源:camshift.py

示例8: onmouse

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import EVENT_FLAG_LBUTTON [as 別名]
def onmouse(event, x, y, flags, param):
        global seed_pt
        if flags & cv2.EVENT_FLAG_LBUTTON:
            seed_pt = x, y
            update() 
開發者ID:makelove,項目名稱:OpenCV-Python-Tutorial,代碼行數:7,代碼來源:floodfill.py


注:本文中的cv2.EVENT_FLAG_LBUTTON屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。