util.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:Cognitive-Face-Python 作者: Microsoft 项目源码 文件源码
def draw_bitmap_rectangle(bitmap, faces):
    """Draw rectangle on bitmap."""
    dc = wx.MemoryDC(bitmap.bmp)
    dc.SetPen(wx.BLUE_PEN)
    dc.SetBrush(wx.TRANSPARENT_BRUSH)
    dc.SetTextBackground('black')
    dc.SetTextForeground('white')
    dc.SetBackgroundMode(wx.SOLID)
    dc.SetFont(wx.Font(8,
                       wx.FONTFAMILY_DEFAULT,
                       wx.FONTSTYLE_NORMAL,
                       wx.FONTWEIGHT_BOLD))
    for face in faces:
        dc.DrawRectangle(
            face.rect.left * bitmap.scale,
            face.rect.top * bitmap.scale,
            face.rect.width * bitmap.scale,
            face.rect.height * bitmap.scale,
        )
        if face.name:
            text_width, text_height = dc.GetTextExtent(face.name)
            dc.DrawText(face.name,
                        face.rect.left * bitmap.scale,
                        face.rect.top * bitmap.scale - text_height)
    dc.SelectObject(wx.NullBitmap)
    bitmap.bitmap.SetBitmap(bitmap.bmp)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号