testCase[10].bBox=[8.25,9.25,2,2.75] testCase[11].bBox=[10,11,1.75,3.9] testCase[12].bBox=[11,11.5,1.25,1.75] testCase[13].bBox=[11.75,12,1.25,2] testCase[14].bBox=[11.4,11.6,2.75,3.5] testCase[15].bBox=[12.5,12.75,1,4] for ntc in range(len(testCase)): testCase[ntc].center=[(testCase[ntc].bBox[0]+testCase[ntc].bBox[1])/2.0,(testCase[ntc].bBox[2]+testCase[ntc].bBox[3])/2.0] for ntc in range(len(testCase)): plt.plot([testCase[ntc].bBox[0],testCase[ntc].bBox[1]],[-testCase[ntc].bBox[2],-testCase[ntc].bBox[2]],'r-') plt.plot([testCase[ntc].bBox[1],testCase[ntc].bBox[1]],[-testCase[ntc].bBox[2],-testCase[ntc].bBox[3]],'r-') plt.plot([testCase[ntc].bBox[1],testCase[ntc].bBox[0]],[-testCase[ntc].bBox[3],-testCase[ntc].bBox[3]],'r-') plt.plot([testCase[ntc].bBox[0],testCase[ntc].bBox[0]],[-testCase[ntc].bBox[3],-testCase[ntc].bBox[2]],'r-') #plt.show() tags=['\sum1','n1','i2','01','=2','(1','x2','21','x2','i2','+2','y1','21','y1','i2',')1'] dominations,laTexExpr= stru.expreBuilder(testCase,tags) plt.figure(5) plt.text(0,0.5,'$%s$'%laTexExpr,fontsize=30) plt.show() elif test==2: filenom=sys.argv[1] #Llegir el nom del fitxer InkML de la consola Coord=ink2Traces.i2t(filenom) #Extreure les coordenades donades pel fitxer img,byAxis,difs=drawTraces.draw(Coord) #Mostrar resultat obtingut i montar imatge Symb,groupedStrokes=fileSeg.segment(Coord,byAxis,difs) #Agrupar traces en simbols Symb=drawRegions.drawS(Symb) testCase=Symb plt.figure(4) for ntc in range(len(testCase)): plt.plot([testCase[ntc].bBox[0],testCase[ntc].bBox[1]],[-testCase[ntc].bBox[2],-testCase[ntc].bBox[2]],'r-') plt.plot([testCase[ntc].bBox[1],testCase[ntc].bBox[1]],[-testCase[ntc].bBox[2],-testCase[ntc].bBox[3]],'r-') plt.plot([testCase[ntc].bBox[1],testCase[ntc].bBox[0]],[-testCase[ntc].bBox[3],-testCase[ntc].bBox[3]],'r-')
] for ntc in range(len(testCase)): plt.plot([testCase[ntc].bBox[0], testCase[ntc].bBox[1]], [-testCase[ntc].bBox[2], -testCase[ntc].bBox[2]], 'r-') plt.plot([testCase[ntc].bBox[1], testCase[ntc].bBox[1]], [-testCase[ntc].bBox[2], -testCase[ntc].bBox[3]], 'r-') plt.plot([testCase[ntc].bBox[1], testCase[ntc].bBox[0]], [-testCase[ntc].bBox[3], -testCase[ntc].bBox[3]], 'r-') plt.plot([testCase[ntc].bBox[0], testCase[ntc].bBox[0]], [-testCase[ntc].bBox[3], -testCase[ntc].bBox[2]], 'r-') #plt.show() tags = [ '\sum1', 'n1', 'i2', '01', '=2', '(1', 'x2', '21', 'x2', 'i2', '+2', 'y1', '21', 'y1', 'i2', ')1' ] dominations, laTexExpr = stru.expreBuilder(testCase, tags) plt.figure(5) plt.text(0, 0.5, '$%s$' % laTexExpr, fontsize=30) plt.show() elif test == 2: filenom = sys.argv[1] #Llegir el nom del fitxer InkML de la consola Coord = ink2Traces.i2t( filenom) #Extreure les coordenades donades pel fitxer img, byAxis, difs = drawTraces.draw( Coord) #Mostrar resultat obtingut i montar imatge Symb, groupedStrokes = fileSeg.segment(Coord, byAxis, difs) #Agrupar traces en simbols Symb = drawRegions.drawS(Symb) testCase = Symb plt.figure(4) for ntc in range(len(testCase)):
] del averages['i2'], averages['\ldots3'], averages['.1'], averages[ '/1'], averages['-1'], averages['!2'] weights = fp.ponderateByConcentration( ) #Aplica una ponderacio per concentracio a les features amp = np.asarray([[Coord[i, j, 0] for j in range(Coord.shape[1])] for i in range(Coord.shape[0])], np.float64).max() - np.asarray( [[Coord[i, j, 0] for j in range(Coord.shape[1])] for i in range(Coord.shape[0])], np.float64).min() alt = np.asarray([[Coord[i, j, 1] for j in range(Coord.shape[1])] for i in range(Coord.shape[0])], np.float64).max() - np.asarray( [[Coord[i, j, 1] for j in range(Coord.shape[1])] for i in range(Coord.shape[0])], np.float64).min() print 'Starting to classify:' foundTags = [] for i in range(len(Symb)): #Per cada simbol a analitzar li assigna un caracter decision = eM.elasticMatching(averages, Symb[i], weights, amp, alt) print decision foundTags.append(decision) dominations, laTexExpr = stru.expreBuilder(Symb, foundTags) print 'Given Tex expression:' print laTexExpr print '100% Complete' print 'Results shown on figures.' fig = plt.figure(3) fig.canvas.set_window_title('Expression') plt.text(0, 0.5, '$%s$' % laTexExpr, fontsize=30) plt.show()