Hello, thanks for your reply, what I want is to extract the characteristics of different images and do the matching (it is a visual odometry algorithm), I want to know how to do this algorithm with different images, not only with 2 (it is easy with 2) , the problem is when I want to do it with different images, suppose I have 10 images (a sequence of the KITTI dataset), I need to search the characteristics of image 1, with 2, then 2 with 3, 3 with 4 and so on, below I put an example with 2 images that works, but I don’t know how to do it for several images
from distutils.command.upload import upload
import cv2
import numpy as np
MAX_FEATURES = 500
GOOD_MATCH_PERCENT = 0.15
# load images into numpy
npMat1 = cv2.imread("C:\\Users\\Geddy\\OneDrive\\Desktop\\0.png")
npMat2 = cv2.imread("C:\\Users\\Geddy\\OneDrive\\Desktop\\1.png")
# upload into Cuda
cuMat1 = cv2.cuda_GpuMat()
cuMat2 = cv2.cuda_GpuMat()
cuMat1.upload(npMat1)
cuMat2.upload(npMat2)
#convert to Gray
cuMat1g = cv2.cuda.cvtColor(cuMat1, cv2.COLOR_RGB2GRAY)
cuMat2g = cv2.cuda.cvtColor(cuMat2, cv2.COLOR_RGB2GRAY)
#ORB
corb = cv2.cuda_ORB.create(MAX_FEATURES)
_kps1, _descs1 = corb.detectAndComputeAsync(cuMat1g, None)
_kps2, _descs2 = corb.detectAndComputeAsync(cuMat2g, None)
#convert Keypoints to CPU
kps1 = [cv2.KeyPoint() for i in range(MAX_FEATURES)]
kps2 = [cv2.KeyPoint() for i in range(MAX_FEATURES)]
corb.convert(_kps1)
corb.convert(_kps2)
# Matching
cbf = cv2.cuda_DescriptorMatcher.createBFMatcher(cv2.NORM_HAMMING)
cmatches = cbf.match(_descs1, _descs2)
# Sort matches by score
cmatches=sorted(cmatches, key=lambda x: x.distance, reverse=False)
# Remove not so good matches
numGoodMatches = int(len(cmatches) * GOOD_MATCH_PERCENT)
cmatches = cmatches[:numGoodMatches]
# Draw top matches
imMatches = cv2.drawMatches(npMat1, kps1, npMat2, kps2, cmatches, None)
cv2.imwrite("gpu_matches.jpg", imMatches)