0

I have a set of images split in train and test and I'm trying to detect features using SIFT from the train set. The problem is that with my code I'm getting:

TypeError: image is not a numpy array, neither a scalar

Here's my code:

import glob
from cv2 import SIFT
import numpy as np

#creating a list of images
images = []
for infile in glob.glob('path'):
    images.append(infile)

np.random.shuffle(images)
my_set = images
#splitting my set in test and train parts

train = my_set[:120]
test = my_set[120:]

#get descriptors of train part
for image in train:
    SIFT().detect(image)

I've tried to change the variables train and test like this:

train = np.array(my_set[:120])

but I get the same error.

giulia_dnt
  • 197
  • 1
  • 4
  • 12
  • your 'image' is only a name. you will have to load the real one with cv2.imread(name) – berak Dec 08 '14 at 09:20
  • Thanks! I've changed the code by putting the cv2.imread function inside the first loop. Now I don't get any error. I hope my approach is correct. – giulia_dnt Dec 08 '14 at 12:05
  • if that is really all of your code - then not. SIFT().detect() *returns keypoints*, which you would use to compute features. then you'd compare those with a matcher or some ml. – berak Dec 08 '14 at 13:01
  • I've changed that as well with the function detectAndCompute that should return both keypoints and descriptors. My task is broader than feature detection, as it's about content base image retrieval. This is just the first part, where I'm trying to get the codebook. – giulia_dnt Dec 08 '14 at 13:20
  • k,k. just saying - you're not done yet. – berak Dec 08 '14 at 13:25

0 Answers0