extract_hog_features.py 文件源码

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

项目:CS231A_Project 作者: afazel 项目源码 文件源码
def neg_hog_rand(path, num_samples, window_size, num_window_per_image):
    rows = window_size[0]
    cols = window_size[1]
    features = []
    cnt = 0
    for dirpath, dirnames, filenames in walk(path):
        for my_file in filenames:

            if cnt < num_samples:
                print cnt,my_file
                cnt = cnt + 1
                im = cv2.imread(path + my_file)
                image = color.rgb2gray(im)
                image_rows = image.shape[0]
                image_cols = image.shape[1]

                for i in range(0,num_window_per_image):
                    x_min = random.randrange(0,image_rows - rows)
                    y_min = random.randrange(0,image_cols - cols)

                    x_max = x_min + rows
                    y_max = y_min + cols

                    image_hog = image[x_min:x_max , y_min:y_max]

                    my_feature, _ = hog(image_hog, orientations=9, pixels_per_cell=(8, 8),cells_per_block=(2, 2), visualise=True)
                    features.append(my_feature)
    return features
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号