Ejemplo n.º 1
0
 def __call__(self, im):
     tmp = im.asPIL()
     tmp = tmp.resize((160, 120))
     tmp = Image(tmp)
     points = self.dog.detect(tmp)
     for score, pt, radius in points:
         pt = Point(pt.X() * 4, pt.Y() * 4)
         im.annotateCircle(pt, radius * 4)
     return im
Ejemplo n.º 2
0
 def __call__(self, im):
     tmp = im.asPIL()
     tmp = tmp.resize((160, 120))
     tmp = Image(tmp)
     points = self.surf.detect(tmp)
     for score, pt, radius in points:
         score = score - 500.0
         if score > 500.0:
             score = 500.0
         score = int(255 * score / 500.0)
         color = "#%02x0000" % score
         pt = Point(pt.X() * 4, pt.Y() * 4)
         im.annotateCircle(pt, radius, color=color)
     return im
Ejemplo n.º 3
0
def AffineNormalizePoints(points):
    '''
    Create a transform that centers a set of points such that there mean is (0,0)
    and then scale such that there average distance from (0,0) is 1.0
     
    @param points: list of link.Point to normalize
    @returns: an AffineTransform object
    '''
    # compute the center
    mean = Point(0,0)
    count = 0
    for point in points:
        mean += point
        count += 1
    mean = (1.0/count)*mean
    
    # mean center the points
    center = AffineTranslate(-mean.X(),-mean.Y(),(0,0))
    points = center.transformPoints(points)
    
    # Compute the mean distance
    mean_dist = 0.0
    count = 0
    for point in points:
        x,y = point.X(),point.Y()
        dist = sqrt(x*x+y*y)
        mean_dist += dist
        count += 1
    mean_dist = (1.0/count)*mean_dist
    
    # Rescale the points
    scale = AffineScale(1.0/mean_dist,(0,0))
    points = scale.transformPoints(points)
    
    # compute the composite transform
    norm = scale*center

    return norm