''' Call external C program to extract feature. @author: chunk chunkplus@gmail.com 2014 Dec ''' import sys, os import subprocess root = "/home/chunk/workspace/dip/chunk/hog/" path = os.path.join(root, "data/train") imgpath = '' hogpath = '' for dirs in os.listdir(path): for _r, _d, _f in os.walk(os.path.join(path, dirs)): for f in _f: imgpath = os.path.join(path, dirs, f) hogpath = os.path.join(root, "hog", dirs) if not os.path.exists(hogpath): os.makedirs(hogpath) hogpath = os.path.join(hogpath,f.replace("jpg", "hog")) print hogpath cmd = ["/home/chunk/workspace/dip/chunk/hog/extract/extract_hog", imgpath, hogpath] # process = subprocess.Popen(cmd, stderr=subprocess.STDOUT, stdout=subprocess.PIPE) subprocess.call(cmd,stderr=subprocess.STDOUT, stdout=subprocess.PIPE)