baseImage


NamebaseImage JSON
Version 2.1.6 PyPI version JSON
download
home_pagehttps://github.com/hakaboom/base_image
SummaryThis is a secondary package of OpenCV,for manage image data
upload_time2023-09-28 17:16:26
maintainer
docs_urlNone
authorhakaboom
requires_python>=3.6, <3.11
licenseApache License 2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # base_image
对opencv_python常用接口的二次开发

建议 opencv version >= 4.5.5(不同opencv版本的python绑定,函数名可能会不同)

# Example

## Create
1. 默认方式创建图片对象
```python
import cv2
from baseImage import Image
from baseImage.constant import Place
    
Image(data='tests/image/0.png')  # 使用默认方式创建
```

2. 通过其他参数,调整图片参数

- 使用place参数,修改数据格式
  - Ndarray: 格式为numpy.ndarray格式
  - Umat: python的绑定不多,没有ndarray灵活,可以用于opencl加速
  - GpuMat: opencv的cuda格式,需要注意显存消耗
    - 可以通过常量`Default_Pool`设定缓冲区

    ```python
    import cv2
    from baseImage import Setting
    
    cv2.cuda.setBufferPoolUsage(True)
    cv2.cuda.setBufferPoolConfig(cv2.cuda.getDevice(), 1024 * 1024 * (3 + 3), 1)
    
    stream = cv2.cuda.Stream()
    pool = cv2.cuda.BufferPool(stream)
    
    Setting.Default_Stream = stream
    Setting.Default_Pool = pool
    ```

```python
import cv2
from baseImage import Image
from baseImage.constant import Place
    
Image(data='tests/image/0.png', place=Place.Ndarray)  # 使用numpy
Image(data='tests/image/0.png', place=Place.UMat)  # 使用Umat
Image(data='tests/image/0.png', place=Place.GpuMat)  # 使用cuda
```

- 使用dtype,修改数据类型
```python
import cv2
import numpy as np
from baseImage.utils.api import cvType_to_npType, npType_to_cvType
from baseImage import Image
    
Image(data='tests/image/0.png', dtype=np.uint8)
Image(data='tests/image/0.png', dtype=np.int8)
Image(data='tests/image/0.png', dtype=np.uint16)
Image(data='tests/image/0.png', dtype=np.int16)
Image(data='tests/image/0.png', dtype=np.int32)
Image(data='tests/image/0.png', dtype=np.float32)
Image(data='tests/image/0.png', dtype=np.float64)
# cvType_to_npType和npType_to_cvType提供了numpy转opencv数据格式的方法, cv的数据格式意义自行百度
```

- clone,用于处理是否拷贝原数据
```python
import cv2
import numpy as np
from baseImage import Image, Rect

img1 = Image(data='tests/image/0.png')
img2 = Image(img1, clone=False)
img2.rectangle(rect=Rect(0, 0, 200, 200), color=(255, 0, 0), thickness=-1)
img2.imshow('img2')
img1.imshow('img1')
cv2.waitKey(0)
```

## property
1. shape: 获取图片的长、宽、通道数
```python
from baseImage import Image

img = Image(data='tests/image/0.png')
print(img.shape)
# expect output
#       (1037, 1920, 3)
```
2. size: 获取图片的长、宽
```python
from baseImage import Image

img = Image(data='tests/image/0.png')
print(img.size)
# expect output
#       (1037, 1920)
```
3. channels: 获取图片的通道数量
```python
from baseImage import Image

img = Image(data='tests/image/0.png')
print(img.channels)
# expect output
#       3
```
4. dtype: 获取图片的数据类型
```python
from baseImage import Image

img = Image(data='tests/image/0.png')
print(img.dtype)
# expect output
#       numpy.uint8
```
5. place: 获取图片的数据格式
```python
from baseImage import Image
from baseImage.constant import Place

img = Image(data='tests/image/0.png', place=Place.Ndarray)
print(img.place == Place.Ndarray)
# expect output
#       True
```
6. data: 获取图片数据
```python
from baseImage import Image

img = Image(data='tests/image/0.png')
print(img.data)
```

