4

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.

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.

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.

I assume that most of lines in input images should be horizontal/vertically straight. Is there any methods to solve my problem in OpenCV?

For example:

This image is Perspectively warped. I wanna make it image like this :

Suhyeon Lee
  • 569
  • 4
  • 18
  • 1
    Can you add a sample image please? – Micka Feb 04 '15 at 07:07
  • I don't have enough reputation for adding image. Please check the links. – Suhyeon Lee Feb 04 '15 at 08:54
  • ok... if you know that connected same-colored lines build a rectangle, perspective undistortion is very simple up to a scale factor (distinct unknown scale factor for each dimension): just warp the distorted rectangle points to any axis aligned rectangle and use the same homography for the whole image. – Micka Feb 04 '15 at 09:41
  • it should be easy to cluster your lines by 2 directions. You can compute 2 vanishing points from that. But I dont know whether that is enough to calibrate the camera in regards of the target plane... – Micka Feb 04 '15 at 09:45
  • If you can manually select four points (in the distorted image) that form a rectangle in the undistorted image, and if you can provide destination coordinates, then it is pretty easy to do using `getPerpectiveTransform` (see [doc](http://docs.opencv.org/modules/imgproc/doc/geometric_transformations.html#getperspectivetransform)). However, if you want to process a large set of images, the manual selection will be taking too much time... – BConic Feb 04 '15 at 15:45

0 Answers0