Ask Your Question

Revision history [back]

how to pass keypoints for orb.computeAsync

Im trying to compute descriptors for the keypoints found, but Im getting segmentation fault error. Part of the problem is that there is very little documentation for opencv cuda in python. I am getting an image data, and using cv2.cuda.createGoodFeaturesToTrack() for getting keypoints. I want to calculate descriptors for the keypoints, and hence using computeAsync(). Here is my code - def extract(img): #orb = cv2.cuda_ORB.create() orb = cv2.ORB_create() #converting to grey cuC1 = cv2.cuda_GpuMat() cuC1.upload(img) cuC1 = cv2.cuda.cvtColor(cuC1, cv2.COLOR_RGB2GRAY)

#detection
pts = cv2.cuda.createGoodFeaturesToTrackDetector(cv2.CV_8UC1)
_kps = pts.detect(cuC1)

npKps = _kps.download()
npKps = np.int0(npKps)
for n in npKps:
    #extraction
    kps = [cv2.KeyPoint(x=f.ravel()[0], y=f.ravel()[1], _size=20) for f in n]  #cpu keypoints, works well with non cuda orb
kps, des = orb.computeAsync(cuC1, _kps)
#return points and descriptors

how to pass keypoints for orb.computeAsync

Im trying to compute descriptors for the keypoints found, but Im getting segmentation fault error. Part of the problem is that there is very little documentation for opencv cuda in python. I am getting an image data, and using cv2.cuda.createGoodFeaturesToTrack() for getting keypoints. I want to calculate descriptors for the keypoints, and hence using computeAsync(). Here is my code - -

def extract(img):
    #orb = cv2.cuda_ORB.create()
    orb = cv2.ORB_create()
    #converting to grey
    cuC1 = cv2.cuda_GpuMat()
    cuC1.upload(img)
    cuC1 = cv2.cuda.cvtColor(cuC1, cv2.COLOR_RGB2GRAY)

cv2.COLOR_RGB2GRAY)
    #detection
 pts = cv2.cuda.createGoodFeaturesToTrackDetector(cv2.CV_8UC1)
 _kps = pts.detect(cuC1)
  npKps = _kps.download()
 npKps = np.int0(npKps)
 for n in npKps:
     #extraction
     kps = [cv2.KeyPoint(x=f.ravel()[0], y=f.ravel()[1], _size=20) for f in n]  #cpu keypoints, works well with non cuda orb
 kps, des = orb.computeAsync(cuC1, _kps)
 #return points and descriptors