shackenberg / Minimal-Bag-of-Visual-Words-Image-Classifier

Implementation of a content based image classifier using the bag of visual words approach in Python together with Lowe's SIFT and Libsvm.
236 stars 94 forks source link

dict2numpy #19

Open buzzo123 opened 7 years ago

buzzo123 commented 7 years ago

hi, can i ask a question?

i want to implement a bag of words classifier in c# but i dont undestand this function:

def dict2numpy(dict):
    nkeys = len(dict)
    array = zeros((nkeys * PRE_ALLOCATION_BUFFER, 128))
    pivot = 0
    for key in dict.keys():
        value = dict[key]
        nelements = value.shape[0]
        while pivot + nelements > array.shape[0]:
            padding = zeros_like(array)
            array = vstack((array, padding))
        array[pivot:pivot + nelements] = value
        pivot += nelements
    array = resize(array, (pivot, 128))
    return array

can you explain me please? thanks a lot