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)
评论列表
文章目录