Exemplo n.º 1
0
def view_collection(collection):

	folder = None
	background = None
	label = None
	file_ext = 'bmp'

	with open(collection, 'r') as f_collection:
		for line in f_collection:

			a_line = line.replace('\n','').split('\t')  # remove line breaks and split at tab
			folder = a_line[0]							# first element is folder containing video images
			background = a_line[1]						# background model for this collection
			label = a_line[2]							# ground truth label


			hd = DetectorFactory.get_hand_detector('realsense', 'color')
			hd.initialize_detector(background, folder, file_ext)


			# for img, filepath in hd.img_generator():
			# 	cv2.putText(img, filepath, (0,30), cv2.FONT_HERSHEY_SIMPLEX, .5, 255)
			# 	cv2.imshow('Img', img)
			# 	cv2.waitKey(0)


			for hands in hd.hand_generator():
				hands.show()


	cv2.destroyAllWindows()
Exemplo n.º 2
0
def analyze_error2():
	train_collection  = 'data/train_2.col'
	test_collection_all = 'data/error2_2.col'	

	hd = DetectorFactory.get_hand_detector('kinect', 'depth')

	clf_l, clf_r, label_names = train_classifiers(train_collection, hd, 'bin', 'svc')

	error_analysis(test_collection_all, hd, clf_l, clf_r, label_names, 'bin', 'Kinect')
Exemplo n.º 3
0
def analyze_realsense():

	train_collection  = 'data/train_1.col'
	test_collection_all = 'data/test_all_1.col'	

	hd = DetectorFactory.get_hand_detector('realsense', 'grey')

	clf_l, clf_r, label_names = train_classifiers(train_collection, hd, 'bmp', 'svc')

	error_analysis(test_collection_all, hd, clf_l, clf_r, label_names, 'bmp', 'Realsense')
Exemplo n.º 4
0
import numpy as np

import features.feature_extraction as fe
from classification.classification import Classifier
from hands.detector_factory import DetectorFactory


# files

# train_collection = 'data/train_combined.col'
train_collection = 'data/train_1.col'
test_collection_b = 'data/test_b_1.col'
test_collection_c = 'data/test_c_1.col'
test_collection_d = 'data/test_d_1.col'

hd = DetectorFactory.get_hand_detector('realsense', 'grey')

summarize = False
features = 'honv'

train_data, train_labels, train_label_names, _ = fe.generate_dataset(train_collection, hd, 'bmp', features, summarize)
test_data_1, test_labels_1, test_label_names_1, _ = fe.generate_dataset(test_collection_b, hd_kin, 'bin', features, summarize)		# Still Hand - Fingers Down
test_data_2, test_labels_2, test_label_names_2, _ = fe.generate_dataset(test_collection_c, hd_kin, 'bin', features, summarize)		# Scale
test_data_3, test_labels_3, test_label_names_3, _ = fe.generate_dataset(test_collection_d, hd_kin, 'bin', features, summarize)		# Practice Piece

assert train_label_names == test_label_names_1, 'Train and test dataset do not have the same labels'
assert train_label_names == test_label_names_2, 'Train and test dataset do not have the same labels'
assert train_label_names == test_label_names_3, 'Train and test dataset do not have the same labels'


Exemplo n.º 5
0
import numpy as np

import features.feature_extraction as fe
from classification.classification import Classifier
from hands.detector_factory import DetectorFactory


collection_1 = 'data/cv_all_1.col'
collection_2 = 'data/cv_all_2.col'
collection_3 = 'data/cv_all_3.col'
collection_4 = 'data/cv_all_combined.col'

hd_rs = DetectorFactory.get_hand_detector('realsense', 'grey')
hd_kin = DetectorFactory.get_hand_detector('kinect', 'depth')

summarize = False
features = 'hog'

data_1, labels_1, train_label_names_1, _ = fe.generate_dataset(collection_1, hd_rs, 'bmp', features, summarize)
data_2, labels_2, train_label_names_2, _ = fe.generate_dataset(collection_2, hd_kin, 'bin', features, summarize)
data_3, labels_3, train_label_names_3, _ = fe.generate_dataset(collection_3, hd_kin, 'bin', features, summarize)
data_4, labels_4, train_label_names_3, _ = fe.generate_dataset(collection_4, hd_kin, 'bin', features, summarize)

cv = 5
clf = Classifier('svc')

scores_l_1 = clf.cross_validation(data_1[0], labels_1[0], cv)
scores_r_1 = clf.cross_validation(data_1[1], labels_1[1], cv)

scores_l_2 = clf.cross_validation(data_2[0], labels_2[0], cv)
scores_r_2 = clf.cross_validation(data_2[1], labels_2[1], cv)
Exemplo n.º 6
0
for s in sessions:

	train_collection  = 'data/train_%s.col' % s
	test_collection_b = 'data/test_b_%s.col' % s
	test_collection_c = 'data/test_c_%s.col' % s
	test_collection_d = 'data/test_d_%s.col' % s
	test_collection_e = 'data/test_e_%s.col' % s
	test_collection_f = 'data/test_f_%s.col' % s


	print '#######  Session %s  ############' % s


	for f in featuresets:

		hd = DetectorFactory.get_hand_detector('kinect', 'depth')

		train_data, train_labels, train_label_names, _ = fe.generate_dataset(train_collection, hd, 'bin', f, summarize=summarize)
		test_data_1, test_labels_1, test_label_names_1, _ = fe.generate_dataset(test_collection_b, hd, 'bin', f, summarize=summarize)		# Still Hand - Fingers Down
		test_data_2, test_labels_2, test_label_names_2, _ = fe.generate_dataset(test_collection_c, hd, 'bin', f, summarize=summarize)		# Scale
		test_data_3, test_labels_3, test_label_names_3, _ = fe.generate_dataset(test_collection_d, hd, 'bin', f, summarize=summarize)		# Practice Piece
		test_data_4, test_labels_4, test_label_names_4, _ = fe.generate_dataset(test_collection_e, hd, 'bin', f, summarize=summarize)		# Practice Piece
		test_data_5, test_labels_5, test_label_names_5, _ = fe.generate_dataset(test_collection_f, hd, 'bin', f, summarize=summarize)		# Practice Piece

		assert train_label_names == test_label_names_1, 'Train and test dataset do not have the same labels'
		assert train_label_names == test_label_names_2, 'Train and test dataset do not have the same labels'
		assert train_label_names == test_label_names_3, 'Train and test dataset do not have the same labels'

		# Test with SVC
		# 	left hand
		cls_svc = Classifier(cls_type='svc')