← 返回 Skills 市场
liudengkui

ocr-passport-xiangyun

作者 liudengkui · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ⚠ pending
46
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install ocr-passport-xiangyun
功能描述
Xiangyun Platform Passport OCR Skill. Calls the Xiangyun API to perform structured recognition of passports from images, extracting fields such as passport n...
使用说明 (SKILL.md)

Xiangyun Passport OCR

Overview

Leverages the Xiangyun Open Platform ID Document Recognition API to parse passport images structurally, supporting both Chinese and international passports. Recognized fields include: passport number, name, name (pinyin), sex, date of birth, place of birth, date of issue, expiry date, issuing authority, nationality, and more.

Product page: https://www.netocr.com/products.html


Triggers

The following user expressions should trigger this skill:

  • "passport OCR", "passport recognition", "recognize passport"
  • "extract passport info", "parse passport", "scan passport"
  • "read passport", "passport data extraction"
  • "Xiangyun passport", "netocr passport"
  • "OCR this passport", "identify passport"

Workflow

Step 1: Load Configuration

Invoke scripts/config_manager.py to read the configuration:

python scripts/config_manager.py load
  • Config file location: config.json in the skill root directory
  • If the config file exists and contains valid key and secret, skip to Step 3
  • If the config file is missing or fields are empty, proceed to Step 2

Step 2: First-Time Setup (on missing config)

Inform the user:

"Please sign up on the Xiangyun Platform (https://www.netocr.com), navigate to your account dashboard to obtain your ocrKey and ocrSecret, then provide them to me to complete the setup."

Once the key and secret are received:

python scripts/config_manager.py save --key YOUR_KEY --secret YOUR_SECRET

This saves the credentials to config.json in the skill root:

{
  "key": "user's ocrKey",
  "secret": "user's ocrSecret"
}

Step 3: Accept Image Input

Supported input methods:

Method Description
Local file path User provides an absolute or relative path
Base64 string User pastes Base64-encoded data directly
URL (→ Base64) Download image first, then convert to Base64

Step 4: Call Recognition API

Run the recognition script:

# Local file (recommended — auto-saves results alongside the image)
python scripts/recognize.py --file /path/to/passport.jpg

# Base64 input
python scripts/recognize.py --base64 "BASE64_STRING_HERE"

# Human-readable table output
python scripts/recognize.py --file /path/to/passport.jpg --output-format table

# Disable auto-save (default: saves as {image_name}.json)
python scripts/recognize.py --file /path/to/passport.jpg --no-save

On success, results are automatically saved as {image_name}.json next to the source image, avoiding repeated API calls for later exports.

API parameters:

Parameter Value Description
typeId 13 Fixed value for passport recognition — do not change
format json Return JSON format
key User credential Loaded from config.json
secret User credential Loaded from config.json

Base64 endpoint: POST https://netocr.com/api/recogliu.do File upload endpoint: POST https://netocr.com/api/recog.do

Step 5: Format & Display Results

On success, display results as a table:

✅ Passport recognition successful

| Field              | Value                    |
|--------------------|--------------------------|
| Passport Number    | E12345678                |
| Name               | ZHANG SAN                |
| Pinyin             | ZHANG SAN                |
| Sex                | Male                     |
| Date of Birth      | 1990-01-01               |
| Place of Birth     | Beijing                  |
| Date of Issue      | 2020-06-01               |
| Expiry Date        | 2030-06-01               |
| Issuing Authority  | NIA                      |
| Nationality        | China                    |

Step 6: Export Results (on-demand only)

Only perform this step when the user explicitly requests exporting, saving, or generating a file.

Trigger examples: "export results", "save as Excel", "generate CSV", "export"

Prefer --from-dir to export directly from cached JSON results — zero API consumption.

# Recommended: read cached JSON results from image directory (no API calls)
python scripts/export.py --from-dir /path/to/images --format excel --output result.xlsx
python scripts/export.py --from-dir /path/to/images --format csv --output result.csv

# Pipe mode (recognize then export — for uncached results)
python scripts/recognize.py --file passport.jpg | python scripts/export.py --format csv --output result.csv

# Specific JSON file
python scripts/export.py --input result.json --format excel --output result.xlsx

Export priority: --from-dir > --batch-input > --input > stdin


Error Handling

Error Code Meaning Action
-1 Recognition failed (poor image quality / no passport detected) Ask user for a clearer passport image
-2 Parameter error Check request parameters
-3 Insufficient service quota Advise user to top up on Xiangyun Platform
-4 Authentication failed Prompt user to verify key/secret and reconfigure
-5 Insufficient balance Advise user to top up their Xiangyun account
CONFIG_MISSING Credentials not configured Guide user through first-time setup

On authentication failure, prompt the user to reset:

python scripts/config_manager.py reset

Image Requirements

Type Recommended Specs
Photo ~200 KB, 24-bit color depth or higher
Scanned 300 DPI, file size \x3C 3 MB
Format JPG, PNG, BMP
  • Place the passport flat and avoid glare or obstructions
  • Ensure text is legible with adequate contrast

Important Notes

  • typeId is fixed at 13 — do not modify when calling the API
  • config.json is stored in the skill directory and contains sensitive credentials; do not commit to version control
  • Always read config.json before each run to avoid repeatedly asking for credentials
  • Recognition results are auto-cached as {image_name}.json alongside the source image; exports read from cache without additional API calls
  • File export is only triggered on explicit user request — never auto-export
  • This skill is fully self-contained and runs on any platform with Python 3.x; no host-specific dependencies

Resources

scripts/

  • config_manager.py — Read, write, and reset configuration files
  • recognize.py — Call the Xiangyun API to perform passport OCR
  • export.py — Export recognition results to CSV / Excel / JSON

references/

  • api_docs.md — Complete Xiangyun Passport Recognition API reference (request parameters, response format, sample code)

Cooperation Opportunities

Public cloud sales hotline (server version OCR recognition software): Manager Yin [13810080484] [[email protected]]

如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install ocr-passport-xiangyun
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /ocr-passport-xiangyun 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
Initial release of ocr-passport-xiangyun skill. - Structured OCR extraction for passports using Xiangyun API, supporting Chinese and international documents. - Accepts passport images via local file, Base64 input, or URL. - Guides users through first-time API credential setup and persists configuration securely. - Automatically saves OCR JSON results next to uploaded images; supports table-formatted output. - Provides explicit, on-demand export to Excel/CSV from cached results. - Handles error codes and credential issues with clear prompts. - Works cross-platform with Python 3.x and requires no host-specific dependencies.
元数据
Slug ocr-passport-xiangyun
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

ocr-passport-xiangyun 是什么?

Xiangyun Platform Passport OCR Skill. Calls the Xiangyun API to perform structured recognition of passports from images, extracting fields such as passport n... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 46 次。

如何安装 ocr-passport-xiangyun?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install ocr-passport-xiangyun」即可一键安装,无需额外配置。

ocr-passport-xiangyun 是免费的吗?

是的,ocr-passport-xiangyun 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

ocr-passport-xiangyun 支持哪些平台?

ocr-passport-xiangyun 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 ocr-passport-xiangyun?

由 liudengkui(@liudengkui)开发并维护,当前版本 v1.0.0。

💬 留言讨论