Beispiel #1
0
def simulate(input):
    chdir('/home/sarath/My_PRojects/gesture')
    print "Succesfully changed directory"
    try:
	    net=cPickle.load(open('net.net','r'))
    except:
	    print 'Unable to open file net.net'
	    exit()
    print 'Succesfully opened file net.net'
    shape=shape_dict()
    in_put=[]
    for i in input:
        in_put.extend(i)
    try:
        out=tuple(net.sim([in_put])[0])
    except:
        print 'simulation error'
        return
    out=list(out)
    print 'out as  list'
    print out
    for i in range(4):
        if i == out.index(max(out)):
            out[i]=1
        else:
            out[i]=0
    out=out.index(1)
    print out
       

    if out == shape['T'].index(1):
        gesture="Triangle"
    elif out == shape['R'].index(1):
        gesture = 'Rectangle'
    elif out == shape['L'].index(1):
        gesture = 'Line'
    elif out == shape['C'].index(1):
        gesture = 'circle'
    else :
        gesture='not defined'
    


    out="notify-send 'the figure is %s '" % (gesture)
    print out
    system(out)
Beispiel #2
0
def simulate(input):
    chdir('/home/sarath/My_PRojects/gesture')
    print "Succesfully changed directory"
    try:
        net = cPickle.load(open('net.net', 'r'))
    except:
        print 'Unable to open file net.net'
        exit()
    print 'Succesfully opened file net.net'
    shape = shape_dict()
    in_put = []
    for i in input:
        in_put.extend(i)
    try:
        out = tuple(net.sim([in_put])[0])
    except:
        print 'simulation error'
        return
    out = list(out)
    print 'out as  list'
    print out
    for i in range(4):
        if i == out.index(max(out)):
            out[i] = 1
        else:
            out[i] = 0
    out = out.index(1)
    print out

    if out == shape['T'].index(1):
        gesture = "Triangle"
    elif out == shape['R'].index(1):
        gesture = 'Rectangle'
    elif out == shape['L'].index(1):
        gesture = 'Line'
    elif out == shape['C'].index(1):
        gesture = 'circle'
    else:
        gesture = 'not defined'

    out = "notify-send 'the figure is %s '" % (gesture)
    print out
    system(out)
def get_train_data():
	from os  import listdir,chdir,remove,rename
	from filtering import filter_xyz
	from clustering import cluster
	table=shape_dict()
	in_put=[]
	target=[]
	chdir('./Shapes')
	for i in listdir('.'):
		try:
			
			data=getdata_file(i)
			data=filter_xyz(data)
			data14=cluster(data,14);
			in_put.append(data14)
			target.append(table[i[0]])
		except:
			print '\t\t\tERROR in file ',i,'removing ',i
 			remove(i)
			pass
	chdir('..')
	return in_put,target