【问题标题】:read data matrix with python in raspberry pi using pylibdmtx package使用 pylibdmtx 包在树莓派中使用 python 读取数据矩阵
【发布时间】:2021-04-22 11:59:14
【问题描述】:

我正在使用 libdmtx 来解码带有 rasbian OS 的数据矩阵。当我在 Windows 中运行我的代码时,我得到了完美的结果,但在 linux 中它不起作用。 这是我的简单代码,当我在 linux 中运行它时,变量“code”始终为空。我没有任何错误。有什么问题?

import cv2 
import time
from pylibdmtx.pylibdmtx import decode

cap = cv2.VideoCapture(0)
cap.set(3,640)
cap.set(4,480)

while True:
    ret,img = cap.read()
    
    cv2.waitKey(1)
    t0 = time.time()
    code = decode(img, timeout=100, max_count=1, corrections=3)
    if(code):
        print((time.time() - t0)*1000)
        print(code)
        print(code[0].data.decode('utf-8'))
        print(code[0].rect)    
        #x,y,w,h = code[0].rect
        #cv2.rectangle(img,(x,y),(x+w,480-y-h),(255,0,255),2)
        
    cv2.imshow('Result',img)    
        
    if cv2.waitKey(1) == 27:
        break

【问题讨论】:

  • 两种环境中是否安装了相同的库?

标签: python linux raspberry-pi


【解决方案1】:

检查以确保您已在 Linux 上安装了 libdmtx:

来自存储库的自述文件: “libdmtx DLL 包含在 Windows Python 轮子中。在其他操作系统上,您需要安装 libdmtx 共享库。”

这是我的第一个猜测。

【讨论】:

  • 您应该编辑您的答案。不要说这是您的猜测,请提供程序,以便其他有相同问题的人可以快速应用您的解决方案
【解决方案2】:
 code = decode(img, timeout=100, max_count=1, corrections=3)

超时时间过低。尝试不超时

code = decode(img, max_count=1, corrections=3)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-04-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多