Guest User

Untitled

a guest
Jan 16th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. theta_in_degrees = 10
  2. theta_in_radians = theta_in_degrees*math.pi/180
  3. ux=0.0
  4. uy=0.0
  5. uz=1.0
  6. vector_normalize_factor = math.sqrt(ux*ux+uy*uy+uz*uz)
  7. ux=ux/vector_normalize_factor
  8. uy=uy/vector_normalize_factor
  9. uz=uz/vector_normalize_factor
  10. print "ux*ux+uy*uy+uz*uz = ", ux*ux+uy*uy+uz*uz
  11. rotation_matrix = np.zeros([3,3])
  12. c1 = math.cos(theta_in_radians)
  13. c2 = 1-c1
  14. s1 = math.sin(theta_in_radians)
  15. rotation_matrix[0][0] = c1+ux*ux*c2
  16. rotation_matrix[0][1] = ux*uy*c2-uz*s1
  17. rotation_matrix[0][2] = ux*uz*c2+uy*s1
  18. rotation_matrix[1][0] = uy*ux*c2+uz*s1
  19. rotation_matrix[1][1] = c1+uy*uy*c2
  20. rotation_matrix[1][2] = uy*uz*c2-ux*s1
  21. rotation_matrix[2][0] = uz*ux*c2-uy*s1
  22. rotation_matrix[2][1] = uz*uy*c2+ux*s1
  23. rotation_matrix[2][2] = c1+uz*uz*c2
  24. print "rotation_matrix = ", rotation_matrix
  25. R = rotation_matrix
  26. #Calculate homography H1 between reference top view and rotated frame
  27. k_inv = np.linalg.inv(k)
  28. Hi = k.dot(R)
  29. Hii = k_inv.dot(h)
  30. H1 = Hi.dot(Hii)
  31. print "H1 = ", H1
  32. im_out = cv2.warpPerspective(im_src, H1, (im_dst.shape[1],im_dst.shape[0]))
  33.  
  34. [[ 1.71025842e+00 -7.51761942e-01 1.02803446e+02]
  35. [ -2.98552735e-16 1.39232576e-01 1.62792482e+02]
  36. [ -1.13518150e-18 -2.27094753e-03 1.00000000e+00]]
  37.  
  38. [[ 1.41009391e+09 0.00000000e+00 5.14000000e+02]
  39. [ 0.00000000e+00 1.78412347e+02 1.17000000e+02]
  40. [ 0.00000000e+00 0.00000000e+00 1.00000000e+00]]
Add Comment
Please, Sign In to add comment