title: How to detect perspective distortion from single image in OpenCV?
body: <p>I am making a program that recognizes horizontal/vertically straight lines from an image file and creates a bunch of line data for other purpose.</p>
  
  <p>However I got a problem that when I take pictures from diagonally sideways(or up/downwards), that picture shouldn't have horizontally/vertically straight lines so I cannot use that picture.</p>
  
  <p>So I have to make image pre-processing method to invert perspective warping. To do so, I must find current projection value of the image first. 
  Unfortunately I couldn't find a way with OpenCV, unless I add precalculating camera matrix progress before taking picture.</p>
  
  <p>I assume that most of lines in input images should be horizontal/vertically straight. Is there any methods to solve my problem in OpenCV?</p>
  
  <p>For example:</p>
  
  <p><a href="http://i.stack.imgur.com/M7KT9.png" rel="nofollow"><em>This image</em></a> is Perspectively warped. I wanna make it image like <a href="http://i.stack.imgur.com/OHh7B.png" rel="nofollow"><em>this</em></a> :</p>