Python cv2.EVENT_MBUTTONDOWN Examples
The following are 4
code examples of cv2.EVENT_MBUTTONDOWN().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
cv2
, or try the search function
.
Example #1
Source File: interact.py From DeepFaceLab with GNU General Public License v3.0 | 7 votes |
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) )
Example #2
Source File: jobs_manual.py From faceswap with GNU General Public License v3.0 | 5 votes |
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)
Example #3
Source File: enter_camera_data.py From Multi-Camera-Object-Tracking with GNU General Public License v3.0 | 5 votes |
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)
Example #4
Source File: visualizer.py From FrameNet with MIT License | 5 votes |
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()