【问题标题】:How to read data matrix code in Python?如何在 Python 中读取数据矩阵代码?
【发布时间】:2018-02-08 13:25:33
【问题描述】:

我想知道如何在 python 中使用 openCV 读取数据矩阵条码

我找到了How to locate and read Data Matrix code with python,但这对我来说仍然不清楚。我想显示读取条码的结果输出。

【问题讨论】:

  • 你采样数据?你试过什么?什么是错误信息?
  • 样本数据 image.png 我试图解码数据矩阵,我在第二篇文章中只得到了 5 张类似这个人的图片。我想解码数据矩阵,但我不知道该怎么做。你知道一些教程吗?

标签: python opencv datamatrix


【解决方案1】:

好的,几天后我找到了解决方案:

import cv2
from pylibdmtx.pylibdmtx import decode
import ctypes  

def Mbox(title, text, style):
    return ctypes.windll.user32.MessageBoxW(0, text, title, style)

# Read file using OpenCV
Mbox('Data Matrix', str(decode(cv2.imread('C:/Users/User/Desktop/Zdjecia_QrCode/again2.png'))), 1)

但我想知道如何提高阅读能力,因为我无法阅读每个数据矩阵。你有什么想法吗?

【讨论】:

  • 你终于找到解决办法了吗?我面临着类似的问题。我可以阅读一些数据矩阵,但不是全部!如果您能分享您的经验,我将不胜感激。
【解决方案2】:
import numpy as np
import cv2
from pylibdmtx import pylibdmtx

if __name__ == '__main__':

    image = cv2.imread('datamatrix_sample1_130x116.png', cv2.IMREAD_UNCHANGED);

    gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

    ret,thresh = cv2.threshold(gray, 0, 255, cv2.THRESH_BINARY | cv2.THRESH_OTSU)

    msg = pylibdmtx.decode(thresh)
    print(msg)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-14
    • 2016-04-19
    • 1970-01-01
    • 1970-01-01
    • 2017-08-20
    • 1970-01-01
    相关资源
    最近更新 更多