MCPcopy Create free account
hub / github.com/VitoHowe/glm-coding / is_ignored_item

Function is_ignored_item

app/services/tenvision_adapter.py:254–278  ·  view source on GitHub ↗
(item, prompt_item, image_h, image_w)

Source from the content-addressed store, hash-verified

252 return True
253 if any(keyword in text for keyword in ('AI', '确定', '安全验证', '生成背景')):
254 return True
255 if len(extract_chinese_chars(text)) == 0:
256 return True
257 x, y, w, h = item['bbox']
258 if prompt_item is not None:
259 # IOU 过滤:与提示文本区域重叠
260 if bbox_iou(item['bbox'], prompt_item['bbox']) > 0.05:
261 return True
262 # Y 区间重叠过滤:与提示文本在同一行的字符均排除
263 px, py, pw, ph = prompt_item['bbox']
264 item_y2 = y + h
265 prompt_y2 = py + ph
266 if y < prompt_y2 and item_y2 > py:
267 return True
268 # 顶部宽文本过滤(覆盖 prompt_item 为 None 的降级情形)
269 if y < int(image_h * 0.22) and w > int(image_w * 0.18) and '请' not in text:
270 return True
271 return False
272
273
274def build_color_masks(crop):
275 gray = cv2.cvtColor(crop, cv2.COLOR_BGR2GRAY)
276 hsv = cv2.cvtColor(crop, cv2.COLOR_BGR2HSV)
277
278 dark_mask = (gray < max(190, int(np.percentile(gray, 55)))).astype(np.uint8) * 255
279 yellow_mask = (
280 (hsv[:, :, 0] >= 8)
281 & (hsv[:, :, 0] <= 55)

Callers 1

build_candidate_charsFunction · 0.85

Calls 2

extract_chinese_charsFunction · 0.85
bbox_iouFunction · 0.85

Tested by

no test coverage detected