OpenCV warpperspective

后端 未结 9 2337
孤城傲影
孤城傲影 2020-12-01 05:45

For some reason whenever I use OpenCV\'s warpPerspective() function, the final warped image does not contain everything in the original image. The left part of the image see

9条回答
  •  再見小時候
    2020-12-01 06:17

    The secret comes in two parts: the transform matrix (homography), and the resulting image size.

    • calculate a correct transform by using the getPerspectiveTransform(). Take 4 points from the original image, calculate their correct position in the destination, put them in two vectors in the same order, and use them to compute the perspective transform matrix.

    • Make sure the destination image size (third parameter for the warpPerspective()) is exactly what you want. Define it as Size(myWidth, myHeight).

提交回复
热议问题