Skip to main content

OpenCV 轻量扩展:Unicode 路径读写、HALCON 风格灰度缩放

Project description

ydl2

ydl2 是对 OpenCV 的轻量补充:解决 Windows 中文路径 读写问题,提供与 HALCON 语义一致的灰度缩放算子,以及基于 HALCON 的形状模板匹配封装。

安装

pip install ydl2

快速使用

Unicode 路径 & 灰度缩放

import ydl2

# Unicode 路径读写(Windows 中文路径)
img = ydl2.imread(r"D:\图片\测试.png")
ydl2.imwrite(r"D:\图片\输出.png", img)

# HALCON 等价算子
stretched = ydl2.scale_image_max(img)
inverted  = ydl2.scale_image(img, -1.0, 255.0)
mapped    = ydl2.scale_image_range(img, 100, 200)

形状模板匹配

import ydl2
import cv2

# 加载模板(只需一次)
model = ydl2.read_shape_model(r"model.yyds")

# 读图并创建图像句柄(首次)
mat = cv2.imread(r"image.jpg")
b, g, r = cv2.split(mat)
handle = ydl2.any_to_tiyoo(r, g, b)

# 匹配
results = ydl2.find_shape_model(handle, model)
for res in results:
    print(res['row'], res['col'], res['score'])

# 后续帧原地更新(零内存分配)
handle = ydl2.any_to_tiyoo(r, g, b, handle=handle)

# 释放
ydl2.clear_image(handle)
ydl2.clear_shape_model(model)

API

函数 说明
imread / imwrite / imshow 支持中文路径的读写与显示
scale_image_max 每通道 min/max 拉伸到 0–255
scale_image g' = g * Mult + Add
scale_image_range 区间线性映射
any_to_tiyoo numpy 数组 → Halcon 图像句柄(创建或原地更新)
tiyoo_to_any Halcon 图像句柄 → numpy 数组
read_image / write_image / clear_image Halcon 图像文件读写与释放
read_shape_model / clear_shape_model 加载 / 释放 Halcon 模板文件
find_shape_model 形状模板匹配,返回 [{'row', 'col', 'angle', 'score'}]

依赖

  • Python >= 3.8
  • numpy >= 1.21
  • opencv-python >= 4.6

链接

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ydl2-0.1.6.tar.gz (26.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ydl2-0.1.6-py3-none-any.whl (26.5 kB view details)

Uploaded Python 3

File details

Details for the file ydl2-0.1.6.tar.gz.

File metadata

  • Download URL: ydl2-0.1.6.tar.gz
  • Upload date:
  • Size: 26.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.6

File hashes

Hashes for ydl2-0.1.6.tar.gz
Algorithm Hash digest
SHA256 28d0044359679c1d96b6f555c78040f639d3072786a45ed2c5fb1f95c5313a50
MD5 41749f705ba99931f768af9b10163e7d
BLAKE2b-256 f85c54ed7a6b1bdfd89c902ce8d7061aba8666875ebae310f6a24c545446a022

See more details on using hashes here.

File details

Details for the file ydl2-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: ydl2-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 26.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.6

File hashes

Hashes for ydl2-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 023cd2ad13b4adf040fbf001c59934c34501cc9adf2de4f1ccd4576a58948592
MD5 4a4ba228b5e5810704fd4b8903f99eea
BLAKE2b-256 1d9ee9a3afd8cbcada48c2576ff4ca9dc3e08756ca5e49b0cc5c06081f85cd88

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page