1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| void processing::perspective(Mat& image1)
{
// Recalage
const char* wndname = "Test";
namedWindow(wndname,CV_WINDOW_NORMAL );
imshow(wndname, image1);
CvPoint2D32f *c1 = new CvPoint2D32f[4];
CvPoint2D32f *c2 = new CvPoint2D32f[4];
c1[0].x = p3.x; c1[0].y = p3.y;
c1[1].x = p2.x; c1[1].y = p2.y;
c1[2].x = p0.x; c1[2].y = p0.y;
c1[3].x = p1.x; c1[3].y = p1.y;
c2[0].x = p3.x; c2[0].y = p3.y;
c2[1].x = p2.x; c2[1].y = p2.y;
c2[2].x = p0.x; c2[2].y = p0.y;
c2[3].x = p1.x; c2[3].y = p1.y;
CvMat *H=cvCreateMat(3,3,CV_32FC1);
cvGetPerspectiveTransform(c2,c1,H);
//IplImage* dst;
// IplImage src = (IplImage)image1;
// IplImage* dst=cvCreateImage(cvGetSize(&src),8, 1);
IplImage src = (IplImage) image1;
IplImage* dst = cvCreateImage(cvGetSize(&src),8,0);
cvWarpPerspective(&src,dst, H, 0, cvScalarAll(0));
cvShowImage("test",dst);
cvReleaseMat(&H);
} |
Partager