Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There is the code computes the affine transformation matrix using the library Opencv (it shows how to trasform your trapezoid to rectangle and how to find transformation matrix for futher calculations):</p> <pre><code>//example from book // Learning OpenCV: Computer Vision with the OpenCV Library // by Gary Bradski and Adrian Kaehler // Published by O'Reilly Media, October 3, 2008 #include &lt;cv.h&gt; #include &lt;highgui.h&gt; #include &lt;stdlib.h&gt; #include &lt;stdio.h&gt; int main(int argc, char* argv[]) { IplImage *src=0, *dst=0; // absolute or relative path to image should be in argv[1] char* filename = argc == 2 ? argv[1] : "Image0.jpg"; // get the picture src = cvLoadImage(filename,1); printf("[i] image: %s\n", filename); assert( src != 0 ); // points (corners of ) CvPoint2D32f srcQuad[4], dstQuad[4]; // transformation matrix CvMat* warp_matrix = cvCreateMat(3,3,CV_32FC1); // clone image dst = cvCloneImage(src); // define all the points //here the coordinates of corners of your trapezoid srcQuad[0].x = ??; //src Top left srcQuad[0].y = ??; srcQuad[1].x = ??; //src Top right srcQuad[1].y = ??; srcQuad[2].x = ??; //src Bottom left srcQuad[2].y = ??; srcQuad[3].x = ??; //src Bot right srcQuad[3].y = ??; //- - - - - - - - - - - - - -// //coordinates of rectangle in src image dstQuad[0].x = 0; //dst Top left dstQuad[0].y = 0; dstQuad[1].x = src-&gt;width-1; //dst Top right dstQuad[1].y = 0; dstQuad[2].x = 0; //dst Bottom left dstQuad[2].y = src-&gt;height-1; dstQuad[3].x = src-&gt;width-1; //dst Bot right dstQuad[3].y = src-&gt;height-1; // get transformation matrix that you can use to calculate //coordinates of point Pxy cvGetPerspectiveTransform(srcQuad,dstQuad,warp_matrix); // perspective transformation cvWarpPerspective(src,dst,warp_matrix); cvNamedWindow( "cvWarpPerspective", 1 ); cvShowImage( "cvWarpPerspective", dst ); cvWaitKey(0); cvReleaseMat(&amp;warp_matrix); cvReleaseImage(&amp;src); cvReleaseImage(&amp;dst); cvDestroyAllWindows(); return 0; </code></pre> <p>Hope it will be helpfull!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload