예제 #1
0
def calc_error_prop():
    # Calculating error propagation
    # Points obtained from file /home/mauricio/CSV/err_calc.ods

    list_image_points = np.array([[171, 96.93], [440.3, 91.73],
                                  [32.76, 453.43], [590.23, 447.53]])

    list_obj_points = np.array([[-125, 750], [125, 750], [-125, 250],
                                [125, 250]])

    mat, _ = cv2.findHomography(list_image_points, list_obj_points)
    print('Homography matrix: {0}'.format(mat))

    for index in range(list_image_points.shape[0]):
        point_des = 4
        image_point = list_image_points[index]
        image_point[0] += point_des
        image_point[1] += point_des

        print('Image point: {0}'.format(image_point))

        obj_point = list_obj_points[index]
        proj_point = ClassUtils.project_points(mat, image_point)

        delta_x = proj_point[0] - obj_point[0]
        delta_y = proj_point[1] - obj_point[1]

        print('Projected point: {0}'.format(proj_point))
        print('DeltaX: {0} - DeltaY: {1}'.format(delta_x, delta_y))

    print('Done!')
예제 #2
0
def mouse_callback(event, x_image, y_image, flags, param):
    global config

    if event == cv2.EVENT_LBUTTONDOWN:
        print('Event click - Evaluating elems ' + str(x_image) + ' ' + str(y_image))
        dict_config = json.loads(config)

        homo_mat = np.asarray(dict_config['homographyMat'], dtype='float')
        point = np.float32([x_image, y_image, 1])

        result = ClassUtils.project_points(homo_mat, point)

        print(result)
        print('Done')