## Function
1. dtype_convert: 数据类型转换
  - 将修改原图像数据
```python
from baseImage import Image
import numpy as np

img = Image(data='tests/image/0.png', dtype=np.uint8)
print(img.dtype)
img.dtype_convert(dtype=np.float32)
print(img.dtype)
```
2. place_convert: 数据格式转换
  - 将修改原图像数据
```python
from baseImage import Image
from baseImage.constant import Place

img = Image(data='tests/image/0.png', place=Place.Ndarray)
print(img.place == Place.Ndarray)
img.place_convert(place=Place.UMat)
print(img.place == Place.Ndarray)
print(img.place == Place.UMat)
```

3. clone: 克隆一个新的图片对象
```python
from baseImage import Image
from baseImage.constant import Place

img = Image(data='tests/image/0.png', place=Place.Ndarray)
img2 = img.clone()
print(img == img2)
```

4. rotate: 旋转图片, 现在只支持opencv自带的三个方向
```python
from baseImage import Image
import cv2

img = Image(data='tests/image/0.png')
img.rotate(code=cv2.ROTATE_180).imshow('180')
img.rotate(code=cv2.ROTATE_90_CLOCKWISE).imshow('90_CLOCKWISE')
img.rotate(code=cv2.ROTATE_90_COUNTERCLOCKWISE).imshow('90_COUNTERCLOCKWISE')
cv2.waitKey(0)
```

5. resize: 缩放图像
```python
from baseImage import Image

img = Image(data='tests/image/0.png')
new_img = img.resize(200, 200)
print(new_img.size)
```

6. cvtColor: 转换图片颜色空间
```python
from baseImage import Image
import cv2

img = Image(data='tests/image/0.png')
new_img = img.cvtColor(cv2.COLOR_BGR2GRAY)
new_img.imshow()
cv2.waitKey(0)
```

7. crop: 裁剪图片
```python
from baseImage import Image, Rect
import cv2

img = Image(data='tests/image/0.png')
new_img = img.crop(rect=Rect(0, 0, 400, 400))
new_img.imshow()
cv2.waitKey(0)
```

8. threshold: 二值化图片
```python
from baseImage import Image
import cv2

img = Image(data='tests/image/0.png')
new_img = img.threshold(thresh=0, maxval=255, code=cv2.THRESH_OTSU)
new_img.imshow()
cv2.waitKey(0)
```

9. rectangle: 在图像上画出矩形
  - 会在原图上进行修改
```python
from baseImage import Image, Rect
import cv2

img = Image(data='tests/image/0.png')
img.rectangle(rect=Rect(100, 100, 300, 300), color=(255, 0, 0), thickness=-1)
img.imshow()
cv2.waitKey(0)
```

10. copyMakeBorder: 扩充图片边缘
```python
from baseImage import Image
import cv2

img = Image(data='tests/image/0.png')
new_img = img.copyMakeBorder(top=10, bottom=10, left=10, right=10, borderType=cv2.BORDER_REPLICATE)
new_img.imshow()
cv2.waitKey(0)
```

11. gaussianBlur: 高斯模糊
```python
from baseImage import Image
import cv2

img = Image(data='tests/image/0.png')
new_img = img.gaussianBlur(size=(11, 11), sigma=1.5, borderType=cv2.BORDER_DEFAULT)
new_img.imshow()
cv2.waitKey(0)
```

12. warpPerspective: 透视变换
```python
from baseImage import Image, Size
import cv2
import numpy as np

img = Image(data='tests/image/0.png')
point_1 = np.float32([[0, 0], [100, 0], [0, 200], [100, 200]])
point_2 = np.float32([[0, 0], [50, 0], [0, 100], [50, 100]])
matrix = cv2.getPerspectiveTransform(point_1, point_2)
size = Size(50, 100)

new_img = img.warpPerspective(matrix, size=size)
new_img.imshow()
cv2.waitKey(0)
```
13. bitwise_not: 反转图片颜色
```python
from baseImage import Image
import cv2

img = Image(data='tests/image/0.png')
new_img = img.bitwise_not()
new_img.imshow()
cv2.waitKey(0)
```

14. imshow: 以GUI显示图片
```python
from baseImage import Image
import cv2

img = Image(data='tests/image/0.png')
img.imshow('img1')
cv2.waitKey(0)
```

15. imwrite: 将图片保存到指定路径
```python
from baseImage import Image
import cv2

img = Image(data='tests/image/0.png').cvtColor(cv2.COLOR_BGR2GRAY)
img.imwrite('tests/image/0_gray.png')
```

16. split: 拆分图像通道
  - 会直接返回拆分后的数据,不是Image类型
```python
from baseImage import Image

img = Image(data='tests/image/0.png')
img_split = img.split()
```

## Extra
1. SSIM: 图片结构相似性
   - resize: 图片缩放大小 
```python
from baseImage import SSIM, Image

ssim = SSIM(resize=(600, 600))
img1 = Image('tests/image/0.png')
img2 = Image('tests/image/0.png')
print(ssim.ssim(im1=img1, im2=img2))
```

2. image_diff: 基于SSIM的图片差异对比
```python
from baseImage import ImageDiff, Image
import cv2

diff = ImageDiff()

img1 = Image('tests/image/0.png')
img2 = Image('tests/image/1.png') 
cnts = diff.diff(img1, img2)
imageA = img1.data.copy()
imageB = img2.data.copy()
print(len(cnts))
for c in cnts:
    (x, y, w, h) = cv2.boundingRect(c)
    cv2.rectangle(imageA, (x, y), (x + w, y + h), (0, 0, 255), 2)
    cv2.rectangle(imageB, (x, y), (x + w, y + h), (0, 0, 255), 2)

cv2.imshow("Original", imageA)
cv2.imshow("Modified", imageB)
cv2.waitKey(0)

```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/hakaboom/base_image",
    "name": "baseImage",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6, <3.11",
    "maintainer_email": "",
    "keywords": "",
    "author": "hakaboom",
    "author_email": "1534225986@qq.com",
    "download_url": "https://files.pythonhosted.org/packages/b0/cd/cca83858890d69585a01f6a2fc5c253357f2f7e0642d4aebc555a9de01b2/baseImage-2.1.6.tar.gz",
    "platform": null,
    "description": "# base_image\r\n\u5bf9opencv_python\u5e38\u7528\u63a5\u53e3\u7684\u4e8c\u6b21\u5f00\u53d1\r\n\r\n\u5efa\u8bae opencv version >= 4.5.5(\u4e0d\u540copencv\u7248\u672c\u7684python\u7ed1\u5b9a,\u51fd\u6570\u540d\u53ef\u80fd\u4f1a\u4e0d\u540c)\r\n\r\n# Example\r\n\r\n## Create\r\n1. \u9ed8\u8ba4\u65b9\u5f0f\u521b\u5efa\u56fe\u7247\u5bf9\u8c61\r\n```python\r\nimport cv2\r\nfrom baseImage import Image\r\nfrom baseImage.constant import Place\r\n    \r\nImage(data='tests/image/0.png')  # \u4f7f\u7528\u9ed8\u8ba4\u65b9\u5f0f\u521b\u5efa\r\n```\r\n\r\n2. \u901a\u8fc7\u5176\u4ed6\u53c2\u6570,\u8c03\u6574\u56fe\u7247\u53c2\u6570\r\n\r\n- \u4f7f\u7528place\u53c2\u6570,\u4fee\u6539\u6570\u636e\u683c\u5f0f\r\n  - Ndarray: \u683c\u5f0f\u4e3anumpy.ndarray\u683c\u5f0f\r\n  - Umat: python\u7684\u7ed1\u5b9a\u4e0d\u591a,\u6ca1\u6709ndarray\u7075\u6d3b,\u53ef\u4ee5\u7528\u4e8eopencl\u52a0\u901f\r\n  - GpuMat: opencv\u7684cuda\u683c\u5f0f,\u9700\u8981\u6ce8\u610f\u663e\u5b58\u6d88\u8017\r\n    - \u53ef\u4ee5\u901a\u8fc7\u5e38\u91cf`Default_Pool`\u8bbe\u5b9a\u7f13\u51b2\u533a\r\n\r\n    ```python\r\n    import cv2\r\n    from baseImage import Setting\r\n    \r\n    cv2.cuda.setBufferPoolUsage(True)\r\n    cv2.cuda.setBufferPoolConfig(cv2.cuda.getDevice(), 1024 * 1024 * (3 + 3), 1)\r\n    \r\n    stream = cv2.cuda.Stream()\r\n    pool = cv2.cuda.BufferPool(stream)\r\n    \r\n    Setting.Default_Stream = stream\r\n    Setting.Default_Pool = pool\r\n    ```\r\n\r\n```python\r\nimport cv2\r\nfrom baseImage import Image\r\nfrom baseImage.constant import Place\r\n    \r\nImage(data='tests/image/0.png', place=Place.Ndarray)  # \u4f7f\u7528numpy\r\nImage(data='tests/image/0.png', place=Place.UMat)  # \u4f7f\u7528Umat\r\nImage(data='tests/image/0.png', place=Place.GpuMat)  # \u4f7f\u7528cuda\r\n```\r\n\r\n- \u4f7f\u7528dtype,\u4fee\u6539\u6570\u636e\u7c7b\u578b\r\n```python\r\nimport cv2\r\nimport numpy as np\r\nfrom baseImage.utils.api import cvType_to_npType, npType_to_cvType\r\nfrom baseImage import Image\r\n    \r\nImage(data='tests/image/0.png', dtype=np.uint8)\r\nImage(data='tests/image/0.png', dtype=np.int8)\r\nImage(data='tests/image/0.png', dtype=np.uint16)\r\nImage(data='tests/image/0.png', dtype=np.int16)\r\nImage(data='tests/image/0.png', dtype=np.int32)\r\nImage(data='tests/image/0.png', dtype=np.float32)\r\nImage(data='tests/image/0.png', dtype=np.float64)\r\n# cvType_to_npType\u548cnpType_to_cvType\u63d0\u4f9b\u4e86numpy\u8f6copencv\u6570\u636e\u683c\u5f0f\u7684\u65b9\u6cd5, cv\u7684\u6570\u636e\u683c\u5f0f\u610f\u4e49\u81ea\u884c\u767e\u5ea6\r\n```\r\n\r\n- clone,\u7528\u4e8e\u5904\u7406\u662f\u5426\u62f7\u8d1d\u539f\u6570\u636e\r\n```python\r\nimport cv2\r\nimport numpy as np\r\nfrom baseImage import Image, Rect\r\n\r\nimg1 = Image(data='tests/image/0.png')\r\nimg2 = Image(img1, clone=False)\r\nimg2.rectangle(rect=Rect(0, 0, 200, 200), color=(255, 0, 0), thickness=-1)\r\nimg2.imshow('img2')\r\nimg1.imshow('img1')\r\ncv2.waitKey(0)\r\n```\r\n\r\n## property\r\n1. shape: \u83b7\u53d6\u56fe\u7247\u7684\u957f\u3001\u5bbd\u3001\u901a\u9053\u6570\r\n```python\r\nfrom baseImage import Image\r\n\r\nimg = Image(data='tests/image/0.png')\r\nprint(img.shape)\r\n# expect output\r\n#       (1037, 1920, 3)\r\n```\r\n2. size: \u83b7\u53d6\u56fe\u7247\u7684\u957f\u3001\u5bbd\r\n```python\r\nfrom baseImage import Image\r\n\r\nimg = Image(data='tests/image/0.png')\r\nprint(img.size)\r\n# expect output\r\n#       (1037, 1920)\r\n```\r\n3. channels: \u83b7\u53d6\u56fe\u7247\u7684\u901a\u9053\u6570\u91cf\r\n```python\r\nfrom baseImage import Image\r\n\r\nimg = Image(data='tests/image/0.png')\r\nprint(img.channels)\r\n# expect output\r\n#       3\r\n```\r\n4. dtype: \u83b7\u53d6\u56fe\u7247\u7684\u6570\u636e\u7c7b\u578b\r\n```python\r\nfrom baseImage import Image\r\n\r\nimg = Image(data='tests/image/0.png')\r\nprint(img.dtype)\r\n# expect output\r\n#       numpy.uint8\r\n```\r\n5. place: \u83b7\u53d6\u56fe\u7247\u7684\u6570\u636e\u683c\u5f0f\r\n```python\r\nfrom baseImage import Image\r\nfrom baseImage.constant import Place\r\n\r\nimg = Image(data='tests/image/0.png', place=Place.Ndarray)\r\nprint(img.place == Place.Ndarray)\r\n# expect output\r\n#       True\r\n```\r\n6. data: \u83b7\u53d6\u56fe\u7247\u6570\u636e\r\n```python\r\nfrom baseImage import Image\r\n\r\nimg = Image(data='tests/image/0.png')\r\nprint(img.data)\r\n```\r\n\r\n## Function\r\n1. dtype_convert: \u6570\u636e\u7c7b\u578b\u8f6c\u6362\r\n  - \u5c06\u4fee\u6539\u539f\u56fe\u50cf\u6570\u636e\r\n```python\r\nfrom baseImage import Image\r\nimport numpy as np\r\n\r\nimg = Image(data='tests/image/0.png', dtype=np.uint8)\r\nprint(img.dtype)\r\nimg.dtype_convert(dtype=np.float32)\r\nprint(img.dtype)\r\n```\r\n2. place_convert: \u6570\u636e\u683c\u5f0f\u8f6c\u6362\r\n  - \u5c06\u4fee\u6539\u539f\u56fe\u50cf\u6570\u636e\r\n```python\r\nfrom baseImage import Image\r\nfrom baseImage.constant import Place\r\n\r\nimg = Image(data='tests/image/0.png', place=Place.Ndarray)\r\nprint(img.place == Place.Ndarray)\r\nimg.place_convert(place=Place.UMat)\r\nprint(img.place == Place.Ndarray)\r\nprint(img.place == Place.UMat)\r\n```\r\n\r\n3. clone: \u514b\u9686\u4e00\u4e2a\u65b0\u7684\u56fe\u7247\u5bf9\u8c61\r\n```python\r\nfrom baseImage import Image\r\nfrom baseImage.constant import Place\r\n\r\nimg = Image(data='tests/image/0.png', place=Place.Ndarray)\r\nimg2 = img.clone()\r\nprint(img == img2)\r\n```\r\n\r\n4. rotate: \u65cb\u8f6c\u56fe\u7247, \u73b0\u5728\u53ea\u652f\u6301opencv\u81ea\u5e26\u7684\u4e09\u4e2a\u65b9\u5411\r\n```python\r\nfrom baseImage import Image\r\nimport cv2\r\n\r\nimg = Image(data='tests/image/0.png')\r\nimg.rotate(code=cv2.ROTATE_180).imshow('180')\r\nimg.rotate(code=cv2.ROTATE_90_CLOCKWISE).imshow('90_CLOCKWISE')\r\nimg.rotate(code=cv2.ROTATE_90_COUNTERCLOCKWISE).imshow('90_COUNTERCLOCKWISE')\r\ncv2.waitKey(0)\r\n```\r\n\r\n5. resize: \u7f29\u653e\u56fe\u50cf\r\n```python\r\nfrom baseImage import Image\r\n\r\nimg = Image(data='tests/image/0.png')\r\nnew_img = img.resize(200, 200)\r\nprint(new_img.size)\r\n```\r\n\r\n6. cvtColor: \u8f6c\u6362\u56fe\u7247\u989c\u8272\u7a7a\u95f4\r\n```python\r\nfrom baseImage import Image\r\nimport cv2\r\n\r\nimg = Image(data='tests/image/0.png')\r\nnew_img = img.cvtColor(cv2.COLOR_BGR2GRAY)\r\nnew_img.imshow()\r\ncv2.waitKey(0)\r\n```\r\n\r\n7. crop: \u88c1\u526a\u56fe\u7247\r\n```python\r\nfrom baseImage import Image, Rect\r\nimport cv2\r\n\r\nimg = Image(data='tests/image/0.png')\r\nnew_img = img.crop(rect=Rect(0, 0, 400, 400))\r\nnew_img.imshow()\r\ncv2.waitKey(0)\r\n```\r\n\r\n8. threshold: \u4e8c\u503c\u5316\u56fe\u7247\r\n```python\r\nfrom baseImage import Image\r\nimport cv2\r\n\r\nimg = Image(data='tests/image/0.png')\r\nnew_img = img.threshold(thresh=0, maxval=255, code=cv2.THRESH_OTSU)\r\nnew_img.imshow()\r\ncv2.waitKey(0)\r\n```\r\n\r\n9. rectangle: \u5728\u56fe\u50cf\u4e0a\u753b\u51fa\u77e9\u5f62\r\n  - \u4f1a\u5728\u539f\u56fe\u4e0a\u8fdb\u884c\u4fee\u6539\r\n```python\r\nfrom baseImage import Image, Rect\r\nimport cv2\r\n\r\nimg = Image(data='tests/image/0.png')\r\nimg.rectangle(rect=Rect(100, 100, 300, 300), color=(255, 0, 0), thickness=-1)\r\nimg.imshow()\r\ncv2.waitKey(0)\r\n```\r\n\r\n10. copyMakeBorder: \u6269\u5145\u56fe\u7247\u8fb9\u7f18\r\n```python\r\nfrom baseImage import Image\r\nimport cv2\r\n\r\nimg = Image(data='tests/image/0.png')\r\nnew_img = img.copyMakeBorder(top=10, bottom=10, left=10, right=10, borderType=cv2.BORDER_REPLICATE)\r\nnew_img.imshow()\r\ncv2.waitKey(0)\r\n```\r\n\r\n11. gaussianBlur: \u9ad8\u65af\u6a21\u7cca\r\n```python\r\nfrom baseImage import Image\r\nimport cv2\r\n\r\nimg = Image(data='tests/image/0.png')\r\nnew_img = img.gaussianBlur(size=(11, 11), sigma=1.5, borderType=cv2.BORDER_DEFAULT)\r\nnew_img.imshow()\r\ncv2.waitKey(0)\r\n```\r\n\r\n12. warpPerspective: \u900f\u89c6\u53d8\u6362\r\n```python\r\nfrom baseImage import Image, Size\r\nimport cv2\r\nimport numpy as np\r\n\r\nimg = Image(data='tests/image/0.png')\r\npoint_1 = np.float32([[0, 0], [100, 0], [0, 200], [100, 200]])\r\npoint_2 = np.float32([[0, 0], [50, 0], [0, 100], [50, 100]])\r\nmatrix = cv2.getPerspectiveTransform(point_1, point_2)\r\nsize = Size(50, 100)\r\n\r\nnew_img = img.warpPerspective(matrix, size=size)\r\nnew_img.imshow()\r\ncv2.waitKey(0)\r\n```\r\n13. bitwise_not: \u53cd\u8f6c\u56fe\u7247\u989c\u8272\r\n```python\r\nfrom baseImage import Image\r\nimport cv2\r\n\r\nimg = Image(data='tests/image/0.png')\r\nnew_img = img.bitwise_not()\r\nnew_img.imshow()\r\ncv2.waitKey(0)\r\n```\r\n\r\n14. imshow: \u4ee5GUI\u663e\u793a\u56fe\u7247\r\n```python\r\nfrom baseImage import Image\r\nimport cv2\r\n\r\nimg = Image(data='tests/image/0.png')\r\nimg.imshow('img1')\r\ncv2.waitKey(0)\r\n```\r\n\r\n15. imwrite: \u5c06\u56fe\u7247\u4fdd\u5b58\u5230\u6307\u5b9a\u8def\u5f84\r\n```python\r\nfrom baseImage import Image\r\nimport cv2\r\n\r\nimg = Image(data='tests/image/0.png').cvtColor(cv2.COLOR_BGR2GRAY)\r\nimg.imwrite('tests/image/0_gray.png')\r\n```\r\n\r\n16. split: \u62c6\u5206\u56fe\u50cf\u901a\u9053\r\n  - \u4f1a\u76f4\u63a5\u8fd4\u56de\u62c6\u5206\u540e\u7684\u6570\u636e,\u4e0d\u662fImage\u7c7b\u578b\r\n```python\r\nfrom baseImage import Image\r\n\r\nimg = Image(data='tests/image/0.png')\r\nimg_split = img.split()\r\n```\r\n\r\n## Extra\r\n1. SSIM: \u56fe\u7247\u7ed3\u6784\u76f8\u4f3c\u6027\r\n   - resize: \u56fe\u7247\u7f29\u653e\u5927\u5c0f \r\n```python\r\nfrom baseImage import SSIM, Image\r\n\r\nssim = SSIM(resize=(600, 600))\r\nimg1 = Image('tests/image/0.png')\r\nimg2 = Image('tests/image/0.png')\r\nprint(ssim.ssim(im1=img1, im2=img2))\r\n```\r\n\r\n2. image_diff: \u57fa\u4e8eSSIM\u7684\u56fe\u7247\u5dee\u5f02\u5bf9\u6bd4\r\n```python\r\nfrom baseImage import ImageDiff, Image\r\nimport cv2\r\n\r\ndiff = ImageDiff()\r\n\r\nimg1 = Image('tests/image/0.png')\r\nimg2 = Image('tests/image/1.png') \r\ncnts = diff.diff(img1, img2)\r\nimageA = img1.data.copy()\r\nimageB = img2.data.copy()\r\nprint(len(cnts))\r\nfor c in cnts:\r\n    (x, y, w, h) = cv2.boundingRect(c)\r\n    cv2.rectangle(imageA, (x, y), (x + w, y + h), (0, 0, 255), 2)\r\n    cv2.rectangle(imageB, (x, y), (x + w, y + h), (0, 0, 255), 2)\r\n\r\ncv2.imshow(\"Original\", imageA)\r\ncv2.imshow(\"Modified\", imageB)\r\ncv2.waitKey(0)\r\n\r\n```\r\n",
    "bugtrack_url": null,
    "license": "Apache License 2.0",
    "summary": "This is a secondary package of OpenCV,for manage image data",
    "version": "2.1.6",
    "project_urls": {
        "Homepage": "https://github.com/hakaboom/base_image"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b0cdcca83858890d69585a01f6a2fc5c253357f2f7e0642d4aebc555a9de01b2",
                "md5": "9b46d5bbdc330938fa3dc6ab10698622",
                "sha256": "d47e8105a8992e070607efa4343b2f1d3f6baf91d176021ca00c2e43c6e0f10f"
            },
            "downloads": -1,
            "filename": "baseImage-2.1.6.tar.gz",
            "has_sig": false,
            "md5_digest": "9b46d5bbdc330938fa3dc6ab10698622",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6, <3.11",
            "size": 29062,
            "upload_time": "2023-09-28T17:16:26",
            "upload_time_iso_8601": "2023-09-28T17:16:26.461734Z",
            "url": "https://files.pythonhosted.org/packages/b0/cd/cca83858890d69585a01f6a2fc5c253357f2f7e0642d4aebc555a9de01b2/baseImage-2.1.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-28 17:16:26",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "hakaboom",
    "github_project": "base_image",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "baseimage"
}
        
Elapsed time: 0.13576s