DX 验证码(关注参数即可)¶
本模块支持多种 DX 验证码类型的识别, 只需关注各类型的输入参数格式与识别效果.
注意:本模块仅提供 DX 验证码的识别功能.
面积验证¶
decode_captcha
¶
decode_captcha(
bg: Union[str, Path, Image, ndarray, bytes],
show: bool = True,
) -> tuple[str, Optional[Image.Image]]
解码 DX Area 验证码,找到图像的面积区域最大的中心点.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bg
|
Union[str, Path, Image, ndarray, bytes]
|
背景图,可以是路径、PIL对象、OpenCV图像或原始字节。 |
required |
show
|
bool
|
是否返回可视化图像。默认为 True。 |
True
|
Returns:
| Type | Description |
|---|---|
tuple[str, Optional[Image]]
|
返回中心点坐标和处理后的图像
|

文字点选¶
decode_captcha
¶
decode_captcha(
bg: Union[str, Path, Image, ndarray, bytes],
cw: str,
show: bool = True,
) -> tuple[str, Optional[Image.Image]]
解码 DX Click 验证码,根据文字内容找到点击点
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bg
|
Union[str, Path, Image, ndarray, bytes]
|
背景图,可以是路径、PIL对象、OpenCV图像或原始字节。 |
required |
cw
|
str
|
验证码内容, 字符串 |
required |
show
|
bool
|
是否返回可视化图像。默认为 True。 |
True
|
Returns:
| Type | Description |
|---|---|
tuple[str, Optional[Image]]
|
返回点击点坐标和处理后的图像
|

差异点击¶
decode_captcha
¶
decode_captcha(
bg: Union[str, Path, Image, ndarray, bytes],
show: bool = True,
) -> tuple[str, Optional[Image.Image]]
解码 DX 差异点击 验证码,找到图像中最不同的图片的中心点.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bg
|
Union[str, Path, Image, ndarray, bytes]
|
背景图,可以是路径、PIL对象、OpenCV图像或原始字节。 |
required |
show
|
bool
|
是否返回可视化图像。默认为 True。 |
True
|
Returns:
| Type | Description |
|---|---|
tuple[str, Optional[Image]]
|
返回最不同的图片中心坐标和处理后的图像
|

字体识别¶
decode_captcha
¶
decode_captcha(
bg: Union[str, Path, Image, ndarray, bytes],
show: bool = True,
) -> tuple[str, Optional[Image.Image]]
解码 DX 字体识别 验证码,找到图像中与其他字体不同的字符的坐标.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bg
|
Union[str, Path, Image, ndarray, bytes]
|
背景图,可以是路径、PIL对象、OpenCV图像或原始字节。 |
required |
show
|
bool
|
是否返回可视化图像。默认为 True。 |
True
|
Returns:
| Type | Description |
|---|---|
tuple[str, Optional[Image]]
|
返回点击点坐标和处理后的图像
|

图标点选¶
decode_captcha
¶
decode_captcha(
bg: Union[str, Path, Image, ndarray, bytes],
fg: Sequence[Union[str, Path, Image, ndarray, bytes]],
show: bool = True,
) -> tuple[str, Optional[Image.Image]]
解码DX 图标验证码,返回点击点坐标
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bg
|
Union[str, Path, Image, ndarray, bytes]
|
背景图片路径或PIL图像对象 (底图) |
required |
fg
|
Sequence[Union[str, Path, Image, ndarray, bytes]]
|
前景图片路径或PIL图像对象 (按顺序的图标) |
required |
show
|
bool
|
是否显示处理后的图片,默认为True |
True
|
Returns:
| Type | Description |
|---|---|
tuple[str, Optional[Image]]
|
返回点击点坐标和处理后的图像
|
![]()
语序点选¶
decode_captcha
¶
decode_captcha(
bg: Union[str, Path, Image, ndarray, bytes],
show: bool = True,
) -> tuple[str, Optional[Image.Image]]
解码 DX 语序验证码,根据图片内容,自动检测点击点
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bg
|
Union[str, Path, Image, ndarray, bytes]
|
背景图,可以是路径、PIL对象、OpenCV图像或原始字节。 |
required |
show
|
bool
|
是否返回可视化图像。默认为 True。 |
True
|
Returns:
| Type | Description |
|---|---|
tuple[str, Optional[Image]]
|
返回点击点坐标和处理后的图像
|

滑动还原¶
decode_captcha
¶
decode_captcha(
bg: Union[str, Path, Image, ndarray, bytes],
split_y: int,
show: bool = True,
) -> tuple[str, Optional[Image.Image]]
解码 DX 滑动还原 验证码, 通过分割图像并寻找最佳平移量来对齐上下部分。
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bg
|
Union[str, Path, Image, ndarray, bytes]
|
背景图,可以是路径、PIL对象、OpenCV图像或原始字节. |
required |
split_y
|
int
|
分割位置的 y 坐标,用于分割上下图像(由 dx 系统给出). |
required |
show
|
bool
|
是否返回可视化图像。默认为 True. |
True
|
Returns:
| Type | Description |
|---|---|
tuple[str, Optional[Image]]
|
返回平移的距离和处理后的图像
|

