title: rotate image by pitch, roll, yaw with python-opencv
body: <p>I want to rotate an image with given roll, pitch and yaw</p>
  <p>Here is the example image</p>
  <pre class="lang-py prettyprint-override"><code>import numpy as np
  import math
  import cv2
  
  radian = math.radians(30)
  
  def eulerAnglesToRotationMatrix(theta) :
      R_x = np.array([[1,                  0,                   0],
                      [0, math.cos(theta[0]), -math.sin(theta[0])],
                      [0,  math.sin(theta[0]), math.cos(theta[0]) ]])
      R_y = np.array([[math.cos(theta[1]), 0, math.sin(theta[1])],
                      [0,                  1,                  0],
                      [-math.sin(theta[1]), 0, math.cos(theta[1])]])
      R_z = np.array([[math.cos(theta[2]), -math.sin(theta[2]), 0],
                      [math.sin(theta[2]), math.cos(theta[2]),  0],
                      [0,                  0,                   1]])
      R = np.dot(R_z, np.dot( R_y, R_x ))
      return R
  
  R = eulerAnglesToRotationMatrix((0,radian,0))
  im = cv2.imread('yaw.png')
  im = cv2.warpPerspective(im, R, (im.shape[1], im.shape[0]))
  cv2.imshow('win', im)
  cv2.waitKey(0)
  </code></pre>
  <p>original image</p>
  <p><a href="https://i.stack.imgur.com/AQQhH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AQQhH.png" alt="enter image description here" /></a></p>
  <p>below is the result rotated by pitch 30 degrees.</p>
  <p><a href="https://i.stack.imgur.com/Yed2f.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Yed2f.jpg" alt="enter image description here" /></a></p>
  <p>the result is wrong.</p>
  <p>any idea?</p>