Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- grayImg = cv2.imread('../my-images/' + row[1], 0)
- keypoints, descriptors = sift.detectAndCompute(grayImg, None)
- descriptors = np.insert(descriptors, 0, 128, 1)
- vectorArray = np.concatenate((vectorArray, descriptors), axis = 0)
- vectorArray.astype(np.int32).tofile('./my_sift_descriptors.fvecs')
- #the above code is faulty and should first insert an int32 of with the dimension as value and subsequently float32 values of the vector itself
- #the following code is correct:
- #assuming you calculated descriptors with SIFT and have opened an output file with 'wb' flag
- for descriptor in descriptors:
- dimension_array = array('i', [128])
- dimension_array.tofile(output_file)
- float_array = array('f', descriptor)
- float_array.tofile(output_file)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement