MCPcopy
hub / github.com/sml2h3/ddddocr / _perform_slide_match

Method _perform_slide_match

ddddocr/core/slide_engine.py:119–147  ·  view source on GitHub ↗

执行滑块匹配 Args: target: 滑块图像数组 background: 背景图像数组 simple_target: 是否为简单滑块 Returns: 匹配结果

(self, target: np.ndarray, background: np.ndarray, 
                           simple_target: bool)

Source from the content-addressed store, hash-verified

117 raise ImageProcessError(f"滑块比较失败: {str(e)}") from e
118
119 def _perform_slide_match(self, target: np.ndarray, background: np.ndarray,
120 simple_target: bool) -> Dict[str, Any]:
121 """
122 执行滑块匹配
123
124 Args:
125 target: 滑块图像数组
126 background: 背景图像数组
127 simple_target: 是否为简单滑块
128
129 Returns:
130 匹配结果
131 """
132 try:
133 # 转换为灰度图
134 target_gray = cv2.cvtColor(target, cv2.COLOR_RGB2GRAY)
135 background_gray = cv2.cvtColor(background, cv2.COLOR_RGB2GRAY)
136
137 if simple_target:
138 # 简单滑块匹配
139 result = self._simple_template_match(target_gray, background_gray)
140 else:
141 # 复杂滑块匹配(边缘检测)
142 result = self._edge_based_match(target_gray, background_gray)
143
144 return result
145
146 except Exception as e:
147 raise ImageProcessError(f"滑块匹配执行失败: {str(e)}") from e
148
149 def _perform_slide_comparison(self, target: np.ndarray, background: np.ndarray) -> Dict[str, Any]:
150 """

Callers 1

slide_matchMethod · 0.95

Calls 3

_edge_based_matchMethod · 0.95
ImageProcessErrorClass · 0.85

Tested by

no test coverage detected