Created
March 6, 2017 23:10
-
-
Save musaprg/f203baa735e9560aa7d884c7b3b4a5db to your computer and use it in GitHub Desktop.
一括読み込み
This file contains hidden or 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
import os, sys | |
import imghdr | |
import cv2 #PILでも良いと思います | |
import logging | |
logger = logging.getLogger(__name__) | |
#わたされたパスがディレクトリかどうかチェック | |
if os.path.isdir(inpath): | |
imgs = [] | |
files = os.listdir(inpath) | |
for file in files | |
if not imghdr.what(file): | |
logger.error('InvalidFile: "%s" is not valid image file.' % file) | |
continue | |
img = imread(file, "r") #画像ファイルなら読み込み | |
if img is not None: | |
#読み込んだ画像データを配列に格納していぬ | |
imgs.append(img) | |
else: | |
logger.error('CVError: imread() failed while reading "%s"' % file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment