screenshot-vision-algorithm 0.3.8__tar.gz → 0.3.10__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {screenshot_vision_algorithm-0.3.8 → screenshot_vision_algorithm-0.3.10}/PKG-INFO +1 -1
- {screenshot_vision_algorithm-0.3.8 → screenshot_vision_algorithm-0.3.10}/pyproject.toml +1 -1
- {screenshot_vision_algorithm-0.3.8 → screenshot_vision_algorithm-0.3.10}/src/screenshot_vision_algorithm/android/wechat/algorithms/speaker_band.py +2 -1
- {screenshot_vision_algorithm-0.3.8 → screenshot_vision_algorithm-0.3.10}/src/screenshot_vision_algorithm/android/wechat/ocr/nickname_binding.py +52 -4
- {screenshot_vision_algorithm-0.3.8 → screenshot_vision_algorithm-0.3.10}/src/screenshot_vision_algorithm.egg-info/PKG-INFO +1 -1
- {screenshot_vision_algorithm-0.3.8 → screenshot_vision_algorithm-0.3.10}/README.md +0 -0
- {screenshot_vision_algorithm-0.3.8 → screenshot_vision_algorithm-0.3.10}/setup.cfg +0 -0
- {screenshot_vision_algorithm-0.3.8 → screenshot_vision_algorithm-0.3.10}/src/screenshot_vision_algorithm/__init__.py +0 -0
- {screenshot_vision_algorithm-0.3.8 → screenshot_vision_algorithm-0.3.10}/src/screenshot_vision_algorithm/_config.py +0 -0
- {screenshot_vision_algorithm-0.3.8 → screenshot_vision_algorithm-0.3.10}/src/screenshot_vision_algorithm/android/__init__.py +0 -0
- {screenshot_vision_algorithm-0.3.8 → screenshot_vision_algorithm-0.3.10}/src/screenshot_vision_algorithm/android/wechat/__init__.py +0 -0
- {screenshot_vision_algorithm-0.3.8 → screenshot_vision_algorithm-0.3.10}/src/screenshot_vision_algorithm/android/wechat/algorithms/__init__.py +0 -0
- {screenshot_vision_algorithm-0.3.8 → screenshot_vision_algorithm-0.3.10}/src/screenshot_vision_algorithm/android/wechat/algorithms/avatar_column.py +0 -0
- {screenshot_vision_algorithm-0.3.8 → screenshot_vision_algorithm-0.3.10}/src/screenshot_vision_algorithm/android/wechat/algorithms/badge_detection.py +0 -0
- {screenshot_vision_algorithm-0.3.8 → screenshot_vision_algorithm-0.3.10}/src/screenshot_vision_algorithm/android/wechat/algorithms/card_bbox.py +0 -0
- {screenshot_vision_algorithm-0.3.8 → screenshot_vision_algorithm-0.3.10}/src/screenshot_vision_algorithm/android/wechat/algorithms/phash_utils.py +0 -0
- {screenshot_vision_algorithm-0.3.8 → screenshot_vision_algorithm-0.3.10}/src/screenshot_vision_algorithm/android/wechat/algorithms/template_matching.py +0 -0
- {screenshot_vision_algorithm-0.3.8 → screenshot_vision_algorithm-0.3.10}/src/screenshot_vision_algorithm/android/wechat/algorithms/title_ocr.py +0 -0
- {screenshot_vision_algorithm-0.3.8 → screenshot_vision_algorithm-0.3.10}/src/screenshot_vision_algorithm/android/wechat/merge/__init__.py +0 -0
- {screenshot_vision_algorithm-0.3.8 → screenshot_vision_algorithm-0.3.10}/src/screenshot_vision_algorithm/android/wechat/merge/multipage.py +0 -0
- {screenshot_vision_algorithm-0.3.8 → screenshot_vision_algorithm-0.3.10}/src/screenshot_vision_algorithm/android/wechat/ocr/__init__.py +0 -0
- {screenshot_vision_algorithm-0.3.8 → screenshot_vision_algorithm-0.3.10}/src/screenshot_vision_algorithm/android/wechat/ocr/avatar_guard.py +0 -0
- {screenshot_vision_algorithm-0.3.8 → screenshot_vision_algorithm-0.3.10}/src/screenshot_vision_algorithm/android/wechat/ocr/badge_ocr.py +0 -0
- {screenshot_vision_algorithm-0.3.8 → screenshot_vision_algorithm-0.3.10}/src/screenshot_vision_algorithm/android/wechat/ocr/text_ocr_adapter.py +0 -0
- {screenshot_vision_algorithm-0.3.8 → screenshot_vision_algorithm-0.3.10}/src/screenshot_vision_algorithm/android/wechat/profiles/__init__.py +0 -0
- {screenshot_vision_algorithm-0.3.8 → screenshot_vision_algorithm-0.3.10}/src/screenshot_vision_algorithm/android/wechat/profiles/android.py +0 -0
- {screenshot_vision_algorithm-0.3.8 → screenshot_vision_algorithm-0.3.10}/src/screenshot_vision_algorithm/android/wechat/profiles/harmony.py +0 -0
- {screenshot_vision_algorithm-0.3.8 → screenshot_vision_algorithm-0.3.10}/src/screenshot_vision_algorithm/android/wechat/profiles/ios.py +0 -0
- {screenshot_vision_algorithm-0.3.8 → screenshot_vision_algorithm-0.3.10}/src/screenshot_vision_algorithm/android/wechat/templates/android/8.0.69/chat_back_chevron.png +0 -0
- {screenshot_vision_algorithm-0.3.8 → screenshot_vision_algorithm-0.3.10}/src/screenshot_vision_algorithm/android/wechat/templates/android/8.0.69/chat_input_emoji_smile.png +0 -0
- {screenshot_vision_algorithm-0.3.8 → screenshot_vision_algorithm-0.3.10}/src/screenshot_vision_algorithm/android/wechat/templates/android/8.0.69/chat_input_plus.png +0 -0
- {screenshot_vision_algorithm-0.3.8 → screenshot_vision_algorithm-0.3.10}/src/screenshot_vision_algorithm/android/wechat/templates/android/8.0.69/chat_input_voice.png +0 -0
- {screenshot_vision_algorithm-0.3.8 → screenshot_vision_algorithm-0.3.10}/src/screenshot_vision_algorithm/android/wechat/templates/android/8.0.69/chat_title_more_dots.png +0 -0
- {screenshot_vision_algorithm-0.3.8 → screenshot_vision_algorithm-0.3.10}/src/screenshot_vision_algorithm/android/wechat/templates/android/8.0.69/favorite_label.png +0 -0
- {screenshot_vision_algorithm-0.3.8 → screenshot_vision_algorithm-0.3.10}/src/screenshot_vision_algorithm/android/wechat/templates/android/8.0.69/new_messages_hint_suffix.png +0 -0
- {screenshot_vision_algorithm-0.3.8 → screenshot_vision_algorithm-0.3.10}/src/screenshot_vision_algorithm/android/wechat/templates/android/8.0.69/unread_divider_hint.png +0 -0
- {screenshot_vision_algorithm-0.3.8 → screenshot_vision_algorithm-0.3.10}/src/screenshot_vision_algorithm/android/wechat/templates/android/8.0.69/unread_divider_hint_v2_textonly.png +0 -0
- {screenshot_vision_algorithm-0.3.8 → screenshot_vision_algorithm-0.3.10}/src/screenshot_vision_algorithm/android/wechat/templates/android/8.0.69/wechat_note_header.png +0 -0
- {screenshot_vision_algorithm-0.3.8 → screenshot_vision_algorithm-0.3.10}/src/screenshot_vision_algorithm/android/xhs/__init__.py +0 -0
- {screenshot_vision_algorithm-0.3.8 → screenshot_vision_algorithm-0.3.10}/src/screenshot_vision_algorithm/android/zhihu/__init__.py +0 -0
- {screenshot_vision_algorithm-0.3.8 → screenshot_vision_algorithm-0.3.10}/src/screenshot_vision_algorithm/logging.py +0 -0
- {screenshot_vision_algorithm-0.3.8 → screenshot_vision_algorithm-0.3.10}/src/screenshot_vision_algorithm/png_utils.py +0 -0
- {screenshot_vision_algorithm-0.3.8 → screenshot_vision_algorithm-0.3.10}/src/screenshot_vision_algorithm.egg-info/SOURCES.txt +0 -0
- {screenshot_vision_algorithm-0.3.8 → screenshot_vision_algorithm-0.3.10}/src/screenshot_vision_algorithm.egg-info/dependency_links.txt +0 -0
- {screenshot_vision_algorithm-0.3.8 → screenshot_vision_algorithm-0.3.10}/src/screenshot_vision_algorithm.egg-info/requires.txt +0 -0
- {screenshot_vision_algorithm-0.3.8 → screenshot_vision_algorithm-0.3.10}/src/screenshot_vision_algorithm.egg-info/top_level.txt +0 -0
- {screenshot_vision_algorithm-0.3.8 → screenshot_vision_algorithm-0.3.10}/tests/test_card_bbox.py +0 -0
- {screenshot_vision_algorithm-0.3.8 → screenshot_vision_algorithm-0.3.10}/tests/test_package.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: screenshot_vision_algorithm
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.10
|
|
4
4
|
Summary: Multi-platform screenshot vision algorithms: WeChat (card bbox, speaker bands, avatar detection, OCR helpers), XHS & Zhihu (planned)
|
|
5
5
|
License: MIT
|
|
6
6
|
Requires-Python: >=3.10
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "screenshot_vision_algorithm"
|
|
7
|
-
version = "0.3.
|
|
7
|
+
version = "0.3.10"
|
|
8
8
|
description = "Multi-platform screenshot vision algorithms: WeChat (card bbox, speaker bands, avatar detection, OCR helpers), XHS & Zhihu (planned)"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = { text = "MIT" }
|
|
@@ -221,6 +221,7 @@ def build_prd_speaker_vertical_bands(
|
|
|
221
221
|
scale_w: float,
|
|
222
222
|
first_avatar_gap_reject_baseline: int = CHAT_BAND_FIRST_AVATAR_TOP_GAP_REJECT_BASELINE,
|
|
223
223
|
first_band_top_extend_baseline: int = CHAT_FIRST_BAND_TOP_EXTEND_BASELINE,
|
|
224
|
+
avatar_merge_min_sep_baseline: int = 24,
|
|
224
225
|
) -> PrdChatVerticalLayout:
|
|
225
226
|
"""由时间序头像顶构造 PRD §5 顶隙 orphan + 左闭右开发言人筒。
|
|
226
227
|
|
|
@@ -248,7 +249,7 @@ def build_prd_speaker_vertical_bands(
|
|
|
248
249
|
|
|
249
250
|
# 时间轴序去重:过近视为同一人头像重复检出
|
|
250
251
|
merged_starts: list[int] = []
|
|
251
|
-
min_sep = int(round(
|
|
252
|
+
min_sep = int(round(int(avatar_merge_min_sep_baseline) * sw))
|
|
252
253
|
for e in timeline:
|
|
253
254
|
y = int(e.y_top)
|
|
254
255
|
if not merged_starts or y - merged_starts[-1] >= min_sep:
|
|
@@ -230,6 +230,32 @@ class NicknameOcrConfig:
|
|
|
230
230
|
"""Prefix / substring tags that exclude a block from nickname
|
|
231
231
|
consideration even if all geometric criteria pass."""
|
|
232
232
|
|
|
233
|
+
# ── 以下字段可由 rules_config.yaml 覆盖(housekeeping 胶水层读 yaml → 灌参)──
|
|
234
|
+
|
|
235
|
+
skip_block_patterns: tuple[str, ...] = ()
|
|
236
|
+
"""附加正则列表,逐条编译后传递给 ``_should_skip_block``。
|
|
237
|
+
内置正则(时间戳/纯数字/系统提示等)**始终并行生效**,
|
|
238
|
+
config 提供的是追加规则,不替代内置逻辑。"""
|
|
239
|
+
|
|
240
|
+
inside_y_tolerance_px: float = 4.0
|
|
241
|
+
"""``_completely_inside`` 的 Y 方向容差(px @ 1080 基准 × scale_w)。
|
|
242
|
+
默认 4.0 与 ``card_binding.inside_y_tolerance_px`` 对齐。"""
|
|
243
|
+
|
|
244
|
+
cross_band_distance_threshold_px: float = 50.0
|
|
245
|
+
"""Step C 跨 band 距离门控基线(px @ 1080 × scale_w)。
|
|
246
|
+
文字底部到卡片所属 speaker_band 顶部超过此值则不作为昵称。"""
|
|
247
|
+
|
|
248
|
+
# ── speaker_band 参数(同名传给 build_prd_speaker_vertical_bands)──
|
|
249
|
+
|
|
250
|
+
first_avatar_gap_reject_baseline: int = 30
|
|
251
|
+
"""orphan 间隙阈值(px @ 1080)。"""
|
|
252
|
+
|
|
253
|
+
first_band_top_extend_baseline: int = 20
|
|
254
|
+
"""首个 band 上移量(px @ 1080)。"""
|
|
255
|
+
|
|
256
|
+
avatar_merge_min_sep_px: int = 24
|
|
257
|
+
"""头像合并最小间距(px @ 1080 × scale_w)。"""
|
|
258
|
+
|
|
233
259
|
|
|
234
260
|
_ATTRIBUTION_PREFIX_DROPS: tuple[str, ...] = (
|
|
235
261
|
"撤回了一条消息",
|
|
@@ -710,7 +736,12 @@ def _load_prd_layout_optional(
|
|
|
710
736
|
bounds = compute_chat_content_vertical_bounds(arr, sw, screen_h=oh)
|
|
711
737
|
ly, ry = detect_chat_side_avatar_ytops(arr, sw, bounds)
|
|
712
738
|
timeline = merge_avatar_ytops_time_order(ly, ry)
|
|
713
|
-
return build_prd_speaker_vertical_bands(
|
|
739
|
+
return build_prd_speaker_vertical_bands(
|
|
740
|
+
timeline, bounds, scale_w=sw,
|
|
741
|
+
first_avatar_gap_reject_baseline=config.first_avatar_gap_reject_baseline,
|
|
742
|
+
first_band_top_extend_baseline=config.first_band_top_extend_baseline,
|
|
743
|
+
avatar_merge_min_sep_baseline=config.avatar_merge_min_sep_px,
|
|
744
|
+
)
|
|
714
745
|
|
|
715
746
|
|
|
716
747
|
def _finalize_prd_attribution(
|
|
@@ -887,7 +918,7 @@ def _resume_thumb_bindings_and_orphans(
|
|
|
887
918
|
# OCR bbox 与卡片 bbox 各有 ±2~3px 抖动:卡内标题行可能比卡顶高出 1~3px,
|
|
888
919
|
# 若按严格包含判定会被误认为"卡外文字"而误绑为昵称(2026-06-11 真实案例)。
|
|
889
920
|
# 真昵称行整体位于卡片上方(y2 < 卡顶),不受此容差影响。
|
|
890
|
-
_inside_tol =
|
|
921
|
+
_inside_tol = float(config.inside_y_tolerance_px) * max(scale_w, 1.0)
|
|
891
922
|
|
|
892
923
|
def _completely_inside(block_bbox: tuple, card_bbox: tuple) -> bool:
|
|
893
924
|
bx1, by1, bx2, by2 = block_bbox
|
|
@@ -917,8 +948,25 @@ def _resume_thumb_bindings_and_orphans(
|
|
|
917
948
|
return True
|
|
918
949
|
if _is_favorite_card_label(t):
|
|
919
950
|
return True
|
|
951
|
+
# ── 附加正则(来自 rules_config.yaml skip_patterns,编译后缓存)──
|
|
952
|
+
if _compiled_skip_patterns:
|
|
953
|
+
for _pat in _compiled_skip_patterns:
|
|
954
|
+
try:
|
|
955
|
+
if _pat.search(t):
|
|
956
|
+
return True
|
|
957
|
+
except Exception:
|
|
958
|
+
continue
|
|
920
959
|
return False
|
|
921
960
|
|
|
961
|
+
# ── 编译 config 追加的正则(函数内缓存,避免每次 block 重新编译)──
|
|
962
|
+
_compiled_skip_patterns: list[re.Pattern] = []
|
|
963
|
+
if config.skip_block_patterns:
|
|
964
|
+
for p in config.skip_block_patterns:
|
|
965
|
+
try:
|
|
966
|
+
_compiled_skip_patterns.append(re.compile(p))
|
|
967
|
+
except re.error:
|
|
968
|
+
pass
|
|
969
|
+
|
|
922
970
|
bindings: list[ResumeThumbBinding] = []
|
|
923
971
|
orphan = 0
|
|
924
972
|
excluded_indices: set[int] = set()
|
|
@@ -1068,14 +1116,14 @@ def _resume_thumb_bindings_and_orphans(
|
|
|
1068
1116
|
|
|
1069
1117
|
if best_i is not None:
|
|
1070
1118
|
# PRD §B.1 C:距离检查——文字底部到卡片所属 speaker_band 顶部
|
|
1071
|
-
# 超过阈值(
|
|
1119
|
+
# 超过阈值(config.cross_band_distance_threshold_px × scale_w)则不作为昵称
|
|
1072
1120
|
_use_as_nickname = True
|
|
1073
1121
|
if band_idx is not None and band_idx >= 0:
|
|
1074
1122
|
_sb_list = getattr(layout_opt, "speaker_bands", ())
|
|
1075
1123
|
if band_idx < len(_sb_list):
|
|
1076
1124
|
_band_y0 = float(_sb_list[band_idx][0])
|
|
1077
1125
|
_gap = _band_y0 - best_bottom # positive → block above band
|
|
1078
|
-
_threshold =
|
|
1126
|
+
_threshold = float(config.cross_band_distance_threshold_px) * float(scale_w)
|
|
1079
1127
|
if _gap > _threshold:
|
|
1080
1128
|
_use_as_nickname = False
|
|
1081
1129
|
if _use_as_nickname:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: screenshot_vision_algorithm
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.10
|
|
4
4
|
Summary: Multi-platform screenshot vision algorithms: WeChat (card bbox, speaker bands, avatar detection, OCR helpers), XHS & Zhihu (planned)
|
|
5
5
|
License: MIT
|
|
6
6
|
Requires-Python: >=3.10
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{screenshot_vision_algorithm-0.3.8 → screenshot_vision_algorithm-0.3.10}/tests/test_card_bbox.py
RENAMED
|
File without changes
|
{screenshot_vision_algorithm-0.3.8 → screenshot_vision_algorithm-0.3.10}/tests/test_package.py
RENAMED
|
File without changes
|