perspectiveTransform error

asked 2015-08-18 03:07:02 -0500

Nbb gravatar image

updated 2015-08-18 07:34:12 -0500

Hi forum,

Im trying to use perspectiveTransform but I keep getting error. I tried to follow the solution from this thread http://answers.opencv.org/question/18...

_players[i].getCoordinates() is of type Point

_homography_matrix is a 3 x 3 Mat

    Mat temp_Mat = Mat::zeros(2, 1, CV_32FC2);

    for (int i = 0; i < _players.size(); i++)
    {
        cout << Mat(_players[i].get_Coordinates()) << endl;
        perspectiveTransform(Mat(_players[i].get_Coordinates()), temp_Mat, _homography_matrix);
    }

Also, how do I convert temp_Mat into type Point ?

OpenCV Error: Assertion failed (scn + 1 == m.cols) in cv::perspectiveTransform

I have tried checking for the types my Mat using the link below.

stackoverflow.com/questions/10167534/how-to-find-out-what-type-of-a-mat-object-is-with-mattype-in-opencv

Still no success.

edit retag flag offensive close merge delete

Comments

have another look at the docs again.

you need 2 corresponding vector<Point2f> arrays with +4 elements each as input, the output will be a 3x3 homogeneous transformation matrix

berak gravatar imageberak ( 2015-08-18 03:34:09 -0500 )edit
1

Hi berak, the function you linked me to is the "getPerspectiveTransform()" which gives me the 3x3 homography matrix.

I am trying to use the function "perspectiveTransform" which multiplies the homography matrix to a single pixel ( Point ) http://docs.opencv.org/modules/core/d...

Nbb gravatar imageNbb ( 2015-08-18 03:50:54 -0500 )edit

ouch, my bad, misread your post.

berak gravatar imageberak ( 2015-08-18 03:53:14 -0500 )edit

Okay I got the problem solved.

http://docs.opencv.org/doc/tutorials/...

This tutorial made use of perspectiveTransform. I followed it and it worked. Oh man.. I am so bad at this. I have got so much more to learn...

Nbb gravatar imageNbb ( 2015-08-18 11:19:09 -0500 )edit