def ball_only_classifier(circles, color_image, bonus_radius): model = svmlight.read_model("./output/best_single_cup_model_for_ball") ff = find_features() # TODO: fix label = 0 best_classification = 0.5 best_circle = None best_circle_pixels = None for c in circles[:6]: pixels, circle = find_pixels(c, color_image, bonus_radius) # create features for that circle features = ff.generate_features(pixels, label) features = parse_one_line(features) print features # run the classifier on that circle classification = svmlight.classify(model, [features]) print classification if classification[0] > best_classification: best_classification = classification best_circle = [c] best_circle_pixels = pixels # make a decision about whether that circle is circly enough # cv2.imshow("Image processed", circle) # cv2.waitKey() # for the strict form of the classifier, I require that all of the detected circles # are in fact circles. other classifiers may be more lenient return best_circle, best_classification, best_circle_pixels
def simple_classifier(circles, color_image, bonus_radius): model = svmlight.read_model("./output/best_single_cup_model") ff = find_features() # TODO: fix label = 0 new_circles = [] for c in circles[:6]: circle = find_pixels(c, color_image, bonus_radius) new_circles.append(circle) # create features for that circle features = ff.generate_features(circle[0], label) features = parse_one_line(features) print features # run the classifier on that circle classification = svmlight.classify(model, [features]) print classification # make a decision about whether that circle is circly enough # cv2.imshow("Image processed", circle) # cv2.waitKey() # for the strict form of the classifier, I require that all of the detected circles # are in fact circles. other classifiers may be more lenient return new_circles