File size: 2,112 Bytes
892fa81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9bd3ee0
892fa81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9bd3ee0
 
892fa81
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
"""
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",
]