The problem of DLT
h1310321230 opened this issue · 1 comments
The homography matrix computed by opencv function findHomography() is different from solve_DLT().
tip:using opencv
p1 = np.float32([[194.6595, 118.8366],
[258.6257, 84.6884],
[196.5097, 239.1188],
[215.2767, 214.2356]])
p2 = np.float32([[102.3168, 49.8535],
[155.5462, 21.9262],
[96.9939, 152.5195],
[114.5596, 130.9756]])
p3 = p1 - p2
h_mat, mask = cv2.findHomography(p1, p2)
print(h_mat)
The Result:
[[ 5.06455163e-01 -1.05217436e-01 -7.85096847e+00]
[ -4.87824842e-02 5.53376881e-01 -1.81473551e+01]
[ -8.16705616e-04 -6.43053066e-04 1.00000000e+00]]
tip:using solve_DLT in this repo.
p1_tensor = tf.placeholder(tf.float32, (1, 8, 1))
p2_tensor = tf.placeholder(tf.float32, (1, 8, 1))
// I have modify solve_DLT function, like that below:
// # pred_h4p_tile = tf.expand_dims(pred_h4p, [2]) # BATCH_SIZE x 8 x 1
// pred_pts_2_tile = tf.add(pred_h4p, pts_1_tile)
h = solve_DLT(1, p1_tensor, p2_tensor)
with tf.Session() as sess:
p1_feed = np.expand_dims(np.reshape(p1, (8, 1)), axis=0)
print(p1_feed)
p2_feed = np.expand_dims(np.reshape(p3, (8, 1)), axis=0)
mat = sess.run(h, feed_dict={p1_tensor:p1_feed, p2_tensor:p2_feed})
print(mat)
The Result:
[[ 2.08181953e+00 3.77683282e-01 -5.56897621e+01]
[ 2.63900846e-01 1.90892375e+00 -2.00925694e+01]
[ 1.30298373e-03 1.01570075e-03 1.00000000e+00]]
Have you solved the problem? There might be an inconsistency in your points.