Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Perspective transform raises error #11

Closed
ChargedMonk opened this issue May 18, 2020 · 4 comments
Closed

Perspective transform raises error #11

ChargedMonk opened this issue May 18, 2020 · 4 comments

Comments

@ChargedMonk
Copy link

I got the following error while matching two images.

OpenCV(4.1.2) /io/opencv/modules/core/src/matmul.dispatch.cpp:531: error: (-215:Assertion failed) scn + 1 == m.cols in function 'perspectiveTransform'

@rmislam
Copy link
Owner

rmislam commented May 25, 2020

Hi @ChargedMonk, can you please attach your two images here so I can debug?

@ChargedMonk
Copy link
Author

Here are the two images -

Image 1

Image 2

@rmislam
Copy link
Owner

rmislam commented Jun 13, 2020

@ChargedMonk I can't exactly reproduce your error, but I have an idea of what is happening. Probably very few keypoints are generated for your images. When I run the matching script with your images on my computer, I only generate 9 keypoints, which is enough to generate a homography. However, possibly on your machine, there are fewer than 4 keypoints generated.

When you run template_matching_demo.py on your machine, what is the length of the list variable good? This is the number of keypoint matches. If there are too few points, I can suggest some threshold changes in the demo script for you.

@rmislam
Copy link
Owner

rmislam commented Jun 14, 2020

I also realize you must have reduced the value of MIN_MATCH_COUNT at the top of the script. I've set this to 10 specifically to avoid this problem. You need at least 4 keypoints to generate a unique homography, and typically around 10 keypoints for the homography to be stable. If you can't generate enough keypoints, I suggest you try higher resolution images.

I'm going to close this issue because it's not an issue with the actual code -- it's just that not enough keypoints are generated for your particular images.

@rmislam rmislam closed this as completed Jun 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants