title: OpenCV Straighten an Image with Python
body: <p>Is there any way that I can straighten this image using OpenCV with Python? I was figuring it out using the different transformations but I cant get it.</p>
  
  <p><a href="https://i.stack.imgur.com/fq8MR.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fq8MR.jpg" alt="Image"></a></p>
  
  <p>Here is my code:</p>
  
  <pre><code>rows, cols, h = img.shape
  
  M = np.float32([[1, 0, 100], [0, 1, 50]])
  </code></pre>
  
  <p>And then I apply Affine Transformation.</p>
  
  <pre><code>dst = cv2.warpAffine(roi, M, (cols, rows))
  </code></pre>
  
  <p>Still I cant get the desired output of the image to be straighten. Scratching my head for almost an hour now. Anyone can help me please?</p>