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

_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.

Still no success.

edit retag flag offensive close merge delete


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

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 )

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.

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