I am getting this error
`error: (-215:Assertion failed) query.type() == type && indices.type() == CV_32S && dists.type() == dtype in function 'runKnnSearch_'`
I am using Python 3.8, opencv-python==4.7.0
My task is to check if an icon is in a screenshot or not. If it is there return its location. I’ve found that opencv can get this job done.
My approach is:
- Get the keypoints and descriptors using ORB and SIFT, and return which has more keypoints.
kp_orb = orb.detect(image,None)
kp_orb, des_orb = orb.compute(image, kp_orb)
kp_sift, des_sift = sift.detectAndCompute(image,None)
if (len(kp_orb) > len(kp_sift)):
return (kp_orb,des_orb, "ORB")
return (kp_sift, des_sift, "SIFT")
- Using FLANN_KDTREE to get the matching keypoints, I got the error provided above
Here is my FLANN code block
FLANN_INDEX_KDTREE = 1
index_params = dict(algorithm = FLANN_INDEX_KDTREE, trees = 5)
search_params = dict(checks=100)
flann = cv.FlannBasedMatcher(index_params,search_params)
matches = flann.knnMatch(des_query,des_target,k=2)
I think this gets the error because SIFT returns descriptors in a type different from what ORB returns, but I am not sure of that because I am a total beginner in this field.
Would you please tell me how to fix this error or if there is a better overall approach please provide an outline and I will make my way through.
Thank you.