内容
mcp-name: io.github.pirahansiah/farshid-mcp-imageProcessing -->
# 图像处理服务器
适用于 VS Code Copilot 代理模式(或任何 MCP 客户端)的综合 **OpenCV 图像处理 MCP 服务器**。提供了约 40 种工具,涵盖摄像头捕获、图像输入/输出、变换、颜色、过滤、边缘、阈值处理、形态学、轮廓/形状、特征匹配、目标检测(人脸 / 眼睛 / 身体 / 二维码)、绘图、图像算术、模板匹配和视频处理。
- **PyPI:** [`farshid-mcp-imageProcessing`](https://pypi.org/project/farshid-mcp-imageProcessing/)
- **MCP 注册表:** `io.github.pirahansiah/farshid-mcp-imageProcessing`
- **Python3.14+
- **操作系统:** 最新 Windows 11、最新 macOS、最新主流 Linux(Ubuntu 24.04ora 41+)
## 安装(PyPI)
```bash
pip install farshid-mcp-imageProcessing
farshcp-imageprocessing # 运行stdio MCP服务器
```
## 在 VS Code 中注册
将以下内容添加到您的用户或工作区 `mcp.json` 中:
```jsonc
{
"servers": {
"imageProcessing": {
"command": "farshid-mcp-imageprocessing",
"type": "stdio"
}
}
}
```
或者,如果您克隆了存储库并希望从源代码运行并使用venv`:
```bash
git clone https://github.com/pirahansiah/farshid-mcp-imageProcessing
cd farshid-mcp-imageProcessing
# Windows(PowerShell):
py -3.14 -m venv . .\.venv\Scripts\Activate.ps1
# / Linux:
python3.14 -m venv .venv && source .venv/bin/activate
pip install -U pip
pip install -e .
```
使用 `opencv-contrib-python` 以便使用捆绑的 Haar 级联和额外算法。
## 快速入门:`/cv` Copilot 提示
此存储库附带了一个工作区提示文件,位于 [.github/prompts/cv.prompt.md](.github/prompts/cv.prompt.md)。在 VS Code Copilot Chat(代理模式)中,输入:
```
/cv 从摄像头拍摄图像并将其保存为灰度 240 * 240
```
代理将调用 `webcam_save`、`image_to_grayscale` 和 `image_resize` 来生成请求的图像,位于 `./.farshid/cv/` 下。
## 工具目录
### 捕获
- `webcam_capture(camera_index=0)` PNG 图像
- `webcam_save(output_path="", camera_index=- `webcam_preview(camera_index=0, seconds)` (本地桌面窗口)
- `webcam_record(output_path, seconds=5, camera_index=0, fps=20)`
### 图像输入/输出 & 信息
- `image_show(path)` — 将图像返回给聊天
- `image_info(path)` — 形状、数据类型、均值、文件大小
image_convert(input_path, output_path, quality=95)`
###变换
- `image_resize(... width|height|scale, interpolation)`
- `image_crop(input_path, output_path, x, y, width, height)`
- `image_rotate(input_path, output_path, scale=1, keep_size- `image_flip(input_path, output_path, direction)`
-_pad(... top, bottom, left, right, border_type, color)`
### 颜色
- `image_to_grayscale`
- `(target=gray|hsv|hls|lab|ycrcb|rgb|bgr)`
- `adjust_brightness_contrast`
- `histogram_equalize(method=clahe|global)`
- `histogram_data(bins=32)`
### 过滤
- `blur_gaussian(ksize, sigma)`
- `blur_median(ksize)`
- `blur_bilateral(d, sigma_color, sigma_space)`
- `sharpen(amount)`
- `denoise(strength)`
### 边缘 / 梯度
edges_canny(threshold12)`
- `edges(ksize)`
- `aplacian(ksize)`
### 阈值处理 & 形态学
- `threshold(method=otsu|binary|binary_inv|adaptive_mean|adaptive_gaussian `morphology(opode|dilate|open|close|gradient|tophat|blackhat)`
### 轮廓 & 形状
- `find(input_path, output_path?, thresh, min_area)`
- `detect_circles(...)` — Hough
- `detect_lines(...)` — 概率 Hough
- `detect_corners(...)` — Shi-Tomasi
### 特征匹配
- `feature_match(image1, image2, output_path?)` — ORB + BFMatcher
### 目标检测(Haar)
- `detect_faces`
- `detect_eyes`
- `detect_bodies`
- `detect_qrcode`
### 绘图
- `draw_rectangle`、`draw_circle`、`draw_line`、`draw_text`
### 合成 / 算术
- `image_blend(image1, image2, output_path, alpha)`
- `image_diff(image1, image2, output_path?)` → 平均/最大差异
- `image_concat(images, output_path)`
- `template_path, template_path, output_path?, threshold)`
###- `video_info(path)`
- `video_extract_frames(video_path,, every_n, max_frames, ext)`
- `video_thumbnail(video_path, output_path, time_seconds)`
## 构建 &```bash
pip install build twine mcp-publisher
python -m build
upload dist/*
mcp login github
mcp publish .mcp/server.json
```
## 操作系统说明
Windows 11(最新):** 摄像头开箱即确保 *设置 → 隐私和安全 → 摄像头 → 应用程序访问摄像头* 为**。
- **macOS(最新):** 第一次会触发系统摄像头权限提示终端/VS Code 进程权限。
- **Linux(一个可用的/video*` 设备。无显示头服务器无法使用 `webcam_preview`(它一个 OpenCV 窗口)。
## 说明
-函数中永远不要使用()`;stdout 是 MCP 。使用 `sys.stderr`server.py` 底部的 `_log` 帮助程序)。
- `webcam_preview` 打开一个真正的桌面窗口 — 仅在服务器具有显示屏时有效通过纯 SSH 或在容器中)。
- 所有路径都支持 `~` 输出目录会自动创建。
带注释的图像的可选的 `output_path`时,它们只