def getFeat(Data,mode): # get and save feature valuve
num = 0
for data in Data:
image = np.reshape(data[0], (200, 200, 3))
gray = rgb2gray(image)/255.0 # trans image to gray
fd = hog(gray, orientations, pixels_per_cell, cells_per_block, block_norm, visualize, normalize)
fd = np.concatenate((fd, data[1])) # add label in the end of the array
filename = list(data[2])
fd_name = filename[0].split('.')[0]+'.feat' # set file name
if mode == 'train':
fd_path = os.path.join('./features/train/', fd_name)
else:
fd_path = os.path.join('./features/test/', fd_name)
joblib.dump(fd, fd_path,compress=3) # save data to local
num += 1
print "%d saving: %s." %(num,fd_name)
1_HoG_extract_feature.py 文件源码
python
阅读 25
收藏 0
点赞 0
评论 0
评论列表
文章目录