Beispiel #1
0
cam = Camera()
cam.set_K(fx=800, fy=800, cx=640, cy=480)
cam.set_width_heigth(1280, 960)
## DEFINE CAMERA POSE LOOKING STRAIGTH DOWN INTO THE PLANE MODEL
cam.set_R_axisAngle(1.0, 0.0, 0.0, np.deg2rad(160.0))
cam.set_t(0.0, -0.2, 0.4, frame='world')
cam.set_P()

#Create a plane with 4 points to start
pl = Plane(origin=np.array([0, 0, 0]),
           normal=np.array([0, 0, 1]),
           size=(0.2, 0.2),
           n=(2, 2))
pl.uniform()

cams = create_cam_distribution(cam, pl, 0.01, plot=False)

## OBTAIN REFERENCE MODEL POINTS (A PERFECT SQUARE)
objectPoints_ref = pl.get_points()
#objectPoints_ref = np.load('objectPoints_test_ippe5.npy')

## CREATE A SET OF OBJECT POINTS EVENLY DISTRIBUTED FOR VALIDATION OF THE HOMOGRAPHY ESTIMATION
validation_plane = Plane(origin=np.array([0, 0, 0]),
                         normal=np.array([0, 0, 1]),
                         size=(0.4, 0.4),
                         n=(4, 4))
validation_plane.uniform()

#############################################
## WE START THE MAIN LOOP OF CALCULATIONS
#############################################
Beispiel #2
0
cam.set_t(0, x, z)
cam.set_R_mat(R_matrix_from_euler_t(0.0, 0, 0))
cam.look_at([0, 0, 0])

max_deviation = 0.06
deviation_range = np.arange(0, max_deviation + 0.01, 0.01)

#Now we define a distribution of cameras on the space based on this plane
#An optional paremeter is de possible deviation from uniform points
plane_size = (0.3, 0.3)
#cams = create_cam_distribution(cam, plane_size,
#                               theta_params = (0,360,2), phi_params =  (0,70,2),
#                               r_params = (0.5,2.0,2), plot=False)
cams = create_cam_distribution(cam,
                               plane_size,
                               theta_params=(0, 360, 10),
                               phi_params=(0, 70, 10),
                               r_params=(0.3, 2.0, 5),
                               plot=False)
print len(cams)
#%%
new_objectPoints = pl.get_points()

## CREATE A SET OF IMAGE POINTS FOR VALIDATION OF THE HOMOGRAPHY ESTIMATION
# This will create a grid of 16 points of size = (0.3,0.3) meters
validation_plane = Plane(origin=np.array([0, 0, 0]),
                         normal=np.array([0, 0, 1]),
                         size=(0.3, 0.3),
                         n=(4, 4))
validation_plane.uniform()

## we create the gradient for the point distribution
    #World position is defined after rotation matrix
    cam.set_t(x, y, z, frame='world')
    cam.set_P()  # create projection matrix

    #We Create a plane with 4 points with a uniform distribution
    pl = Plane(origin=np.array([0, 0, 0]),
               normal=np.array([0, 0, 1]),
               size=(2.5, 2.5),
               n=(2, 2))

    max_deviation = 0.06
    deviation_range = np.arange(0, max_deviation + 0.01, 0.01)

    #Now we define a distribution of cameras on the space based on this plane
    #An optional paremeter is de possible deviation from uniform points
    cams = create_cam_distribution(cam, pl, max_deviation, plot=True)
##%%
#
#    #We create the set of objectpoints from the planes as an array
#    # for pool workers
#    iters = 1
#
#
#
#    pool = Pool()
#
#
#    noise_range = [0, 1, 2, 3, 4]
#
#    ippe_tvec_error_avg = list()
#    ippe_rmat_error_avg = list()