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

Question about m_kp1 and m_kp2 not being generated #310

Open
wangyan0913 opened this issue Nov 29, 2023 · 5 comments
Open

Question about m_kp1 and m_kp2 not being generated #310

wangyan0913 opened this issue Nov 29, 2023 · 5 comments

Comments

@wangyan0913
Copy link

Hello, thank you very much for your guidance, your work has helped me a lot in my studies. When using pre-trained weights for image matching, the elements in out2[0] are all 0-valued, resulting in kp2 not being generated, why is this?

Traceback (most recent call last):
File "SuperPoint-master/SuperPoint-master/superpoint/match_features_demo.py", line 186, in
H, inliers = compute_homography(m_kp1, m_kp2)
File "SuperPoint-master/SuperPoint-master/superpoint/match_features_demo.py", line 65, in compute_homography
cv2.RANSAC)
cv2.error: OpenCV(3.4.2) /io/opencv/modules/calib3d/src/fundam.cpp:372: error: (-5:Bad argument) The input arrays should be 2D or 3D point sets in function 'findHomography'

@rpautrat
Copy link
Owner

Hi, maybe there are simply no keypoint detected. Did you visualize the images and the predictions of the network?

@wangyan0913
Copy link
Author

嗨,也许根本没有检测到关键点。您是否可视化了网络的图像和预测?
Hello, thank you very much for your reply, I follow the absolute path and input two images, and input two identical images, img1 can successfully generate kp1,but img2's kp2 is still null...
There is no error in the path, and the process is exactly the same for both images, I still can't find out the reason why kp2 is null, it's been bothering me for a long time, I hope I can get your help, I really appreciate it!

@rpautrat
Copy link
Owner

rpautrat commented Dec 3, 2023

Did you modify anything from the code online?

@wangyan0913
Copy link
Author

Running the original code gave me the following two errors, so I made changes:
1.
File "SuperPoint-master/superpoint/match_features_demo.py", line 50, in
keypoints = [cv2.KeyPoint(p[1], p[0], 1) for p in keypoints]
cv2.error: OpenCV(4.6.0) 👎 error: (-5:Bad argument) in function 'KeyPoint'

Overload resolution failed:

  • Argument 'x' can not be safely parsed to 'float'

My solution: add it before the error reporting statement: keypoints=keypoints.astype(np.float32)

Traceback (most recent call last):
File "SuperPoint-master/superpoint/match_features_demo.py", line 158, in
m_kp1, m_kp2, matches = match_descriptors(kp1, desc1, kp2, desc2)
File "SuperPoint-master/superpoint/match_features_demo.py",line58,in match_descriptors
matches = bf.match(desc1, desc2)
cv2.error: OpenCV(4.6.0) /io/opencv/modules/core/src/batch_distance.cpp:303: error: (-215:Assertion failed) K == 1 && update == 0 && mask.empty() in function 'batchDistance'

My solution: change "bf = cv2.BFMatcher(cv2.NORM_L2,crossCheck=True)" to "bf = cv2.BFMatcher(cv2.NORM_L2)"

No other changes have been made.

@rpautrat
Copy link
Owner

Hi, these changes should not be a problem in theory. So I don't know why you don't get keypoints on the second image. This is indeed a very weird behavior...

You would need to debug yourself, by inspecting the data at different steps of the inference (e.g. visualize the keypoint probability map output by the network, print the number of keypoints at different stages, etc), to localize the part of the code where the keypoints are discarded (or whether the probability map is itself full of zeros).

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