0

I have an issue with perspective transformation in OpenCV (I'm working with Qt). I've attached two images, you can see the contour and how part of the image is lost.

What kind of transformation can I use? Note that the images may or may not have this curvature.

  • Image edited

  • Issue with curvature

thanks

cbuchart
  • 10,847
  • 9
  • 53
  • 93

1 Answers1

0

That's the expected output: an image of the same size but transformed, as it can be seen in OpenCV's page.

If you want to preserve the whole image you have to embed the original one into a larger image (probably centered, with a background color that matches your problem, maybe black) and the apply the transformation to that image. You can later crop-to-fit and scale it to the original size.

cbuchart
  • 10,847
  • 9
  • 53
  • 93
  • 1
    I'm not very fluent with OpenCV so I'm only describing the high-level solution. Probably you can figure out better than me the best way to compute the optimum size _before_ applying the perspective transformation, like applying it to the corners of the image and computing a bounding-box. – cbuchart Mar 14 '17 at 14:14
  • yes, applying the transformation to the corner points and evaluating the bounding rect of the results is a common way to do it. He can have a look at this: http://stackoverflow.com/questions/16587274/opencv-2-4-3-warpperspective-with-reversed-homography-on-a-cropped-image/24425764#24425764 and adjust it to transform the image corners instead of some contour. – Micka Mar 14 '17 at 15:33