(self, bgr, bbox)
| 10737 | return "data:image/png;base64," + base64.b64encode(enc.tobytes()).decode("utf-8") |
| 10738 | |
| 10739 | def _face_icon(self, bgr, bbox): |
| 10740 | import cv2 |
| 10741 | if bbox is None: |
| 10742 | return "" |
| 10743 | try: |
| 10744 | x1, y1, x2, y2 = [int(v) for v in bbox] |
| 10745 | except Exception: |
| 10746 | return "" |
| 10747 | h, w = bgr.shape[:2] |
| 10748 | pad = max(8, int(max(x2 - x1, y2 - y1) * 0.2)) |
| 10749 | x1 = max(0, x1 - pad) |
| 10750 | y1 = max(0, y1 - pad) |
| 10751 | x2 = min(w - 1, x2 + pad) |
| 10752 | y2 = min(h - 1, y2 + pad) |
| 10753 | if x2 <= x1 or y2 <= y1: |
| 10754 | return "" |
| 10755 | crop = bgr[y1:y2, x1:x2] |
| 10756 | if crop.size == 0: |
| 10757 | return "" |
| 10758 | crop = cv2.resize(crop, (96, 96)) |
| 10759 | return self._encode_bgr_png(crop) |
| 10760 | |
| 10761 | def _detect_faces_cv2(self, bgr): |
| 10762 | import cv2 |
no test coverage detected