Ask Your Question

Sparrow's profile - activity

2015-02-15 11:35:10 -0600 commented answer Problem with perspective

thank you it works

2015-02-15 08:19:55 -0600 commented question Problem with perspective

I'm stupid Thank you very much I'll open in debug mode

2015-02-15 08:02:53 -0600 commented answer Problem with perspective

Sorry but I tried and it doesn't work on my computer

What are the includes ? Should I use "using namespace cv" ?

2015-02-15 07:44:09 -0600 received badge  Scholar (source)
2015-02-15 07:31:45 -0600 received badge  Supporter (source)
2015-02-15 07:20:43 -0600 commented answer Problem with perspective

That the result I wanted

I'm goign to learn differences between C and C++ in order to understand the code

Thank you very much

Sparrow

2015-02-15 06:59:19 -0600 commented question Problem with perspective

Sorry I didn't konw. It mays explain why I don't find many topic on opencv with C

2015-02-15 06:50:40 -0600 asked a question Problem with perspective

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 : image description The goal is to have a "top view" of the court

Thank you for your help

Sparrow