Ask Your Question

Revision history [back]

You add below lines:

int distanceOfPoints(cv::Point point1, cv::Point point2) { int result = (int) sqrt(pow(point1.x - point2.x, 2.0) + pow(point1.y - point2.y, 2.0)); return result; } int* hw(cv::Point p1,cv::Point p2,cv::Point p3,cv::Point p4) { int a[2]; if(distanceOfPoints(p1,p2)<distanceofpoints(p3,p4)) a[0]="distanceOfPoints(p3,p4);" else="" a[0]="distanceOfPoints(p1,p2);" if(distanceofpoints(p2,p3)<distanceofpoints(p4,p1))="" a[1]="distanceOfPoints(p4,p1);" else="" a[1]="distanceOfPoints(p2,p3);&lt;/p">

return a;

}

int main(){ ...............

cv::Point P1 = contours_poly[0][0]; cv::Point P2 = contours_poly[0][1]; cv::Point P3 = contours_poly[0][2]; cv::Point P4 = contours_poly[0][3]; cv::Mat transformed = cv::Mat::zeros(hw(P1,P2,P3,P4)[1], hw(P1,P2,P3,P4)[0], CV_8UC3);

cv::Mat transmtx = getPerspectiveTransform(quad_pts, squre_pts); warpPerspective(src, transformed, transmtx, transformed.size()); ................ }

You add below lines:

int distanceOfPoints(cv::Point point1, cv::Point point2) { int result = (int) sqrt(pow(point1.x - point2.x, 2.0) + pow(point1.y - point2.y, 2.0)); return result; } }

int* hw(cv::Point p1,cv::Point p2,cv::Point p3,cv::Point p4) { int a[2]; a[2];

if(distanceOfPoints(p1,p2)<distanceOfPoints(p3,p4))
 if(distanceOfPoints(p1,p2)<distanceofpoints(p3,p4)) a[0]="distanceOfPoints(p3,p4);" else="" a[0]="distanceOfPoints(p1,p2);" if(distanceofpoints(p2,p3)<distanceofpoints(p4,p1))="" a[1]="distanceOfPoints(p4,p1);" else="" a[1]="distanceOfPoints(p2,p3);&lt;/p">
a[0]=distanceOfPoints(p3,p4);
 

else
    a[0]=distanceOfPoints(p1,p2);

if(distanceOfPoints(p2,p3)<distanceOfPoints(p4,p1))
    a[1]=distanceOfPoints(p4,p1);

else
    a[1]=distanceOfPoints(p2,p3);

return a;

}

int main(){ ...............

cv::Point P1 = contours_poly[0][0]; cv::Point P2 = contours_poly[0][1]; cv::Point P3 = contours_poly[0][2]; cv::Point P4 = contours_poly[0][3]; cv::Mat transformed = cv::Mat::zeros(hw(P1,P2,P3,P4)[1], hw(P1,P2,P3,P4)[0], CV_8UC3);

cv::Mat transmtx = getPerspectiveTransform(quad_pts, squre_pts); warpPerspective(src, transformed, transmtx, transformed.size()); ................ }

You add below lines:

int distanceOfPoints(cv::Point point1, cv::Point point2) { {

int result = (int) sqrt(pow(point1.x - point2.x, 2.0) + pow(point1.y - point2.y, 2.0)); 2.0));

return result; result;

}

int* hw(cv::Point p1,cv::Point p2,cv::Point p3,cv::Point p4) p4)

{ int a[2];

if(distanceOfPoints(p1,p2)<distanceOfPoints(p3,p4))
    a[0]=distanceOfPoints(p3,p4);

else
    a[0]=distanceOfPoints(p1,p2);

if(distanceOfPoints(p2,p3)<distanceOfPoints(p4,p1))
    a[1]=distanceOfPoints(p4,p1);

else
    a[1]=distanceOfPoints(p2,p3);

return a;

}

int main(){ ...............

cv::Point P1 = contours_poly[0][0]; cv::Point P2 = contours_poly[0][1]; cv::Point P3 = contours_poly[0][2]; cv::Point P4 = contours_poly[0][3]; cv::Mat transformed = cv::Mat::zeros(hw(P1,P2,P3,P4)[1], hw(P1,P2,P3,P4)[0], CV_8UC3);

cv::Mat transmtx = getPerspectiveTransform(quad_pts, squre_pts); warpPerspective(src, transformed, transmtx, transformed.size()); ................ }

You add below lines:

int distanceOfPoints(cv::Point point1, cv::Point point2)
{

{

int result = (int) sqrt(pow(point1.x - point2.x, 2.0) + pow(point1.y - point2.y, 2.0));

2.0)); return result;

return result;

}

}

int* hw(cv::Point p1,cv::Point p2,cv::Point p3,cv::Point p4)

p4)

{ int a[2];

a[2];
 if(distanceOfPoints(p1,p2)<distanceOfPoints(p3,p4))
     a[0]=distanceOfPoints(p3,p4);

 else
     a[0]=distanceOfPoints(p1,p2);

 if(distanceOfPoints(p2,p3)<distanceOfPoints(p4,p1))
     a[1]=distanceOfPoints(p4,p1);

 else
     a[1]=distanceOfPoints(p2,p3);

 return a;
}

}

int main(){ ...............

...............

cv::Point P1 = contours_poly[0][0]; cv::Point P2 = contours_poly[0][1]; cv::Point P3 = contours_poly[0][2]; cv::Point P4 = contours_poly[0][3]; cv::Mat transformed = cv::Mat::zeros(hw(P1,P2,P3,P4)[1], hw(P1,P2,P3,P4)[0], CV_8UC3);

CV_8UC3);

cv::Mat transmtx = getPerspectiveTransform(quad_pts, squre_pts); warpPerspective(src, transformed, transmtx, transformed.size()); ................ }

}