MCPcopy Create free account
hub / github.com/CScorza/IntelOSINT / _face_embedding_cv2

Method _face_embedding_cv2

IntelOSINT.py:10772–10790  ·  view source on GitHub ↗
(self, bgr, bbox)

Source from the content-addressed store, hash-verified

10770 return out
10771
10772 def _face_embedding_cv2(self, bgr, bbox):
10773 import cv2
10774 import numpy as np
10775 x1, y1, x2, y2 = bbox
10776 crop = bgr[max(0, y1):max(0, y2), max(0, x1):max(0, x2)]
10777 if crop.size == 0:
10778 return None
10779 gray = cv2.cvtColor(crop, cv2.COLOR_BGR2GRAY)
10780 gray = cv2.resize(gray, (96, 96), interpolation=cv2.INTER_AREA)
10781 hog = cv2.HOGDescriptor(
10782 _winSize=(96, 96), _blockSize=(16, 16), _blockStride=(8, 8),
10783 _cellSize=(8, 8), _nbins=9
10784 )
10785 vec = hog.compute(gray)
10786 if vec is None:
10787 return None
10788 v = vec.flatten().astype("float32")
10789 n = float(np.linalg.norm(v) + 1e-12)
10790 return v / n
10791
10792 def compare_faces_arcface(self, image_a=None, image_b=None, threshold=(0.55 + 0.36) / 1.36, images_a=None, images_b=None, mode="pair", provider="arcface"):
10793 try:

Callers 1

extract_from_imageMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected