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.7.tar.gz (28.8 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.7-py3-none-any.whl (28.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ydl2-0.1.7.tar.gz
  • Upload date:
  • Size: 28.8 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.7.tar.gz
Algorithm Hash digest
SHA256 b7d35ddcafe611ed374fb1adac2f34eea7b70c391f229016a1af08b7a980d12d
MD5 45d5aea8e0f51dade8adeed92687a170
BLAKE2b-256 b758ca059a546cbf421ad7efb3135a84b38b630844d6a02a5b8457a633746eac

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ydl2-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 28.6 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.7-py3-none-any.whl
Algorithm Hash digest
SHA256 9c201ddf74a46985f7625c5aa40aa07711be98b5e7e9c1825c48abc98c9d9b21
MD5 b3ba431d8da2bb28538de8deee3c9eb4
BLAKE2b-256 9b3e2dea002b81c5144b1a8f46bc92f34f03093289ed456cd923cbb43facae91

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