當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。