Ask Your Question
0

Can we use surf detectAndCompute function for multiple images -OpenCV - Python

asked 2018-11-20 13:41:51 -0600

Cola gravatar image

I want to match images using multiple train images.

This what I'm expecting to do

import cv2 import matplotlib.pyplot as plt import numpy as np

surf=cv2.xfeatures2d.SURF_create(400) img=[] //train images img.append(cv2.imread('test_images/frame964.jpg',0)) img.append(cv2.imread('test_images/frame112.jpg',0))

//test image test_img = cv2.imread('test_images/frame300.jpg',0)

//problematic in here kp1,des1=surf.detectAndCompute(img,None)

kp2,des2=surf.detectAndCompute(test_img,None)

bf = cv2.BFMatcher(cv2.NORM_L1, crossCheck=False)

matches = bf.match(des1,des2) matches = sorted(matches, key = lambda x:x.distance) img3 = cv2.drawMatches(roi,kp1,frame,kp2,matches[:10], None,flags=2)

cv2.imwrite("outputimage.jpg",img3)

This is not working in python. It gives an error in here

kp1,des1=surf.detectAndCompute(img,None)

Error is : kp1,des1=surf.detectAndCompute(img,None) TypeError: image is not a numpy array, neither a scalar

I saw a C code by making vector images and match them. Is there any possibility of doing this in python. Is there any approach for this ?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-11-21 04:53:08 -0600

berak gravatar image

updated 2018-11-21 05:07:23 -0600

no, you can use only a single image at a time here (not a list)

I saw a C code by making vector images and match them

you can match a vector of descriptors, but to acquire those, you have to call detectAndCompute per image

have another look at the tutorials

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-11-20 13:41:51 -0600

Seen: 822 times

Last updated: Nov 21 '18