@@ -0,0 +1,2481 @@
+#######################################################%0A# AUTHOR  : Ashkan Kiaie-Sandjie                      #%0A# SUMMARY : Contain the logic to compute the angle    #%0A#           between an object and the center of the   #%0A#           image                                     #%0A#######################################################%0A%0Aimport numpy as np%0Aimport argparse%0Aimport cv2%0Aimport sys%0Aimport math%0A%0Afov_horizontal = 53.50%0Awidth_res = 1024%0Aheight_res = 768%0A%0A%0Adef get_angle_from(source_image):%0A    keypoints = get_keypoints(source_image)%0A    pixel_in_width = math.sqrt(math.pow(width_res, 2) + math.pow(width_res, 2))%0A    pixel_degree = fov_horizontal / pixel_in_width%0A%0A    for k in keypoints:%0A        center_x = int(k.pt%5B0%5D)%0A        return center_x * pixel_degree%0A%0A    return 0.0%0A%0Adef print_distance(real_size, focal, size):%0A    distance = real_size * focal / size%0A    print(distance)%0A    return distance%0A%0Adef get_keypoints_image(keypoints, source_image):%0A    image_keypoints = cv2.drawKeypoints(%0A        source_image, keypoints, np.array(%5B%5D),%0A        (0,0,255),%0A        cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)%0A%0A    return image_keypoints%0A%0Adef get_keypoints(source_image):%0A    params = cv2.SimpleBlobDetector_Params()%0A    params.minThreshold = 150%0A    params.maxThreshold = 255%0A    params.minArea = 40%0A    params.maxArea = 20000%0A    params.filterByArea = 1%0A    params.filterByColor = 1%0A    params.filterByConvexity = 1%0A    params.minConvexity = 0.60%0A    params.filterByInertia = 1%0A    params.filterByCircularity = 1%0A    params.minCircularity = 0.6%0A    params.minInertiaRatio = 0.6%0A    params.blobColor = 255%0A    detector = cv2.SimpleBlobDetector(params)%0A    keypoints = detector.detect(source_image)%0A    return keypoints%0A%0Adef show_and_wait(image):%0A    cv2.imshow(%22output%22, image)%0A    cv2.waitKey(0)%0A%0Adef process_size(image_path):%0A    name = image_path%0A    source_image = cv2.imread(name)%0A    angle = get_angle_from(source_image)%0A    return angle%0A%0Adef main(argv=None):%0A    if argv is None:%0A        argv = sys.argv%0A    angle = process_size(%22../tests/calque/3m.jpg%22)%0A    print angle%0A%0A    angle = process_size(%22../tests/calque/5m.jpg%22)%0A    print angle%0A%0A    angle = process_size(%22../tests/calque/6m.jpg%22)%0A    print angle%0A%0A    angle = process_size(%22../tests/calque/7m.jpg%22)%0A    print angle%0A%0A    angle = process_size(%22../tests/calque/8m.jpg%22)%0A    print angle%0A%0A    angle = process_size(%22../tests/calque/9m.jpg%22)%0A    print angle%0A%0A%0Aif __name__ == %22__main__%22:%0A    sys.exit(main())%0A

add function that compute angle from a point