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


Python cv2.EVENT_MBUTTONDOWN属性代码示例

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


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

示例1: on_capture_mouse

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import EVENT_MBUTTONDOWN [as 别名]
def on_capture_mouse (self, wnd_name):
        self.last_xy = (0,0)

        def onMouse(event, x, y, flags, param):
            (inst, wnd_name) = param
            if event == cv2.EVENT_LBUTTONDOWN: ev = InteractBase.EVENT_LBUTTONDOWN
            elif event == cv2.EVENT_LBUTTONUP: ev = InteractBase.EVENT_LBUTTONUP
            elif event == cv2.EVENT_RBUTTONDOWN: ev = InteractBase.EVENT_RBUTTONDOWN
            elif event == cv2.EVENT_RBUTTONUP: ev = InteractBase.EVENT_RBUTTONUP
            elif event == cv2.EVENT_MBUTTONDOWN: ev = InteractBase.EVENT_MBUTTONDOWN
            elif event == cv2.EVENT_MBUTTONUP: ev = InteractBase.EVENT_MBUTTONUP
            elif event == cv2.EVENT_MOUSEWHEEL:
                ev = InteractBase.EVENT_MOUSEWHEEL
                x,y = self.last_xy #fix opencv bug when window size more than screen size
            else: ev = 0

            self.last_xy = (x,y)
            inst.add_mouse_event (wnd_name, x, y, ev, flags)
        cv2.setMouseCallback(wnd_name, onMouse, (self,wnd_name) ) 
开发者ID:iperov,项目名称:DeepFaceLab,代码行数:21,代码来源:interact.py

示例2: on_event

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import EVENT_MBUTTONDOWN [as 别名]
def on_event(self, event, x, y, flags, param):  # pylint: disable=unused-argument,invalid-name
        """ Handle the mouse events """
        # pylint: disable=no-member
        if self.interface.get_edit_mode() != "Edit":
            return
        logger.trace("Mouse event: (event: %s, x: %s, y: %s, flags: %s, param: %s",
                     event, x, y, flags, param)
        if not self.mouse_state and event not in (cv2.EVENT_LBUTTONDOWN, cv2.EVENT_MBUTTONDOWN):
            return

        self.initialize()

        if event in (cv2.EVENT_LBUTTONUP, cv2.EVENT_MBUTTONUP):
            self.mouse_state = None
            self.last_move = None
        elif event == cv2.EVENT_LBUTTONDOWN:
            self.mouse_state = "left"
            self.set_bounding_box(x, y)
        elif event == cv2.EVENT_MBUTTONDOWN:
            self.mouse_state = "middle"
            self.set_bounding_box(x, y)
        elif event == cv2.EVENT_MOUSEMOVE:
            if self.mouse_state == "left":
                self.move_bounding_box(x, y)
            elif self.mouse_state == "middle":
                self.resize_bounding_box(x, y) 
开发者ID:deepfakes,项目名称:faceswap,代码行数:28,代码来源:jobs_manual.py

示例3: mouse_evt

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import EVENT_MBUTTONDOWN [as 别名]
def mouse_evt(event,x,y,flags,param):
	global cons,cams, selected_cam
	if(event == cv2.EVENT_LBUTTONDOWN):
		if(placing):
			if(len(cams)<max_cams):
				cams.append((x,y))
				cons = np.concatenate((cons,np.zeros((1,len(cons)),dtype = np.bool)), axis=0)
				cons = np.concatenate((cons, np.zeros((len(cons), 1),dtype = np.bool)),axis=1)
				update_cameras_img()
				cv2.imshow("Floorplan",cam_img)
		elif(not placing):
			indx = closest_cam(x,y)
			if(indx != None):
				if(selected_cam == None):
					selected_cam = indx
				elif(selected_cam != None):
					if(indx != selected_cam):
						cons[indx][selected_cam] = not cons[indx][selected_cam]
						cons[selected_cam][indx] = not cons[selected_cam][indx]
						selected_cam = None
						update_connections_img()
						cv2.imshow("Floorplan",conn_img)
					elif(indx == selected_cam):
						selected_cam = None

	elif(event == cv2.EVENT_MOUSEMOVE and placing == False and selected_cam != None):
		cur_img = conn_img.copy()
		cv2.line(cur_img, (cams[selected_cam][0],cams[selected_cam][1]), (x,y), (0,0,0), 4)
		cv2.imshow("Floorplan", cur_img)
	elif(event == cv2.EVENT_MBUTTONDOWN):
		if(placing):
			if(len(cams)>0):
				indx = closest_cam(x,y)
				if(indx != None):
					cons = np.delete(cons, indx, axis = 0)
					cons = np.delete(cons, indx, axis = 1)
					del cams[indx]
					update_cameras_img()
					cv2.imshow("Floorplan",cam_img) 
开发者ID:arvganesh,项目名称:Multi-Camera-Object-Tracking,代码行数:41,代码来源:enter_camera_data.py

示例4: click_and_crop

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import EVENT_MBUTTONDOWN [as 别名]
def click_and_crop(event, x, y, flags, param):
	global mouse_x, mouse_y, original_image, color_image
	mouse_x = x
	mouse_y = y
	if event == cv2.EVENT_LBUTTONDOWN:
		ModifyImage()
 
	elif event == cv2.EVENT_MBUTTONDOWN:
		color_image = original_image.copy()

	UpdateImage() 
开发者ID:hjwdzh,项目名称:FrameNet,代码行数:13,代码来源:visualizer.py


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