旋转验证¶
decode_captcha
¶
decode_captcha(
bg: Union[str, Path, Image, ndarray, bytes],
fg: Union[str, Path, Image, ndarray, bytes],
method: str = "1",
show: bool = True,
) -> tuple[str, Optional[Image.Image]]
解码 DX 旋转验证码,找到最佳旋转角度并返回叠加图像。
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bg
|
Union[str, Path, Image, ndarray, bytes]
|
背景图,可以是路径、PIL对象、OpenCV图像或原始字节。 |
required |
fg
|
Union[str, Path, Image, ndarray, bytes]
|
前景图,可以是路径、PIL对象、OpenCV图像或原始字节。 |
required |
method
|
str
|
哈希方法, 1 代表使用 imagehash.phash, 2代表使用自定义的 phash。默认为 "1"。 |
'1'
|
show
|
bool
|
是否返回可视化图像。默认为 True。 |
True
|
Returns:
| Type | Description |
|---|---|
tuple[str, Optional[Image]]
|
返回最佳旋转角度和处理后的图像
|

刮刮卡验证¶
decode_captcha
¶
decode_captcha(
bg: Union[str, Path, Image, ndarray, bytes],
show: bool = True,
) -> tuple[str, Optional[Image.Image]]
识别刮刮卡验证码
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bg
|
Union[str, Path, Image, ndarray, bytes]
|
背景图,可以是路径、PIL对象、OpenCV图像或原始字节。 |
required |
show
|
bool
|
是否返回可视化图像。默认为 True。 |
True
|
Returns:
| Type | Description |
|---|---|
tuple[str, Optional[Image]]
|
返回识别结果和处理后的图像
|

乱序拼图¶
decode_captcha
¶
decode_captcha(
bg: Union[str, Path, Image, ndarray, bytes],
show: bool = True,
) -> tuple[str, Optional[Image.Image]]
识别 DX 乱序拼图验证码, 返回需要交换的索引对(行优先序)以及重建后的图像。
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bg
|
Union[str, Path, Image, ndarray, bytes]
|
背景图,可以是路径、PIL对象、OpenCV图像或原始字节。 |
required |
show
|
bool
|
是否返回可视化图像。默认为 True。 |
True
|
Returns:
| Type | Description |
|---|---|
tuple[str, Optional[Image]]
|
返回识别结果和处理后的图像
|

滑块验证¶
decode_captcha
¶
decode_captcha(
bg: Union[str, Path, Image, ndarray, bytes],
fg: Union[str, Path, Image, ndarray, bytes],
show: bool = True,
method: str = "3",
) -> tuple[str, Optional[Image.Image]]
解码 DX 滑块验证码,返回滑块位置并在背景图上画出滑块位置
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bg
|
Union[str, Path, Image, ndarray, bytes]
|
背景图片路径或PIL图像对象 (底图) |
required |
fg
|
Union[str, Path, Image, ndarray, bytes]
|
前景图片路径或PIL图像对象 (按顺序的图标) |
required |
show
|
bool
|
是否显示处理后的图片,默认为True |
True
|
method
|
str
|
滑块位置计算方法,默认为 "3",可选 "1" (SlideCrack), "2" (ddddocr), "3" (SlideMatcher) |
'3'
|
Returns:
| Type | Description |
|---|---|
tuple[str, Optional[Image]]
|
返回滑块位置和处理后的图像
|

空间语义¶
decode_captcha
¶
decode_captcha(
bg: Union[str, Path, Image, ndarray, bytes],
verifyType: Union[int, str],
childVerifyType: Union[int, str],
color: Optional[str] = None,
imgName: Optional[str] = None,
show: bool = True,
) -> tuple[str, Optional[Image.Image]]
解码 DX 空间语义验证码,返回物体的中心点坐标并在背景图上画出物体位置
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bg
|
Union[str, Path, Image, ndarray, bytes]
|
背景图片路径或PIL图像对象 (底图) |
required |
verifyType
|
Union[int, str]
|
验证类型,可以是整数或字符串, 这些值由 dx 系统给出 |
required |
childVerifyType
|
Union[int, str]
|
子验证类型,可以是整数或字符串, 这些值由 dx 系统给出 |
required |
color
|
Optional[str]
|
颜色,仅在某些条件下才需要,如 verifyType=1 时, 这些值由 dx 系统给出 |
None
|
imgName
|
Optional[str]
|
物体名称,仅在某些条件下才需要,如 verifyType=1 时, 这些值由 dx 系统给出 |
None
|
show
|
bool
|
是否显示处理后的图片,默认为 True,如果为 False,则只返回中心点坐标 |
True
|
Returns:
| Type | Description |
|---|---|
tuple[str, Optional[Image]]
|
返回物体的中心点坐标和处理后的图像
|
