本文整理汇总了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
示例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)
示例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)
示例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)
示例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
示例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)
示例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
示例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()