face-intel / cores /vision /__init__.py
Marwan
Restructure + add reverse face search (PimEyes-style)
f5eeb1c
Raw
History Blame Contribute Delete
2.11 kB
"""
Vision Core — the single source of truth for image operations.
Every provider that needs to decode, resize, convert, hash, or analyze
an image calls these functions instead of reimplementing them. This
guarantees:
1. Single decode path (no double-decoding of the same bytes).
2. Single resize policy (consistent max_dim, interpolation).
3. Single hashing implementation (cache keys always match).
4. Single color-conversion path (BGR <-> Gray <-> RGB).
5. Single perceptual-hash implementation (pHash, dHash, aHash, wHash).
This module is dependency-light: only numpy + cv2 + Pillow (already
required by the platform). No external services, no model downloads.
"""
from cores.vision.decode import (
bytes_to_numpy,
base64_to_numpy,
numpy_to_base64,
numpy_to_bytes,
url_to_bytes,
url_to_numpy,
sniff_format,
)
from cores.vision.geometry import (
BBox,
crop_region,
resize_with_aspect,
clamp_box,
boxes_iou,
)
from cores.vision.color import (
to_gray,
to_rgb,
to_bgr,
guess_color_profile,
dominant_colors,
)
from cores.vision.hashing import (
sha256_bytes,
sha256_image,
phash,
dhash,
ahash,
whash,
hamming_distance,
)
from cores.vision.quality import (
brightness,
contrast,
sharpness,
noise_level,
quality_score,
)
from cores.vision.drawing import draw_boxes
from cores.vision.yolo import letterbox, nms, xywh2xyxy, scale_boxes
__all__ = [
# decode
"bytes_to_numpy", "base64_to_numpy", "numpy_to_base64", "numpy_to_bytes",
"url_to_bytes", "url_to_numpy", "sniff_format",
# geometry
"BBox", "crop_region", "resize_with_aspect", "clamp_box", "boxes_iou",
# color
"to_gray", "to_rgb", "to_bgr", "guess_color_profile", "dominant_colors",
# hashing
"sha256_bytes", "sha256_image", "phash", "dhash", "ahash", "whash",
"hamming_distance",
# quality
"brightness", "contrast", "sharpness", "noise_level", "quality_score",
# drawing
"draw_boxes",
# yolo postprocessing
"letterbox", "nms", "xywh2xyxy", "scale_boxes",
]