Hello evrybody
I'm trying to apply a perspective transform on an image but I doesn't worklike I would like. Since code and pictures are easier to understand than a long speech (and because my english is quite poor) here is the code (in C):
#include <stdio.h>
#include "opencv/highgui.h"
#include "opencv/cv.h"
int main() {
int flags;
CvScalar fillval;
CvPoint2D32f P[3], Q[3];
IplImage *image, *resultat;
CvMat* matrice = cvCreateMat(3,3,CV_32FC1);
cvNamedWindow("Entrée", CV_WINDOW_AUTOSIZE);
cvNamedWindow("Résultat", CV_WINDOW_AUTOSIZE);
image = cvLoadImage("C:\\Users\\Julien\\Pictures\\tennis-3d.jpg", CV_LOAD_IMAGE_COLOR);
resultat=cvCloneImage(image);
cvShowImage( "Entrée", image);
cvShowImage( "Résultat", resultat);
P[0].x=266;
P[0].y=101;
P[1].x=534;
P[1].y=101;
P[2].x=667;
P[2].y=394;
P[3].x=133;
P[3].y=393;
Q[0].x=0;
Q[0].y=0;
Q[1].x=image->width;
Q[1].y=0;
Q[2].x=image->width;
Q[2].y=image->height;
Q[3].x=0;
Q[3].y=image->height;
cvGetPerspectiveTransform(P,Q,matrice);
cvWarpPerspective(image,resultat, matrice,flags=CV_WARP_FILL_OUTLIERS,fillval=cvScalarAll(0) );
cvShowImage( "Résultat", resultat);
cvWaitKey(1000000);
return 0;
}
And the result : The goal is to have a "top view" of the court
Thank you for your help
Sparrow