|
|
''' |
|
|
If you use your personal computer, often you will not have the performance needed to work on all this data. |
|
|
this script will help you bring out a sample that you can work on. |
|
|
if you want to work with all data, ignore this file. |
|
|
''' |
|
|
import csv |
|
|
import shutil |
|
|
|
|
|
def copyDirectory(src , dest): |
|
|
try: |
|
|
shutil.copytree(src, dest) |
|
|
return 1 |
|
|
|
|
|
except shutil.Error as e: |
|
|
print('Directory not copied. Error: %s' % e) |
|
|
return 2 |
|
|
|
|
|
except OSError as e: |
|
|
print('Directory not copied. Error: %s' % e) |
|
|
return 3 |
|
|
|
|
|
|
|
|
path_dest = 'validation_samples' |
|
|
path_source = '20BN-JESTER' |
|
|
csv_file = 'data_csv/jester-v1-validation.csv' |
|
|
|
|
|
file = open(csv_file, 'r') |
|
|
reader = csv.reader(file, delimiter=';') |
|
|
count = 0 |
|
|
simple = 500 |
|
|
class_ = ['Thumb Up', 'Swiping Right', 'Sliding Two Fingers Left', 'No gesture'] |
|
|
rows = [] |
|
|
|
|
|
for c in class_: |
|
|
for line in reader: |
|
|
target = line[1] |
|
|
ref = line[0] |
|
|
|
|
|
if target == c: |
|
|
dep = copyDirectory(path_source+ref , path_dest+ref) |
|
|
if dep == 1: |
|
|
count += 1 |
|
|
rows.append([ref, target]) |
|
|
if count == simple: |
|
|
break |
|
|
|
|
|
|
|
|
'''with open(path_dest+'validation.csv', 'wt') as f: |
|
|
csv_writer = csv.writer(f, quoting = csv.QUOTE_ALL) |
|
|
csv_writer.writerows(rows)''' |