示例#1
0
volker_metric_des = list()
matrix_cond_ref = list()
matrix_cond_des = list()
algebraic_error_ref = list()
algebraic_error_des = list()

max_iters = 10

for i in range(max_iters):
    for cam in cams:
        ## TRUE VALUE OF HOMOGRAPHY OBTAINED FROM CAMERA PARAMETERS
        Hcam = cam.homography_from_Rt()

        ## GENERATION OF THE DESIRED OBJECT POINTS
        #pl.uniform_with_distortion(mean = 0, sd = 0.02)
        pl.random(n=20, r=0.01, min_sep=0.01)
        objectPoints_des = pl.get_points()

        ## PROJECT OBJECT POINTS INTO CAMERA IMAGE
        imagePoints_ref = np.array(cam.project(objectPoints_ref, False))
        imagePoints_des = np.array(cam.project(objectPoints_des, False))

        ## ADD NOISE
        imagePoints_ref_noisy = cam.addnoise_imagePoints(imagePoints_ref,
                                                         mean=0,
                                                         sd=2)
        imagePoints_des_noisy = cam.addnoise_imagePoints(imagePoints_des,
                                                         mean=0,
                                                         sd=2)

        ## SHOW THE PROJECTIONS IN IMAGE PLANE
示例#2
0
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(179.0))
#cam.set_t(0.0,-0.0,0.5, frame='world')

cam.set_R_axisAngle(1.0, 0.0, 0.0, np.deg2rad(140.0))
cam.set_t(0.0, -0.4, 0.4, frame='world')

## Define a Display plane
pl = Plane(origin=np.array([0, 0, 0]),
           normal=np.array([0, 0, 1]),
           size=(0.3 + 0.5, 0.2 + 0.5),
           n=(2, 2))
pl.random(n=6, r=0.001, min_sep=0.001)

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

## we create the gradient for the point distribution
gradient = gd6.create_gradient(metric='condition_number')
#gradient = gd6.create_gradient(metric='volker_metric')
#gradient = gd6.create_gradient(metric='pnorm_condition_number')

objectPoints_des = pl.get_points()
# we now replace the first 4 points with the border positions
#x = r*np.cos(np.deg2rad(angle))
#z = r*np.sin(np.deg2rad(angle))
#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])

#cam.set_R_axisAngle(1.0,  0.0,  0.0, np.deg2rad(110.0))
#cam.set_t(0.0,-0.3,0.1, frame='world')

## Define a Display plane
pl = Plane(origin=np.array([0, 0, 0]),
           normal=np.array([0, 0, 1]),
           size=(0.3, 0.3),
           n=(2, 2))
pl = CircularPlane()
pl.random(n=number_of_points, r=0.01, min_sep=0.01)

objectPoints = pl.get_points()

x1, y1, x2, y2, x3, y3, x4, y4 = gd.extract_objectpoints_vars(objectPoints)
imagePoints_true = np.array(cam.project(objectPoints, False))
imagePoints_measured = cam.addnoise_imagePoints(imagePoints_true, mean=0, sd=4)
repro = gd.repro_error_autograd(x1, y1, x2, y2, x3, y3, x4, y4, cam.P,
                                imagePoints_measured)
#%%

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