← Back to Skills Marketplace
Pill Counter Skill
by
johnsonxuan
· GitHub ↗
· v1.0.0
· MIT-0
29
Downloads
0
Stars
0
Active Installs
1
Versions
Install in OpenClaw
/install pill-counter-skill
Description
使用 OpenCV 图像识别精确计数药片。自动检测、分类(小圆/中圆/大圆/椭圆)、 标注结果图片。支持 JSON 和文本两种输出格式。 适用场景:药品盘点、处方核对、药物研究计数。
README (SKILL.md)
💊 药片精确计数 Skill
自动识别图片中的药片,按形状和大小分类计数。
功能
- ✅ 自动检测图片中的所有药片
- ✅ 分类:小圆形、中圆形、大圆形、椭圆形
- ✅ 逐个编号标注,生成结果图片
- ✅ 支持 JSON / 文本两种输出格式
- ✅ 处理粘连药片(分水岭算法)
使用方法
基本用法
python3 scripts/pill_counter.py \x3C图片路径>
指定输出格式
python3 scripts/pill_counter.py image.jpg --output json
保存标注结果图
python3 scripts/pill_counter.py image.jpg --save result.jpg
完整参数
python3 scripts/pill_counter.py image.jpg --output text --save result.jpg
输出示例
文本输出(默认)
=============================================
📊 药片计数结果
=============================================
✅ 检测总数: 240 粒
🟢 小圆形: 13 粒
🔵 中圆形: 204 粒
🟠 椭圆形: 23 粒
🟢=小圆 🔵=中圆 🟣=大圆 🟠=椭圆
=============================================
JSON 输出
{
"total": 240,
"image_size": [3072, 4096],
"categories": {
"小圆形": 13,
"中圆形": 204,
"椭圆形": 23
}
}
分类说明
| 类型 | 识别规则 | 颜色标记 |
|---|---|---|
| 小圆形 | 圆形度>0.75,面积\x3C中位数70% | 🟢 绿色 |
| 中圆形 | 圆形度>0.75,面积在中位数±40% | 🔵 青色 |
| 大圆形 | 圆形度>0.75,面积>中位数140% | 🟣 紫色 |
| 椭圆形 | 宽高比>1.4 或 \x3C0.7 | 🟠 橙色 |
依赖
- Python 3.6+
- opencv-python-headless
- numpy
注意事项
- 图片需要清晰,药片与背景有明显对比度
- 白色药片在深色背景上效果最佳
- 药片有粘连时会自动分离,极端重叠可能影响精度
- 碎片可能被误识别为小药片
Usage Guidance
Install the Python dependencies in a virtual environment, run the tool on copies of pill images, specify an explicit --save path in a workspace folder, and manually verify results before using them for inventory, prescription, or safety-critical decisions.
Capability Analysis
Type: OpenClaw Skill
Name: pill-counter-skill
Version: 1.0.0
The skill is a legitimate image processing tool for counting and classifying pills using OpenCV. The Python script (scripts/pill_counter.py) performs standard computer vision operations like thresholding and contour detection without any suspicious behaviors such as network requests, shell execution, or unauthorized file access. Permissions are properly restricted to a specific workspace directory.
Capability Assessment
Purpose & Capability
The code and documentation coherently match a local OpenCV pill-counting purpose, with no network or credential behavior shown. Because it is framed for medication and prescription workflows, the counts should be treated as an aid rather than a sole source of truth.
Instruction Scope
The skill is user-invoked through a Python command and its examples are direct CLI usage. The script does, however, create an annotated result image by default even when the user does not provide --save.
Install Mechanism
There is no automatic install spec, but SKILL.md asks the user to install unpinned Python packages with pip; this is expected for OpenCV processing but should be done in a controlled environment.
Credentials
Local image reads and result-image writes are proportional to the stated purpose. The declared write permission is scoped to a workspace path, while the script can write to a user-supplied --save path or next to the input image.
Persistence & Privilege
No credentials, account access, background workers, persistent memory, or autonomous persistence are shown; the only persistent artifact is a local output image.
How to Use
- Make sure OpenClaw is installed (local or Docker)
- Run the install command in chat:
/install pill-counter-skill - After installation, invoke the skill by name or use
/pill-counter-skill - Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.0
pill-counter-skill 1.0.0
- 首次发布,支持使用 OpenCV 自动检测图片中的药片并分类计数
- 按小圆形、中圆形、大圆形、椭圆形进行分类
- 结果可输出为文本或 JSON,同时可生成带编号标注的图片
- 支持处理粘连药片(分水岭算法)
- 提供命令行界面支持多种参数和输出方式
Metadata
Frequently Asked Questions
What is Pill Counter Skill?
使用 OpenCV 图像识别精确计数药片。自动检测、分类(小圆/中圆/大圆/椭圆)、 标注结果图片。支持 JSON 和文本两种输出格式。 适用场景:药品盘点、处方核对、药物研究计数。 It is an AI Agent Skill for Claude Code / OpenClaw, with 29 downloads so far.
How do I install Pill Counter Skill?
Run "/install pill-counter-skill" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.
Is Pill Counter Skill free?
Yes, Pill Counter Skill is completely free, licensed under MIT-0. You can download, install and use it at no cost.
Which platforms does Pill Counter Skill support?
Pill Counter Skill is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).
Who created Pill Counter Skill?
It is built and maintained by johnsonxuan (@johnsonxuan); the current version is v1.0.0.
More Skills