python - opencv python 七段数字检测与ocr
问题描述
我的算法是
rgb -> gray -> blur -> 二值化(用于纠正背景的不均匀性)-> dilate -> otsu ->morphologyEX
gray = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)
blurred = cv2.GaussianBlur(gray, (3, 3), 0)
se = cv2.getStructuringElement(cv2.MORPH_RECT, (10, 10))
bg = cv2.morphologyEx(blurred, cv2.MORPH_DILATE, se)
out_gray = cv2.divide(blurred, bg, scale=255)
out_binary = cv2.threshold(out_gray, 0, 255, cv2.THRESH_BINARY_INV | cv2.THRESH_OTSU)[1]
# kernel = np.ones((2, 2), np.uint8)
kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (1, 3))
result = cv2.morphologyEx(out_binary, cv2.MORPH_CLOSE, kernel)
我想输出 [3 0 3 8 6 7 0 8 1]
解决方案
推荐阅读
- ios - 使用“https”作为深度链接swift 4中的url模式在应用程序委托中未调用打开url方法
- powershell - 函数中可选但互斥的开关
- marklogic - ADMIN-DUPLICATECONFIGITEM:数据库资源“hrhub-content”已经内容数据库“element-attribute-range-index
- ddos - 在 DDOS 攻击后,我无法再访问我的网站了
- javascript - Javascript:promise.resolve() 语句有效吗?
- machine-learning - ANN 结果是否应该根据输出而改变?
- python - 使用 python 脚本获取证书大小
- mysql - 如何使用 dbfit 访问多个数据集?
- asp.net-core - 如何在 ASP.NET Boilerplate (ASP.NET Core) 中更改应用服务的响应格式?
- python - 为什么 Python 浮点数有 real 和 imag 属性?