1 Star 0 Fork 0

hankutech_feilong_chen / mobilenet-ssd-snpe

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
image_to_raw.py 1.07 KB
一键复制 编辑 原始数据 按行查看 历史
sky 提交于 2021-11-19 16:47 . add facedetect demo
import cv2
import numpy as np
import os
import random
VOC_path = './data/VOC2007'
VOC_raw_path = './data/VOC_raw'
VOC_resize_path = './data/VOC_resize'
raw_list_file = './data/VOC_raw_list.txt'
raw_file_names = ''
if not os.path.exists(VOC_raw_path):
os.makedirs(VOC_raw_path)
if not os.path.exists(VOC_resize_path):
os.makedirs(VOC_resize_path)
imgs = os.listdir(VOC_path)
for i, file_name in enumerate(imgs):
img = cv2.imread(os.path.join(VOC_path, file_name))
resized_img = cv2.resize(img, (320, 240), cv2.INTER_LINEAR)
resize_file_name = os.path.join(VOC_resize_path, str(i) + '.jpg')
cv2.imwrite(resize_file_name, resized_img)
mean,std = cv2.meanStdDev(img)
mean = mean.reshape(1,3)
std = std.reshape(1,3)
resized_img = (resized_img-mean)/(0.000001 + std)
resized_img_data = np.array(resized_img, np.float32)
raw_file_name = os.path.join(VOC_raw_path, str(i) + '.raw')
resized_img_data.tofile(raw_file_name)
raw_file_names += (raw_file_name + '\n')
with open(raw_list_file, 'w') as f:
f.write(raw_file_names)
f.close()
C++
1
https://gitee.com/hankutech_feilong_chen/mobilenet-ssd-snpe.git
git@gitee.com:hankutech_feilong_chen/mobilenet-ssd-snpe.git
hankutech_feilong_chen
mobilenet-ssd-snpe
mobilenet-ssd-snpe
master

搜索帮助