Ask Your Question

perspectiveTransform() fails

asked 2018-06-19 05:14:49 -0600

I'm trying to retrieve the position of my matched object, I'm using this tutorial

So far my code is

Instead FlannBasedMatcher which is given in the tutorial I use BFMatcher with NORM_L2.

Problem is when I go to perspectiveTransform it gives an error like below.

image description

I have no idea what makes the cv::Exception? Please help

edit retag flag offensive close merge delete



would you be so nice, and swap the screenshot with a text version of the error ?

berak gravatar imageberak ( 2018-06-19 05:48:02 -0600 )edit

will do. Tomorrow, currently away from the pc

MenukaIshan gravatar imageMenukaIshan ( 2018-06-19 06:01:49 -0600 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2018-06-19 05:43:02 -0600

berak gravatar image

updated 2018-06-19 05:47:03 -0600

your Homography Mat is empty() !

yes, that can happen, if you did not have enough "good" points for findHomography(), it returns an empty Mat.

you have to add a check here:

Mat H = findHomography( obj, scene, RANSAC );
if (H.empty()) {
    cerr << "bad homography." << endl;
    return 1;
edit flag offensive delete link more


It seems this is the problem :(

MenukaIshan gravatar imageMenukaIshan ( 2018-06-21 22:11:10 -0600 )edit

Question Tools

1 follower


Asked: 2018-06-19 05:14:49 -0600

Seen: 402 times

Last updated: Jun 19 '18