descriptors.py 文件源码

python
阅读 38 收藏 0 点赞 0 评论 0

项目:object-classification 作者: HenrYxZ 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号