Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- theta_in_degrees = 10
- theta_in_radians = theta_in_degrees*math.pi/180
- ux=0.0
- uy=0.0
- uz=1.0
- vector_normalize_factor = math.sqrt(ux*ux+uy*uy+uz*uz)
- ux=ux/vector_normalize_factor
- uy=uy/vector_normalize_factor
- uz=uz/vector_normalize_factor
- print "ux*ux+uy*uy+uz*uz = ", ux*ux+uy*uy+uz*uz
- rotation_matrix = np.zeros([3,3])
- c1 = math.cos(theta_in_radians)
- c2 = 1-c1
- s1 = math.sin(theta_in_radians)
- rotation_matrix[0][0] = c1+ux*ux*c2
- rotation_matrix[0][1] = ux*uy*c2-uz*s1
- rotation_matrix[0][2] = ux*uz*c2+uy*s1
- rotation_matrix[1][0] = uy*ux*c2+uz*s1
- rotation_matrix[1][1] = c1+uy*uy*c2
- rotation_matrix[1][2] = uy*uz*c2-ux*s1
- rotation_matrix[2][0] = uz*ux*c2-uy*s1
- rotation_matrix[2][1] = uz*uy*c2+ux*s1
- rotation_matrix[2][2] = c1+uz*uz*c2
- print "rotation_matrix = ", rotation_matrix
- R = rotation_matrix
- #Calculate homography H1 between reference top view and rotated frame
- k_inv = np.linalg.inv(k)
- Hi = k.dot(R)
- Hii = k_inv.dot(h)
- H1 = Hi.dot(Hii)
- print "H1 = ", H1
- im_out = cv2.warpPerspective(im_src, H1, (im_dst.shape[1],im_dst.shape[0]))
- [[ 1.71025842e+00 -7.51761942e-01 1.02803446e+02]
- [ -2.98552735e-16 1.39232576e-01 1.62792482e+02]
- [ -1.13518150e-18 -2.27094753e-03 1.00000000e+00]]
- [[ 1.41009391e+09 0.00000000e+00 5.14000000e+02]
- [ 0.00000000e+00 1.78412347e+02 1.17000000e+02]
- [ 0.00000000e+00 0.00000000e+00 1.00000000e+00]]
Add Comment
Please, Sign In to add comment