Ejemplo n.º 1
0
 def __init__(self, res, path, size=util.MAX_THUMBNAIL_SIZE):
     super(Face, self).__init__()
     self.path = path
     self.bmp = wx.Bitmap(path)
     self.name = None
     if res.get('faceId'):
         self.id = res['faceId']
     if res.get('persistedFaceId'):
         self.persisted_id = res['persistedFaceId']
     if res.get('faceRectangle'):
         rect = res['faceRectangle']
         self.left = int(rect['left'])
         self.top = int(rect['top'])
         self.width = int(rect['width'])
         self.height = int(rect['height'])
         self.bmp = self.bmp.GetSubBitmap(
             wx.Rect(self.left, self.top, self.width, self.height))
     if res.get('faceAttributes'):
         attr = res['faceAttributes']
         self.age = int(attr['age'])
         self.gender = attr['gender']
         self.head_pose = "Pitch: {}, Roll:{}, Yaw:{}".format(
             attr['headPose']['pitch'], attr['headPose']['roll'],
             attr['headPose']['yaw'])
         self.smile = float(attr['smile']) > 0 and 'Smile' or 'Not Smile'
         self.facial_hair = sum(attr['facialHair'].values()) > 0 and 'Yes' \
             or 'No'
         self.glasses = attr['glasses']
         self.emotion = max(attr['emotion'],
                            key=lambda key: attr['emotion'][key])
     self.bmp = util.scale_bitmap(self.bmp, size)
Ejemplo n.º 2
0
 def create_header(self, parent):
     panel = wx.Panel(parent, -1)
     panel.SetBackgroundColour(wx.Colour(*BACKGROUND))
     panel.SetForegroundColour(wx.BLACK)
     feed = self.item.feed
     paths = ['icons/feed.png']
     if feed.has_favicon:
         paths.insert(0, feed.favicon_path)
     for path in paths:
         try:
             bitmap = util.scale_bitmap(wx.Bitmap(path), 16, 16, wx.Colour(*BACKGROUND))
             break
         except Exception:
             pass
     else:
         bitmap = wx.EmptyBitmap(16, 16)
     icon = controls.BitmapLink(panel, feed.link, bitmap)
     icon.SetBackgroundColour(wx.Colour(*BACKGROUND))
     width, height = icon.GetSize()
     feed = self.create_feed(panel, width)
     button = controls.BitmapLink(panel, popups.COMMAND_CLOSE, wx.Bitmap('icons/cross.png'), wx.Bitmap('icons/cross_hover.png'))
     button.SetBackgroundColour(wx.Colour(*BACKGROUND))
     sizer = wx.BoxSizer(wx.HORIZONTAL)
     sizer.Add(icon, 0, wx.ALIGN_CENTER|wx.ALL, 10)
     sizer.Add(feed, 1, wx.ALIGN_CENTER_VERTICAL|wx.TOP|wx.BOTTOM, 5)
     sizer.Add(button, 0, wx.ALIGN_CENTER|wx.ALL, 10)
     panel.SetSizer(sizer)
     self.bind_links([icon, button])
     self.bind_widgets([panel])
     return panel
Ejemplo n.º 3
0
    def set_bmp(self, bitmap):
        """Set the image bitmap."""
        self.bmp = util.scale_bitmap(bitmap, size=self.size)
        width = bitmap.GetWidth()
        new_width = self.bmp.GetWidth()

        self.scale = 1.0 * new_width / width

        self.bitmap.SetBitmap(self.bmp)
        self.sizer.Layout()
Ejemplo n.º 4
0
    def set_path(self, path):
        """Set the image path."""
        bitmap = wx.Bitmap(path)
        self.bmp = util.scale_bitmap(bitmap, size=self.size)

        width = bitmap.GetWidth()
        new_width = self.bmp.GetWidth()

        self.scale = 1.0 * new_width / width

        self.bitmap.SetBitmap(self.bmp)
        self.sizer.Layout()
 def __init__(self, res, path, size=util.MAX_THUMBNAIL_SIZE):
     super(Face, self).__init__()
     self.path = path
     self.bmp = wx.Bitmap(path)
     self.name = None
     if res.get('faceId'):
         self.id = res['faceId']
     if res.get('persistedFaceId'):
         self.persisted_id = res['persistedFaceId']
     if res.get('faceRectangle'):
         rect = res['faceRectangle']
         self.left = int(rect['left'])
         self.top = int(rect['top'])
         self.width = int(rect['width'])
         self.height = int(rect['height'])
         self.bmp = self.bmp.GetSubBitmap(
             wx.Rect(self.left, self.top, self.width, self.height))
     if res.get('faceAttributes'):
         attr = res['faceAttributes']
         self.age = int(attr['age'])
         self.gender = attr['gender']
         self.smile = float(attr['smile']) > 0 and 'Smile' or 'Not Smile'
         self.glasses = attr['glasses']
     self.bmp = util.scale_bitmap(self.bmp, size)