def all_descriptors(dataset, class_list, option = constants.ORB_FEAT_OPTION):
"""
Gets every local descriptor of a set with different classes (This is useful for getting a codebook).
Args:
class_list (list of arrays of strings): The list has information for a specific class in each element and each
element is an array of strings which are the paths for the image of that class.
option (integer): It's 49 (the key '1') if ORB features are going to be used, else use SIFT features.
Returns:
numpy float matrix: Each row are the descriptors found in an image of the set
"""
des = None
for i in range(len(class_list)):
message = "*** Getting descriptors for class number {0} of {1} ***".format(i, len(class_list))
print(message)
class_img_paths = class_list[i]
new_des = descriptors_from_class(dataset, class_img_paths, i, option)
if des is None:
des = new_des
else:
des = np.vstack((des, new_des))
message = "*****************************\n"\
"Finished getting all the descriptors\n"
print(message)
print("Total number of descriptors: {0}".format(len(des)))
if len(des) > 0:
print("Dimension of descriptors: {0}".format(len(des[0])))
print("First descriptor:\n{0}".format(des[0]))
return des
评论列表
文章目录