import sys, os
from lib.feature import HogFeature, HogSizeFeature
import config

if __name__ == "__main__":
	if len(sys.argv) < 1:
		print "USAGE: python dump_data_labels.py"
		sys.exit(0)

	feature_type = config.FEATURE_TYPE
	feature = None

	if feature_type == "HogFeature":
		feature = HogFeature()
	else:
		feature = HogSizeFeature()

	# dump dataset
	data, labels = feature.create_data_labels(
		class_dict = config.CATEGORY_CLASS_DICT, 
		limit_num = config.LIMIT_NUM, 
		pkl_data_label_path = config.PKL_DATA_LABEL_FILE,
		pkl_params_path = config.PKL_PARAMS_FILE)
Exemplo n.º 2
0
	classifier_file = config.PKL_CLASSIFIER_FILE
	params_file = config.PKL_PARAMS_FILE

	# load data for estimator
	try:
		clf = joblib.load(classifier_file)
		(mu, sigma) = joblib.load(params_file)
		print clf
	except Exception, e:			
		raise e
	else:
		pass

	if feature_type	== "HogFeature":
		feature = HogFeature(mu, sigma)
	else:
		feature = HogSizeFeature(mu, sigma)

	print "classify for label %d with %s"%(label, classifier_file)

	cnt = 0
	failure = 0
	if os.path.isdir(src):
		for filename in os.listdir(src):
			path = os.path.join(src, filename)
			img = cv2.imread(path, cv2.CV_LOAD_IMAGE_GRAYSCALE)
			if img is not None:
				feature_value = feature.calc(img)
				label_predict = int(clf.predict(feature_value))
				cnt += 1