Exemple #1
0
def _scoreStroke(stroke, template, sample_size = None):
    
    if sample_size is None:
        sample_size = len(template)
        
    sNorm = GeomUtils.strokeNormalizeSpacing(stroke, len(template))
    centr = GeomUtils.centroid(sNorm.Points)
    numPoints = len(sNorm.Points)
    
    point_vect = []
    templ_vect = []

    numPoints = len(template)
    if len(template) == len(sNorm.Points):
        for idx in range(0, numPoints, numPoints/sample_size ):
            templ_vect.append(template[idx].X)
            templ_vect.append(template[idx].Y)
            
            p = sNorm.Points[idx]
            point_vect.append(p.X - centr.X)
            point_vect.append(p.Y - centr.Y)
       
        angularDist = GeomUtils.vectorDistance(point_vect, templ_vect)
    else:
        angularDist = math.pi
    return angularDist
Exemple #2
0
def scoreStroke(stroke, template):
    sNorm = GeomUtils.strokeNormalizeSpacing(stroke, TEMPLATE_SAMPLE)
    centr = GeomUtils.centroid(sNorm.Points)
    point_vect = []
    templ_vect = []
    for q in template:
       templ_vect.append(q.X)
       templ_vect.append(q.Y)
    for p in sNorm.Points:
       point_vect.append(p.X - centr.X)
       point_vect.append(p.Y - centr.Y)
    angularDist = GeomUtils.vectorDistance(point_vect, templ_vect)
    return angularDist