Created
February 15, 2017 09:04
-
-
Save ytbilly3636/7aeb970a44260d96653971368f3b7eee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
import numpy as np | |
import cv2, os, time | |
# 複数の画像を読み込む関数 | |
def imgsread(path): | |
# ディレクトリ中のファイル名のリストを取得 | |
filelists = os.listdir(path) | |
print 'number of files: ', len(filelists) | |
# 読み込んだ画像をリストに追加 | |
imgs = [] | |
for f in filelists: | |
img = cv2.imread(f) | |
imgs.append(img) | |
# リストをnumpyに変換 | |
return np.asarray(imgs) | |
# 画像の読み込み時間の計測 | |
s1 = time.time() | |
array1 = imgsread('hoge/hoge/foo/bar') | |
print 'imgsread()', time.time() - s1 | |
# 画像をnpy形式で保存 | |
np.save('array.npy', array) | |
# npyファイルの読み込み時間の計測 | |
s2 = time.time() | |
array2 = np.load('array.npy') | |
print 'np.load()', time.time() - s2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment