TrafficEye License Plate Reader
Use this skill when the user wants to read a license plate from an image with the TrafficEye API.
What This Skill Does
- 1. Accepts a local image path.
- Uploads the image to the TrafficEye recognition API.
- Optionally sends a
request form field if TRAFFICEYE_REQUEST_JSON is configured. - Parses the API response.
- Picks the largest detected plate by polygon area.
- Returns the full selected plate payload to the user, including text, type (country), dimension, scores, occlusion, unreadable, and position.
Expected Input
- - A local image file path.
- If the user supplied an attachment instead of a path, first resolve it to a local file path and then run the helper.
Default Runtime Assumptions
- - The API endpoint defaults to
https://trafficeye.ai/recognition. - The default request payload is
{"tasks":["DETECTION","OCR"],"requestedDetectionTypes":["BOX","PLATE"]}. - The default API-key transport matches the TrafficEye public API example: header mode with header name
apikey. - Auth and request fields remain configurable in case your deployment differs.
Environment Variables
- -
TRAFFICEYE_API_KEY: required unless passed explicitly to the helper. - INLINECODE6 : optional, defaults to
https://trafficeye.ai/recognition. - INLINECODE8 : one of
header, bearer, form, query. Default: header. - INLINECODE14 : key name for
header, form, or query mode. Default: apikey. - INLINECODE19 : multipart field for the image. Default:
file. - INLINECODE21 : multipart field for the JSON request. Default:
request. - INLINECODE23 : JSON string to include as the request field. By default this is
{"tasks":["DETECTION","OCR"],"requestedDetectionTypes":["BOX","PLATE"]}. - INLINECODE25 : optional timeout in seconds. Default:
30.
How To Run
Setup your API key:
CODEBLOCK0
Use the bundled helper:
CODEBLOCK1
For structured output:
CODEBLOCK2
If the deployment expects Bearer auth:
CODEBLOCK3
If the deployment needs an explicit request payload:
CODEBLOCK4
Equivalent to the documented public API example:
CODEBLOCK5
Agent Workflow
- 1. Verify that the image path exists.
- Run
python3 recognize_plate.py <image-path> --format json. - Present the full selected plate payload to the user, especially
text, type, dimension, occlusion, unreadable, and position. - If the API returns no readable text, explain that the largest plate was found but OCR text was missing.
- If authentication fails, ask the user which auth mode their deployment expects and retry with the matching environment variables.
Offline Validation
You can validate the selection logic without calling the API:
CODEBLOCK6
Notes
- - The helper intentionally chooses the largest plate by geometric area, not by detection confidence.
- The response parser first checks
combinations[].roadUsers[].plates[], then also supports roadUsers[].plates[], top-level plates[], and nested plate payloads discovered recursively. - The default request and auth header mirror the public example at
https://www.trafficeye.ai/api. - The selected result now includes the original plate payload from the API so country/type and all scores are preserved.
TrafficEye 车牌识别器
当用户想要通过 TrafficEye API 从图像中读取车牌时,使用此技能。
该技能的功能
- 1. 接受本地图像路径。
- 将图像上传至 TrafficEye 识别 API。
- 如果配置了 TRAFFICEYEREQUESTJSON,则可选地发送 request 表单字段。
- 解析 API 响应。
- 根据多边形面积选择检测到的最大车牌。
- 向用户返回完整的选定车牌数据,包括文本、类型(国家)、尺寸、分数、遮挡、不可读和位置。
预期输入
- - 本地图像文件路径。
- 如果用户提供了附件而非路径,则先将其解析为本地文件路径,然后运行辅助程序。
默认运行时假设
- - API 端点默认为 https://trafficeye.ai/recognition。
- 默认请求负载为 {tasks:[DETECTION,OCR],requestedDetectionTypes:[BOX,PLATE]}。
- 默认 API 密钥传输方式与 TrafficEye 公共 API 示例一致:标头模式,标头名称为 apikey。
- 认证和请求字段保持可配置,以适应不同的部署环境。
环境变量
- - TRAFFICEYEAPIKEY:必需,除非显式传递给辅助程序。
- TRAFFICEYEAPIURL:可选,默认为 https://trafficeye.ai/recognition。
- TRAFFICEYEAPIKEYMODE:可选值为 header、bearer、form、query。默认为 header。
- TRAFFICEYEAPIKEYNAME:用于 header、form 或 query 模式的密钥名称。默认为 apikey。
- TRAFFICEYEFILEFIELD:图像的多部分字段。默认为 file。
- TRAFFICEYEREQUESTFIELD:JSON 请求的多部分字段。默认为 request。
- TRAFFICEYEREQUESTJSON:作为请求字段包含的 JSON 字符串。默认值为 {tasks:[DETECTION,OCR],requestedDetectionTypes:[BOX,PLATE]}。
- TRAFFICEYETIMEOUTS:可选超时时间(秒)。默认为 30。
运行方法
设置您的 API 密钥:
bash
export TRAFFICEYEAPIKEY=YOURREALKEY
使用捆绑的辅助程序:
bash
python3 recognize_plate.py /absolute/path/to/image.jpg
如需结构化输出:
bash
python3 recognize_plate.py /absolute/path/to/image.jpg --format json
如果部署环境需要 Bearer 认证:
bash
TRAFFICEYEAPIKEYMODE=bearer python3 recognizeplate.py /absolute/path/to/image.jpg
如果部署环境需要显式请求负载:
bash
TRAFFICEYEREQUESTJSON={requestedDetectionTypes:[PLATE]} python3 recognize_plate.py /absolute/path/to/image.jpg --format json
等同于文档中的公共 API 示例:
bash
curl -X POST \
-H Content-Type: multipart/form-data \
-H apikey: YOURAPIKEY_HERE \
-F file=@image.jpg \
-F request={tasks:[DETECTION,OCR],requestedDetectionTypes:[BOX,PLATE]} \
https://trafficeye.ai/recognition
代理工作流程
- 1. 验证图像路径是否存在。
- 运行 python3 recognize_plate.py --format json。
- 向用户展示完整的选定车牌数据,特别是 text、type、dimension、occlusion、unreadable 和 position。
- 如果 API 未返回可读文本,则说明已找到最大车牌但缺少 OCR 文本。
- 如果认证失败,询问用户其部署环境期望的认证模式,并使用匹配的环境变量重试。
离线验证
您可以在不调用 API 的情况下验证选择逻辑:
bash
python3 recognizeplate.py --response-json-file examples/sampleresponse.json --format json
注意事项
- - 辅助程序有意根据几何面积选择最大车牌,而非检测置信度。
- 响应解析器首先检查 combinations[].roadUsers[].plates[],同时也支持 roadUsers[].plates[]、顶层 plates[] 以及递归发现的嵌套车牌数据。
- 默认请求和认证标头与 https://www.trafficeye.ai/api 上的公共示例一致。
- 选定结果现在包含来自 API 的原始车牌数据,因此国家/类型和所有分数均得以保留。