Beispiel #1
0
    def update():
        x, y, c = databuff[CNT]

        scores, thetas, matches = zip(
            *dollar.query(x, y, scale, N, templates_fh))
        print
        for m, r, s in zip(matches, thetas, scores):
            print "'%s': %f (%f)" % (m, s, r * 180 / np.pi)

        for ax in axes.values():
            ax.cla()

        axes['query'].plot(x, y, '-o')
        axes['query'].set_title("Test sample from class '%s'" % c)

        x, y = dollar.preprocess(x, y, scale, N)
        axes['transform'].plot(x, y, '-o')
        axes['transform'].set_title("Transformed query")

        for i in range(3):
            ds = templates_fh[matches[i]][0]
            x_r, y_r = dollar.rotate(x, y, thetas[i])
            axes['match_' + str(i)].plot(ds['x'], ds['y'], '-o', color='b')
            axes['match_' + str(i)].plot(x_r, y_r, '-o', color='g')
            axes['match_' + str(i)].set_title("'%s' (%.2f)" %
                                              (matches[i], scores[i]))

        fig.canvas.draw()
Beispiel #2
0
    def update():
        x,y,c = databuff[CNT]

        scores, thetas, matches = zip(*dollar.query(x,y,scale,N,templates_fh))
        print
        for m,r,s in zip(matches,thetas,scores):
            print "'%s': %f (%f)" % (m,s,r*180/np.pi)

        for ax in axes.values(): ax.cla()

        axes['query'].plot(x,y,'-o')
        axes['query'].set_title("Test sample from class '%s'" % c)

        x,y = dollar.preprocess(x,y,scale,N)
        axes['transform'].plot(x,y,'-o')
        axes['transform'].set_title("Transformed query")

        for i in range(3):
            ds = templates_fh[matches[i]][0]
            x_r,y_r = dollar.rotate(x,y,thetas[i])
            axes['match_'+str(i)].plot(ds['x'],ds['y'],'-o',color='b')
            axes['match_'+str(i)].plot(x_r,y_r,'-o',color='g')
            axes['match_'+str(i)].set_title("'%s' (%.2f)" % (matches[i],scores[i]))
        
        fig.canvas.draw()
Beispiel #3
0
def gesture_match(query,template,score,theta,clsid):
    x,y = query
    n = len(x)
    x,y = dollar.preprocess(x,y,scale,samplesize)

    if score > 0.8:
        query = dollar.rotate(x,y,theta)
        artists.append((gui.lines['template'],template))
        title = "%s (N=%d, score: %.2f)" % (clsid,n,score)
    else:
        query = x,y
        title = "No match (scored too low)"
    artists.append((gui.lines['query'],query))
    gui.axes['match'].set_title(title)
    global redraw
    redraw = True

    print "Class: %s (%.2f)" % (clsid,score)
    print "Npoints:", n
Beispiel #4
0
def gesture_match(query, template, score, theta, clsid):
    x, y = query
    n = len(x)
    x, y = dollar.preprocess(x, y, scale, samplesize)

    if score > 0.8:
        query = dollar.rotate(x, y, theta)
        artists.append((gui.lines['template'], template))
        title = "%s (N=%d, score: %.2f)" % (clsid, n, score)
    else:
        query = x, y
        title = "No match (scored too low)"
    artists.append((gui.lines['query'], query))
    gui.axes['match'].set_title(title)
    global redraw
    redraw = True

    print "Class: %s (%.2f)" % (clsid, score)
    print "Npoints:", n