k-Nearest Neighbour classification – OpenCV 3.4 with python 3 Tutorial 33

Source code: [python] import cv2 import numpy as np def mouse_pos(event, x, y, flags, params): global squares, color, new_element if event == cv2.EVENT_LBUTTONDOWN: if color == "b": blue_squares.append([x, y]) elif color == "r": red_squares.append([x, y]) else: new_element = [x, y] # Create Window and Set mouse events cv2.namedWindow("Frame") cv2.setMouseCallback("Frame", mouse_pos) # Create an empty image […]