簡體   English   中英

使用 pylibdmtx package 在樹莓派中使用 python 讀取數據矩陣

[英]read data matrix with python in raspberry pi using pylibdmtx package

我正在使用 libdmtx 使用 rasbian OS 解碼數據矩陣。 當我在 windows 中運行我的代碼時,我得到了完美的結果,但在 linux 中它不起作用。 這是我的簡單代碼,當我在 linux 中運行它時,變量“代碼”始終為空。 我沒有任何錯誤。 問題是什么?

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

檢查以確保您已在 Linux 上安裝了 libdmtx:

從存儲庫的自述文件中:“libdmtx DLL 包含在 Windows Python 輪子中。在其他操作系統上,您將需要安裝 libdmtx 共享庫。”

那是我的第一個猜測。

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

超時太低了。 嘗試不超時

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM