Name | mcv-plus JSON |
Version |
0.0.1
JSON |
| download |
home_page | None |
Summary | Opencv图像处理增强库 |
upload_time | 2024-10-24 13:35:54 |
maintainer | None |
docs_url | None |
author | KateTseng |
requires_python | >=3 |
license | MIT |
keywords |
auto
script
testing
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# 图像处理模块
本模块提供一个 `Image` 类,用于基本的图像操作和使用 OpenCV 进行模板匹配的功能。
## 类:Image
### `__init__(image: cv2.Mat)`
初始化一个 `Image` 对象。
- **参数:**
- `image`:OpenCV 图像,类型为 `cv2.Mat`。
### 方法
#### 基础功能
- **`read(file_path: str) -> Image`**
- 从文件中读取图像。
- **参数:**
- `file_path`:图像文件的路径。
- **返回:** 一个 `Image` 对象。
- **`save(file_path: str, ext: str = ".png")`**
- 将图像保存到指定的文件。
- **参数:**
- `file_path`:保存图像的路径。
- `ext`:保存图像的文件格式。
- **`show(window_name: str = "Image")`**
- 在窗口中显示图像。
- **参数:**
- `window_name`:窗口的名称。
- **`to_base64() -> str`**
- 将图像转换为 base64 编码的字符串。
- **`to_bytes() -> bytes`**
- 将图像转换为字节数组。
#### 图像处理功能
- **`resize(width: int, height: int) -> Image`**
- 将图像调整为指定的尺寸。
- **参数:**
- `width`:新宽度。
- `height`:新高度。
- **`scale(fx: float = 1.0, fy: float = 1.0) -> Image`**
- 根据指定的比例因子缩放图像。
- **参数:**
- `fx`:宽度的缩放比例。
- `fy`:高度的缩放比例。
- **`grayscale() -> Image`**
- 将图像转换为灰度图像。
- **`clip(x: int, y: int, w: int, h: int) -> Image`**
- 裁剪图像到指定的区域。
- **参数:**
- `x`:起始 x 坐标。
- `y`:起始 y 坐标。
- `w`:裁剪区域的宽度。
- `h`:裁剪区域的高度。
- **`pyr_down() -> Image`**
- 使用金字塔方法下采样图像。
- **`get_pixel(x: int, y: int) -> Tuple[int, int, int]`**
- 获取指定坐标处的像素的 BGR 值。
#### 绘图功能
- **`draw_line(pt1: Sequence[int], pt2: Sequence[int], color: Sequence[float] = (0, 0, 255), thickness: int = 1) -> Image`**
- 在图像上绘制一条线。
- **`draw_rectangle(pt1: Sequence[int], pt2: Sequence[int], color: Sequence[float] = (0, 0, 255), thickness: int = 1) -> Image`**
- 在图像上绘制一个矩形。
- **`draw_circle(center: Sequence[int], radius: int, color: Sequence[float] = (0, 0, 255), thickness: int = 1) -> Image`**
- 在图像上绘制一个圆。
- **`draw_text(text: str, position: Sequence[int], color: Sequence[int] = (0, 0, 255), font_size: int = 1, font_path: str = "simsun.ttc") -> Image`**
- 在图像上绘制文字。
- **`draw_point(center: Sequence[int], radius: int = 1, color: Sequence[float] = (0, 0, 255)) -> Image`**
- 在图像上绘制一个点。
## 模板匹配功能
- **`match_template(img: Image, template: Image, region: Sequence[int] = None, threshold: float = 0.95, max_result: int = 5) -> Optional[List[Tuple[int, int]]]`**
- 执行模板匹配。
- **`match_template_best(img: Image, template: Image, region: Sequence[int] = None, threshold: float = 0.95, level: int = None) -> Optional[Tuple[int, int]]`**
- 找到图像中模板的最佳匹配。
## 找色功能
- **`find_color(img: Image, color: Sequence[int], region: Sequence[int] = None, threshold: int = 4) -> Optional[Tuple[int, int]]`**
- 找到一个匹配特定颜色的像素。
- **`find_all_points_color(img: Image, color: Sequence[int], region: Sequence[int] = None, threshold: int = 4) -> Optional[List[Tuple[int, int]]]`**
- 找到图像中所有匹配特定颜色的点。
- **`find_multi_colors(img: Image, first_color: Sequence[int], colors: List[Tuple[int, int, Sequence[int]]], region: Sequence[int] = None, threshold: int = 4) -> Optional[Tuple[int, int]]`**
- 找到匹配多个颜色的点。
Raw data
{
"_id": null,
"home_page": null,
"name": "mcv-plus",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3",
"maintainer_email": null,
"keywords": "Auto Script Testing",
"author": "KateTseng",
"author_email": "Kate.TsengK@outlook.com",
"download_url": "https://files.pythonhosted.org/packages/27/4f/4ad2128744df975be07c723b00f9c31624e60516da454b7017778ca92b4e/mcv-plus-0.0.1.tar.gz",
"platform": null,
"description": "# \u56fe\u50cf\u5904\u7406\u6a21\u5757\r\n\r\n\u672c\u6a21\u5757\u63d0\u4f9b\u4e00\u4e2a `Image` \u7c7b\uff0c\u7528\u4e8e\u57fa\u672c\u7684\u56fe\u50cf\u64cd\u4f5c\u548c\u4f7f\u7528 OpenCV \u8fdb\u884c\u6a21\u677f\u5339\u914d\u7684\u529f\u80fd\u3002\r\n\r\n## \u7c7b\uff1aImage\r\n\r\n### `__init__(image: cv2.Mat)`\r\n\u521d\u59cb\u5316\u4e00\u4e2a `Image` \u5bf9\u8c61\u3002\r\n- **\u53c2\u6570\uff1a**\r\n - `image`\uff1aOpenCV \u56fe\u50cf\uff0c\u7c7b\u578b\u4e3a `cv2.Mat`\u3002\r\n\r\n### \u65b9\u6cd5\r\n\r\n#### \u57fa\u7840\u529f\u80fd\r\n\r\n- **`read(file_path: str) -> Image`**\r\n - \u4ece\u6587\u4ef6\u4e2d\u8bfb\u53d6\u56fe\u50cf\u3002\r\n - **\u53c2\u6570\uff1a**\r\n - `file_path`\uff1a\u56fe\u50cf\u6587\u4ef6\u7684\u8def\u5f84\u3002\r\n - **\u8fd4\u56de\uff1a** \u4e00\u4e2a `Image` \u5bf9\u8c61\u3002\r\n\r\n- **`save(file_path: str, ext: str = \".png\")`**\r\n - \u5c06\u56fe\u50cf\u4fdd\u5b58\u5230\u6307\u5b9a\u7684\u6587\u4ef6\u3002\r\n - **\u53c2\u6570\uff1a**\r\n - `file_path`\uff1a\u4fdd\u5b58\u56fe\u50cf\u7684\u8def\u5f84\u3002\r\n - `ext`\uff1a\u4fdd\u5b58\u56fe\u50cf\u7684\u6587\u4ef6\u683c\u5f0f\u3002\r\n \r\n- **`show(window_name: str = \"Image\")`**\r\n - \u5728\u7a97\u53e3\u4e2d\u663e\u793a\u56fe\u50cf\u3002\r\n - **\u53c2\u6570\uff1a**\r\n - `window_name`\uff1a\u7a97\u53e3\u7684\u540d\u79f0\u3002\r\n\r\n- **`to_base64() -> str`**\r\n - \u5c06\u56fe\u50cf\u8f6c\u6362\u4e3a base64 \u7f16\u7801\u7684\u5b57\u7b26\u4e32\u3002\r\n \r\n- **`to_bytes() -> bytes`**\r\n - \u5c06\u56fe\u50cf\u8f6c\u6362\u4e3a\u5b57\u8282\u6570\u7ec4\u3002\r\n\r\n#### \u56fe\u50cf\u5904\u7406\u529f\u80fd\r\n\r\n- **`resize(width: int, height: int) -> Image`**\r\n - \u5c06\u56fe\u50cf\u8c03\u6574\u4e3a\u6307\u5b9a\u7684\u5c3a\u5bf8\u3002\r\n - **\u53c2\u6570\uff1a**\r\n - `width`\uff1a\u65b0\u5bbd\u5ea6\u3002\r\n - `height`\uff1a\u65b0\u9ad8\u5ea6\u3002\r\n\r\n- **`scale(fx: float = 1.0, fy: float = 1.0) -> Image`**\r\n - \u6839\u636e\u6307\u5b9a\u7684\u6bd4\u4f8b\u56e0\u5b50\u7f29\u653e\u56fe\u50cf\u3002\r\n - **\u53c2\u6570\uff1a**\r\n - `fx`\uff1a\u5bbd\u5ea6\u7684\u7f29\u653e\u6bd4\u4f8b\u3002\r\n - `fy`\uff1a\u9ad8\u5ea6\u7684\u7f29\u653e\u6bd4\u4f8b\u3002\r\n\r\n- **`grayscale() -> Image`**\r\n - \u5c06\u56fe\u50cf\u8f6c\u6362\u4e3a\u7070\u5ea6\u56fe\u50cf\u3002\r\n\r\n- **`clip(x: int, y: int, w: int, h: int) -> Image`**\r\n - \u88c1\u526a\u56fe\u50cf\u5230\u6307\u5b9a\u7684\u533a\u57df\u3002\r\n - **\u53c2\u6570\uff1a**\r\n - `x`\uff1a\u8d77\u59cb x \u5750\u6807\u3002\r\n - `y`\uff1a\u8d77\u59cb y \u5750\u6807\u3002\r\n - `w`\uff1a\u88c1\u526a\u533a\u57df\u7684\u5bbd\u5ea6\u3002\r\n - `h`\uff1a\u88c1\u526a\u533a\u57df\u7684\u9ad8\u5ea6\u3002\r\n\r\n- **`pyr_down() -> Image`**\r\n - \u4f7f\u7528\u91d1\u5b57\u5854\u65b9\u6cd5\u4e0b\u91c7\u6837\u56fe\u50cf\u3002\r\n\r\n- **`get_pixel(x: int, y: int) -> Tuple[int, int, int]`**\r\n - \u83b7\u53d6\u6307\u5b9a\u5750\u6807\u5904\u7684\u50cf\u7d20\u7684 BGR \u503c\u3002\r\n \r\n#### \u7ed8\u56fe\u529f\u80fd\r\n\r\n- **`draw_line(pt1: Sequence[int], pt2: Sequence[int], color: Sequence[float] = (0, 0, 255), thickness: int = 1) -> Image`**\r\n - \u5728\u56fe\u50cf\u4e0a\u7ed8\u5236\u4e00\u6761\u7ebf\u3002\r\n\r\n- **`draw_rectangle(pt1: Sequence[int], pt2: Sequence[int], color: Sequence[float] = (0, 0, 255), thickness: int = 1) -> Image`**\r\n - \u5728\u56fe\u50cf\u4e0a\u7ed8\u5236\u4e00\u4e2a\u77e9\u5f62\u3002\r\n\r\n- **`draw_circle(center: Sequence[int], radius: int, color: Sequence[float] = (0, 0, 255), thickness: int = 1) -> Image`**\r\n - \u5728\u56fe\u50cf\u4e0a\u7ed8\u5236\u4e00\u4e2a\u5706\u3002\r\n\r\n- **`draw_text(text: str, position: Sequence[int], color: Sequence[int] = (0, 0, 255), font_size: int = 1, font_path: str = \"simsun.ttc\") -> Image`**\r\n - \u5728\u56fe\u50cf\u4e0a\u7ed8\u5236\u6587\u5b57\u3002\r\n\r\n- **`draw_point(center: Sequence[int], radius: int = 1, color: Sequence[float] = (0, 0, 255)) -> Image`**\r\n - \u5728\u56fe\u50cf\u4e0a\u7ed8\u5236\u4e00\u4e2a\u70b9\u3002\r\n\r\n## \u6a21\u677f\u5339\u914d\u529f\u80fd\r\n- **`match_template(img: Image, template: Image, region: Sequence[int] = None, threshold: float = 0.95, max_result: int = 5) -> Optional[List[Tuple[int, int]]]`**\r\n - \u6267\u884c\u6a21\u677f\u5339\u914d\u3002\r\n\r\n- **`match_template_best(img: Image, template: Image, region: Sequence[int] = None, threshold: float = 0.95, level: int = None) -> Optional[Tuple[int, int]]`**\r\n - \u627e\u5230\u56fe\u50cf\u4e2d\u6a21\u677f\u7684\u6700\u4f73\u5339\u914d\u3002\r\n\r\n## \u627e\u8272\u529f\u80fd\r\n- **`find_color(img: Image, color: Sequence[int], region: Sequence[int] = None, threshold: int = 4) -> Optional[Tuple[int, int]]`**\r\n - \u627e\u5230\u4e00\u4e2a\u5339\u914d\u7279\u5b9a\u989c\u8272\u7684\u50cf\u7d20\u3002\r\n\r\n- **`find_all_points_color(img: Image, color: Sequence[int], region: Sequence[int] = None, threshold: int = 4) -> Optional[List[Tuple[int, int]]]`**\r\n - \u627e\u5230\u56fe\u50cf\u4e2d\u6240\u6709\u5339\u914d\u7279\u5b9a\u989c\u8272\u7684\u70b9\u3002\r\n\r\n- **`find_multi_colors(img: Image, first_color: Sequence[int], colors: List[Tuple[int, int, Sequence[int]]], region: Sequence[int] = None, threshold: int = 4) -> Optional[Tuple[int, int]]`**\r\n - \u627e\u5230\u5339\u914d\u591a\u4e2a\u989c\u8272\u7684\u70b9\u3002\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Opencv\u56fe\u50cf\u5904\u7406\u589e\u5f3a\u5e93",
"version": "0.0.1",
"project_urls": null,
"split_keywords": [
"auto",
"script",
"testing"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "4161f00c0e1e28df1a393b12dddf463b733e38413e06a43533d6c3cc3c615372",
"md5": "c3306de760a27aaee8034b30a864c22a",
"sha256": "c131573aa51224964c1d7427a8bc29905b9b72c98857b8f9016b014b2027b707"
},
"downloads": -1,
"filename": "mcv_plus-0.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c3306de760a27aaee8034b30a864c22a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3",
"size": 5928,
"upload_time": "2024-10-24T13:35:53",
"upload_time_iso_8601": "2024-10-24T13:35:53.513070Z",
"url": "https://files.pythonhosted.org/packages/41/61/f00c0e1e28df1a393b12dddf463b733e38413e06a43533d6c3cc3c615372/mcv_plus-0.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "274f4ad2128744df975be07c723b00f9c31624e60516da454b7017778ca92b4e",
"md5": "bddffde3f44e88872bd739f661aca6b2",
"sha256": "3b1a9d767034fde612a463c5f0295aaa9eea8d432109bb138e9c3c4caf1b8edd"
},
"downloads": -1,
"filename": "mcv-plus-0.0.1.tar.gz",
"has_sig": false,
"md5_digest": "bddffde3f44e88872bd739f661aca6b2",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3",
"size": 7043,
"upload_time": "2024-10-24T13:35:54",
"upload_time_iso_8601": "2024-10-24T13:35:54.893578Z",
"url": "https://files.pythonhosted.org/packages/27/4f/4ad2128744df975be07c723b00f9c31624e60516da454b7017778ca92b4e/mcv-plus-0.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-24 13:35:54",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "mcv-plus"
}