Skip to content

Commit f262e8d

Browse files
committed
Solved Merge Issues
2 parents 2ace844 + 00f3b8d commit f262e8d

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

scripts/Assignment3_Camera_Calibration.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,25 @@ def artagcallback(i):
116116

117117

118118
def calculate_extrinsic(positions, K_matrix, end_effector_positions):
119+
min_error = 10000000000000000
119120
p = get_p(K_matrix, positions)
120121
P = get_P(end_effector_positions)
121-
M = get_projection_matrix(p, P)
122-
K,R = linalg.rq(M[:,0:3])
122+
for i in range(0,1000):
123+
indices = np.random.randint(0, 100, size=6)
124+
M = get_projection_matrix(p[indices,:], P[indices,:])
125+
homogeneous_P = np.hstack((P, np.ones((P.shape[0], 1))))
126+
estimated_p = np.matmul(M,homogeneous_P.T)
127+
estimated_p = estimated_p/estimated_p[2,:]
128+
error = np.linalg.norm(p-estimated_p[0:2,:].T)
129+
print(error)
130+
if error < min_error:
131+
min_error = error
132+
final_M = M
133+
K,R = linalg.rq(final_M[:,0:3])
123134
print(K/K[2,2])
124135
T = np.matmul(np.linalg.inv(K),M[:,3])
125136
H = np.vstack((np.hstack((R,T.reshape((3,1)))),np.array([[0,0,0,1]])))
137+
print(H)
126138
return H
127139

128140
def get_projection_matrix(p, P):
@@ -156,4 +168,10 @@ def get_P(end_effector_position):
156168
return point_3D_world_frame
157169

158170
if __name__ == "__main__":
159-
main(30)
171+
<<<<<<< HEAD
172+
main(30)
173+
=======
174+
main(100)
175+
# calib_info = np.load("calibration_info.npz")
176+
# calculate_extrinsic(calib_info['position'], calib_info['camerainfo'], calib_info['forward_kinematics'])
177+
>>>>>>> 00f3b8d0a97eda761ca978e46306ced5397a027d

0 commit comments

Comments
 (0)