Ask Your Question
0

perspectiveTransform() fails

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

I'm trying to retrieve the position of my matched object, I'm using this tutorial https://docs.opencv.org/3.4.1/d7/dff/...

So far my code is https://gist.github.com/Menuka5/de971...

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

Comments

1

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 -0500 )edit
1

will do. Tomorrow, currently away from the pc

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

1 answer

Sort by ยป oldest newest most voted
2

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

berak gravatar image

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

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

Comments

It seems this is the problem :(

MenukaIshan gravatar imageMenukaIshan ( 2018-06-21 22:11:10 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

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

Seen: 49 times

Last updated: Jun 19 '18