Ejemplo n.º 1
0
 def _loadimage(self, dims, smalldims):
     """Load the image in normal size and small size.
     
     Argument
     dims -- tuple containing normal width and height of the image
     smalldims -- tuple containing small width and height of the image
     
     """
     if(self._imagename == ''):
         self.image = None
         self.smallimage = None
     else:
         try:
             image = Image.open(self._imagename)
             previmage = resizeImage(image, dims[0], dims[1])
             self.image = ImageTk.PhotoImage(previmage)
             smallimage = resizeImage(image, smalldims[0], smalldims[1])
             self.smallimage = ImageTk.PhotoImage(smallimage)
         except IOError:
             print('Error: could not open ' + self._imagename)
             self.valid = False
def recognizePictureCandidates(faceRecognizer, subjects, imageSize = None):
  path = "/home/juan/ciberpunks/faces/candidatos/"
  for filename in os.listdir(path):
    try:
      im = Image.open(os.path.join(path, filename))
      im = resizeImage(im.convert("L"), imageSize)
      image = np.asarray(im, dtype=np.uint8)
      (prediction, distance) = faceRecognizer.predict(image)
      print "Filename: {0} - Predicted = {1} with distance {2}".format(filename, subjects[prediction], distance)
    except IOError as e:
      print "I/O error({0}): {1}".format(e.errno, e.strerror)
    except:
      print "Unexpected error:", sys.exc_info()[0]
      raise
Ejemplo n.º 3
0
    def __init__(self, imagename, smalldims):
        """Create IconItem.
        
        Arguments
        imagename -- the name of the image
        smalldims -- a tuple containing the maximum dimensions of the icon
        
        """
        self.smallimage = None

        try:
            image = Image.open(imagename)
            smallimage = resizeImage(image, smalldims[0], smalldims[1])
            self.smallimage = ImageTk.PhotoImage(smallimage)
        except IOError:
            print('Error: could not open ' + imagename)
Ejemplo n.º 4
0
 def __init__(self, imagename, smalldims):
     """Create IconItem.
     
     Arguments
     imagename -- the name of the image
     smalldims -- a tuple containing the maximum dimensions of the icon
     
     """
     self.smallimage = None
     
     try:
         image = Image.open(imagename)
         smallimage = resizeImage(image, smalldims[0], smalldims[1])
         self.smallimage = ImageTk.PhotoImage(smallimage)
     except IOError:
         print('Error: could not open ' + imagename)