OpenCV Q&A Forum - RSS feedhttp://answers.opencv.org/questions/OpenCV answersenCopyright <a href="http://www.opencv.org">OpenCV foundation</a>, 2012-2018.Sun, 30 Jun 2013 18:37:27 -0500Eliminate scaling from perspective transformhttp://answers.opencv.org/question/15936/eliminate-scaling-from-perspective-transform/I would like to project an image to a textured wall. Using various techniques I was able to detect the wall plane, and now I just want to draw the image on that plane.
The plane itself is a quadrangle, and I was able to get a perspective transform matrix between the image and the wall plane, and use that transform to perform the projection. My only problem is that the image is scaled up to occupy the entire quadrangle of the wall plane. I would only like it to follow its perspective, without the changes in scale. Can I somehow eliminate the scaling from the transformation matrix, or is there any other method that would help?
Thank you!Sun, 30 Jun 2013 09:40:03 -0500http://answers.opencv.org/question/15936/eliminate-scaling-from-perspective-transform/Answer by SR for <p>I would like to project an image to a textured wall. Using various techniques I was able to detect the wall plane, and now I just want to draw the image on that plane. </p>
<p>The plane itself is a quadrangle, and I was able to get a perspective transform matrix between the image and the wall plane, and use that transform to perform the projection. My only problem is that the image is scaled up to occupy the entire quadrangle of the wall plane. I would only like it to follow its perspective, without the changes in scale. Can I somehow eliminate the scaling from the transformation matrix, or is there any other method that would help?</p>
<p>Thank you!</p>
http://answers.opencv.org/question/15936/eliminate-scaling-from-perspective-transform/?answer=15942#post-id-15942If your perspective mapping matrix is `P` you can apply this transformation followed by scaling and translation: Simply apply the scaling matrix `S` and the translation matrix `T` to the quadrangle corners:
`P' = T * S * P` (matrix multiplications)Sun, 30 Jun 2013 15:50:52 -0500http://answers.opencv.org/question/15936/eliminate-scaling-from-perspective-transform/?answer=15942#post-id-15942Comment by Rares Musina for <p>If your perspective mapping matrix is <code>P</code> you can apply this transformation followed by scaling and translation: Simply apply the scaling matrix <code>S</code> and the translation matrix <code>T</code> to the quadrangle corners:</p>
<p><code>P' = T * S * P</code> (matrix multiplications)</p>
http://answers.opencv.org/question/15936/eliminate-scaling-from-perspective-transform/?comment=15948#post-id-15948Thanks for the response! Do you happen to know how to split the transformation matrix into scaling and translation matrices? I was thinking of applying the transposed scaling matrix to my transformed quadrangle, in order to scale it back to its original size. Sun, 30 Jun 2013 18:37:27 -0500http://answers.opencv.org/question/15936/eliminate-scaling-from-perspective-transform/?comment=15948#post-id-15948