def get_circles(self, frame): red = frame[:, :, 0] - frame[:, :, 2] red = images.threshold(red, 120) opened = images.opening(red, (31, 31)) m1 = list(images.center_of_mass(opened)) return [m1[0], m1[1], 50]
def locate_bubble_contour(self): im = self.mean_frame() blur = images.gaussian_blur(im, (31, 31)) threshold = images.threshold(blur, 70) contours = images.find_contours(threshold) contour = images.sort_contours(contours)[-1] return contour
def get_circles(frame): red = frame[:, :, 0] - frame[:, :, 2] red = images.threshold(red, 65) opened = images.opening(red, (31, 31)) w = opened.shape[1] im1, im2 = opened[:, :w//2], opened[:, w//2:] images.display(im1) m1 = list(images.center_of_mass(im1)) m2 = list(images.center_of_mass(im2)) m2[0] += w//2 return np.array([[m1[0], m1[1], 50], [m2[0], m2[1], 50]])
def find_center(self, im): im0 = im.copy() im = images.threshold(im, 80) im = images.opening(im, (6, 6)) center = images.center_of_mass(im) im0 = images.gray_to_bgr(im0) im0 = images.draw_circle(im0, center[0], center[1], 5) im = images.gray_to_bgr(im) im = images.draw_circle(im, center[0], center[1], 5) images.save(images.hstack(im, im0), self.log_direc + '{}.png'.format(self.i)) self.i += 1 return center
def get_circles(frame, left_crop, right_crop): red = frame[:, :, 0] - frame[:, :, 2] red = images.threshold(red, 65) opened = images.opening(red, (31, 31)) w = opened.shape[1] im1 = images.crop(opened, left_crop.bbox) im2 = images.crop(opened, right_crop.bbox) m1 = list(images.center_of_mass(im1)) m2 = list(images.center_of_mass(im2)) m1[0] += left_crop.bbox.xmin m1[1] += left_crop.bbox.ymin m2[0] += right_crop.bbox.xmin m2[1] += right_crop.bbox.ymin return np.array([[m1[0], m1[1], 50], [m2[0], m2[1], 50]])
def get_circles(self, frame): red = frame[:, :, 0] - frame[:, :, 2] red = images.threshold(red, 65) opened = images.opening(red, (31, 31)) im1 = images.crop(opened, self.left_crop.bbox) im2 = images.crop(opened, self.right_crop.bbox) if self.TRACK_LEFT: m1 = list(images.center_of_mass(im1)) else: m1 = [im1.shape[1] // 2, im1.shape[0] // 2] if self.TRACK_RIGHT: m2 = list(images.center_of_mass(im2)) else: m2 = [im2.shape[1] // 2, im2.shape[0] // 2] m1[0] += self.left_crop.bbox.xmin m1[1] += self.left_crop.bbox.ymin m2[0] += self.right_crop.bbox.xmin m2[1] += self.right_crop.bbox.ymin return np.array([[m1[0], m1[1], 50], [m2[0], m2[1], 50]])
def get_circles(frame): red = frame[:, :, 0] - frame[:, :, 2] red = images.threshold(red, 65) opened = images.opening(red, (31, 31)) m = list(images.center_of_mass(opened)) return np.array([m[0], m[1], 50])
def get_center(self, im): threshold = images.threshold(im, 45) circles = images.find_circles(threshold, 11, 200, 5, 6, 7) self.circles = circles return np.mean(circles[:, :2], axis=0)
def threshold(frame, parameters): threshold = parameters['threshold'][0] mode = parameters['threshold mode'] return images.threshold(frame, threshold, mode)