Пример #1
0
 def run(self):
     while True:
         image = StringIO.StringIO(self.img_queue.get())
         logger.debug("Processing net image")
         stks = imageBufferToStrokes(image)
         logger.debug("Processed net image, converting strokes")
         for stk in stks:
             newStroke = Stroke()
             for x,y in stk.points:
                scale = WIDTH / float(1280)
                newPoint = Point(scale * x,HEIGHT - scale * y)
                newStroke.addPoint(newPoint)
             self.stk_queue.put(newStroke)
Пример #2
0
    def LoadStrokesFromImage(self):
        fname = askopenfilename(initialdir='/home/jbrowne/src/sketchvision/images/')
        if fname == "":
           return

        try:
           print "Loading strokes..."
           strokes = imageToStrokes(fname)
        except Exception as e:
           print "Error importing strokes from image '%s':\n %s" % (fname, e)
           return
        print "Loaded %s strokes from '%s'" % (len(strokes), fname)

        for s in strokes:
           newStroke = Stroke()
           for x,y in s.points:
              scale = WIDTH / float(1280)
              newPoint = Point(scale * x,HEIGHT - scale * y)
              newStroke.addPoint(newPoint)
           self.Board.AddStroke(newStroke)
           self.StrokeList.append(newStroke)
Пример #3
0
 def loadStrokes(self):
    fd = open(self._fname, "r")
    curStroke = None
    for line in fd.readlines():
       if line.startswith("#STROKE"):
          curStroke = Stroke()
       elif line.startswith("#ENDSTROKE"):
          logger.debug("Loaded Stroke with %s points" % (len(curStroke.Points)) )
          yield curStroke
          curStroke = None
       else:
          fields = line.split()
          assert len(fields) <= 3 and len(fields) > 1, "Error: ill-formed point"
          if len(fields) == 2:
             x, y = fields
             t = 0.0
          elif len(fields) == 3:
             x, y, t = fields
             
          curStroke.addPoint ( Point(float(x), float(y), float(t)) )
    fd.close()
Пример #4
0
    def LoadStrokesFromImage(self):
        fname = askopenfilename(initialdir='./')
        if fname == "":
           return

        try:
           logger.debug( "Loading strokes...")
           strokes = ImageStrokeConverter.imageToStrokes(fname)
        except Exception as e:
           logger.debug( "Error importing strokes from image '%s':\n %s" % (fname, e))
           return
        logger.debug( "Loaded %s strokes from '%s'" % (len(strokes), fname))

        for s in strokes:
           newStroke = Stroke()
           for x,y in s.points:
              scale = WIDTH / float(1280)
              newPoint = Point(scale * x,HEIGHT - scale * y)
              newStroke.addPoint(newPoint)
           #self.Board.AddStroke(newStroke)
           self.StrokeList.append(newStroke)