滑块匹配算法 Args: target_image: 滑块图片 background_image: 背景图片 simple_target: 是否为简单滑块 Returns: 匹配结果字典,包含target坐标 Raises: ImageProcessError: 当图像处理失败时
(self, target_image: Union[bytes, str, Image.Image],
background_image: Union[bytes, str, Image.Image],
simple_target: bool = False)
| 43 | raise NotImplementedError("请使用slide_match或slide_comparison方法") |
| 44 | |
| 45 | def slide_match(self, target_image: Union[bytes, str, Image.Image], |
| 46 | background_image: Union[bytes, str, Image.Image], |
| 47 | simple_target: bool = False) -> Dict[str, Any]: |
| 48 | """ |
| 49 | 滑块匹配算法 |
| 50 | |
| 51 | Args: |
| 52 | target_image: 滑块图片 |
| 53 | background_image: 背景图片 |
| 54 | simple_target: 是否为简单滑块 |
| 55 | |
| 56 | Returns: |
| 57 | 匹配结果字典,包含target坐标 |
| 58 | |
| 59 | Raises: |
| 60 | ImageProcessError: 当图像处理失败时 |
| 61 | """ |
| 62 | # 验证输入 |
| 63 | validate_image_input(target_image) |
| 64 | validate_image_input(background_image) |
| 65 | |
| 66 | try: |
| 67 | # 加载图像 |
| 68 | target_pil = load_image_from_input(target_image) |
| 69 | background_pil = load_image_from_input(background_image) |
| 70 | |
| 71 | # 转换为numpy数组 |
| 72 | target_array = image_to_numpy(target_pil, 'RGB') |
| 73 | background_array = image_to_numpy(background_pil, 'RGB') |
| 74 | |
| 75 | # 执行匹配 |
| 76 | result = self._perform_slide_match(target_array, background_array, simple_target) |
| 77 | |
| 78 | return result |
| 79 | |
| 80 | except Exception as e: |
| 81 | raise ImageProcessError(f"滑块匹配失败: {str(e)}") from e |
| 82 | |
| 83 | def slide_comparison(self, target_image: Union[bytes, str, Image.Image], |
| 84 | background_image: Union[bytes, str, Image.Image]) -> Dict[str, Any]: |
nothing calls this directly
no test coverage detected