Exemplo n.º 1
0
def make_face_boxed_image(img,
                          feat,
                          color=utils.RED,
                          thickness=4,
                          alpha=0.5,
                          show_conf_=True):
    if feat.face_pos_arr is None or feat.face_conf_arr is None:
        return img

    thickness = thickness if show_conf_ else -1
    for pos, conf in zip(feat.face_pos_arr, feat.face_conf_arr):
        img = utils.draw_box_on_img(img,
                                    pos,
                                    color=color,
                                    thickness=thickness,
                                    alpha=alpha)
        if show_conf_:
            img = cv2.putText(img, "{:3d}".format(conf),
                              (pos[0] + 4, pos[3] - 4),
                              cv2.FONT_HERSHEY_SIMPLEX, 1, utils.WHITE, 5)
            img = cv2.putText(img, "{:3d}".format(conf),
                              (pos[0] + 4, pos[3] - 4),
                              cv2.FONT_HERSHEY_SIMPLEX, 1, color, 2)

    return img
Exemplo n.º 2
0
def make_window_masked_image(self,
                             img,
                             win_pos,
                             color=utils.BLACK,
                             show_sec=-1):
    img = utils.draw_box_on_img(img,
                                win_pos,
                                color=color,
                                thickness=-1,
                                alpha=0)
    utils.imshow(img, desc="make window masked image", pause_sec=show_sec)

    return img
Exemplo n.º 3
0
def make_face_masked_image(img,
                           face_pos_arr,
                           color=utils.RED,
                           margin=0,
                           show_sec=-1):
    if face_pos_arr is None:
        return img

    for face_pos in face_pos_arr:
        pos = [
            face_pos[0] - margin, face_pos[1] - margin, face_pos[2] + margin,
            face_pos[3] + margin
        ]
        pos = utils.check_box_boundary(pos, img.shape[1::-1])
        img = utils.draw_box_on_img(img,
                                    pos,
                                    color=color,
                                    thickness=-1,
                                    alpha=0)

    utils.imshow(img, desc="make face masked image", pause_sec=show_sec)

    return img