Guest User

Untitled

a guest
Aug 18th, 2019
58
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. grayImg = cv2.imread('../my-images/' + row[1], 0)
  2. keypoints, descriptors = sift.detectAndCompute(grayImg, None)
  3. descriptors = np.insert(descriptors, 0, 128, 1)
  4. vectorArray = np.concatenate((vectorArray, descriptors), axis = 0)
  5.  
  6. vectorArray.astype(np.int32).tofile('./my_sift_descriptors.fvecs')
  7.  
  8. #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
  9. #the following code is correct:
  10.  
  11. #assuming you calculated descriptors with SIFT and have opened an output file with 'wb' flag
  12. for descriptor in descriptors:
  13. dimension_array = array('i', [128])
  14. dimension_array.tofile(output_file)
  15. float_array = array('f', descriptor)
  16. float_array.tofile(output_file)
RAW Paste Data