def drawRectangleOnMouseCallback(self, window_title, color, thickness): # Global variables for rectangle drawing using mouse callbacks. drawing = False ix, iy = -1, -1 # Note: it is important to draw the rectangle from top -> bottom, left -> right. # color - list of three colors (R,G,B). # thickness - thickness of the circumference of the rectangle. -1 will fill the rectangle. # Drawing function. def draw_rectangle(event, x, y, flags, param): global ix, iy, drawing if event == cv.EVENT_LBUTTONDOWN: drawing = True ix, iy = x, y elif event == cv.EVENT_MOUSEMOVE: if drawing: cv.rectangle(self.image, (ix, iy), (x, y), color, thickness) elif event == cv.EVENT_LBUTTONUP: drawing = False cv.rectangle(self.image, (ix, iy), (x, y), color, thickness) # Connecting the image display with the drawing function. cv.namedWindow(winname=window_title) cv.setMouseCallback(window_title, draw_rectangle) # Showing image with OpenCV. imageDisplay(window_name=window_title, image=self.image)
def drawCircleOnMouseCallback(self, window_title, radius, color, thickness): # radius - Radius of the circle. # color - list of three colors (R,G,B). # thickness - thickness of the circumference of the rectangle. -1 will fill the rectangle. # Drawing function. def draw_circle(event, x, y, flags, param): if event == cv.EVENT_LBUTTONDOWN: # Circle will have user selected color. cv.circle(self.image, (x, y), radius, color, thickness) elif event == cv.EVENT_RBUTTONDOWN: # Circle will have alternative color. cv.circle(self.image, (x, y), radius, np.flip(color), thickness) # Connecting the image display with the drawing function. cv.namedWindow(winname=window_title) cv.setMouseCallback(window_title, draw_circle) # Showing image with OpenCV. imageDisplay(window_name=window_title, image=self.image)
def showConcatImages(self, window_name, scale): log.debug("Displaying both the original images and the filtered one") imageDisplay(window_name=window_name, image=self.ConcatMultipleImages(scale=scale))
def showImage(self, window_name): log.debug("Displaying the current image") imageDisplay(window_name=window_name, image=self.image)
def showOriginalImage(self, window_name): log.debug("Displaying the original image") imageDisplay(window_name=window_name, image=self.original_image)