Exemplo n.º 1
0
    def __init__(self, points=None, smoothing=False):
        # call parent constructor
        AnnotatableObject.__init__(self) 
        # give each stroke a unique id
        self.id = Stroke.Number
        Stroke.Number += 1

        self.Points = []
        self.BoundTopLeft = Point( 0, 0 )
        self.BoundBottomRight = Point( 0, 0 )
        #Centerpoint of this stroke
        self.X = None
        self.Y = None
        self.Center = None
        self.Color = Stroke.DefaultStrokeColor

        self._length = -1
        self._resample = {}

        if points and len(points)>0:
            # if passed a sequence of tuples, covert them all to points
            if all(type(i)==tuple for i in points):
                points = [ Point(x,y) for (x,y) in points ]
            # turning smoothing off is very handy for testing
            if smoothing: 
                # get rid of redundant points
                rfree = [ points[0] ]
                rfree.extend( [ b for (a,b) in zip(points[:-1],points[1:]) if (a.X!=b.X or a.Y!=b.Y or a.T!=b.T)] )
                logger.debug( "redundant points: %d", len(points) - len(rfree) )
                logger.debug( "raw points: %s", [str(i) for i in points] )
                # smooth over the rest
                from Utis.GeomUtils import smooth
                points = smooth( rfree  )
            for p in points:
                self.addPoint(p)
Exemplo n.º 2
0
 def __init__(self, xLoc, yLoc, drawTime=0):
     AnnotatableObject.__init__(self)
     #self.X = int(xLoc)
     #self.Y = int(yLoc)
     #self.T = int(drawTime)
     self.X = float(xLoc)
     self.Y = float(yLoc)
     self.T = float(drawTime)
Exemplo n.º 3
0
    def __init__(self, points=None, id = None, board=None):#, smoothing=False): DEPRECATED
        # call parent constructor
        AnnotatableObject.__init__(self) 
        # give each stroke a unique ident
        if id != None:
            self.ident = id
            Stroke.Number = max(Stroke.Number, id) + 1
        else:
            self.ident = Stroke.Number
            Stroke.Number += 1

        self.Points = []
        self.BoundTopLeft = Point( 0, 0 )
        self.BoundBottomRight = Point( 0, 0 )
        #Centerpoint of this stroke
        self.X = None
        self.Y = None
        self.Center = None
        self.Color = Stroke.DefaultStrokeColor
        self._featureVectors = {} #Rubine Feature vector for this stroke. Set by calling setFeatureVector(...)

        self._length = None
        self._resample = {}
        self.setBoard(board)# self._board = board

        if points and len(points)>0:
            # if passed a sequence of tuples, covert them all to points
            if all(type(i)==tuple for i in points):
                points = [ Point(x,y) for (x,y) in points ]
            # turning smoothing off is very handy for testing
            self.Points = points
            xlist = [p.X for p in points]
            ylist = [p.Y for p in points]
            ( left , right ) = min(xlist), max(xlist)
            ( bottom, top ) = min(ylist), max(ylist)
            self.BoundTopLeft = Point(left, top)
            self.BoundBottomRight = Point(right, bottom)

            self.X = (left + right) / 2
            self.Y = (top + bottom) / 2
            self.Center = Point(self.X, self.Y)