Ask Your Question
0

BOWKMeansTrainer cluster Python issue

asked 2015-11-14 22:42:47 -0600

briansrls gravatar image

Hello all,

I'm trying to use cluster from the BOWKMeansTrainer class on python. Here's a snippet of code to give you an idea

sift = cv2.SIFT() print names_path

descriptors_unclustered = []

for p in training_paths:
    image = cv2.imread(p)
    gray = cv2.cvtColor(image, cv2.CV_LOAD_IMAGE_GRAYSCALE)
    kp, dsc= sift.detectAndCompute(gray, None)
    descriptors_unclustered.append(dsc)
     dictionarySize = 5

desc = np.empty(len(descriptors_unclustered), dtype=object) for i in range(len(descriptors_unclustered)):
    desc[i] = descriptors_unclustered[i]

print desc BOW = cv2.BOWKMeansTrainer(dictionarySize)

dictionary = BOW.cluster(desc)

print dictionary

I'm getting the error

TypeError: descriptors data type = 17 is not supported

When passing my numpy array to clusters(). Any idea what causes this, or what data type it's supposed to accept?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2015-11-14 23:21:46 -0600

berak gravatar image

updated 2015-11-14 23:23:17 -0600

try adding your descriptors directly to your BOW:

gray = cv2.cvtColor(image, cv2.CV_LOAD_IMAGE_GRAYSCALE)
kp, dsc= sift.detectAndCompute(gray, None)
BOW.add(dsc)

## later:
dictionary = BOW.cluster()
edit flag offensive delete link more

Comments

1

I love you! take my updoots

briansrls gravatar imagebriansrls ( 2015-11-14 23:53:38 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-11-14 22:42:47 -0600

Seen: 1,617 times

Last updated: Nov 14 '15