sparkfish / pdf417decoder Goto Github PK
View Code? Open in Web Editor NEWPDF417 Decoder available in Python
PDF417 Decoder available in Python
I am trying to install pdf417decoder. I am using command:
pip install pdf417decoder
but everytime I get following error :
ERROR: Could not find a version that satisfies the requirement pdf417decoder (from versions: none)
ERROR: No matching distribution found for pdf417decoder
Can you please help me out to install the package
I noticed that barcodes which don't have any padding cannot be decoded. I'm using the following code to test:
import sys
from PIL import Image
from pdf417decoder import PDF417Decoder
image = Image.open(sys.argv[1])
decoder = PDF417Decoder(image)
if decoder.decode() > 0:
decoded = decoder.barcode_data_index_to_string(0)
print(decoded)
else:
print("cannot decode")
The following image cannot be decoded:
While the following image can:
Images are the same, except that second image has 1px of white padding around the barcode, while the first image touches the image borders.
Whenever I try to run the decoder.decode() dommand, I get the following error. Do you have any suggestions? Thanks!
UnboundLocalError: local variable 'codewords_ptr' referenced before assignment
this is the code i tried :
from pdf417decoder import PDF417Decoder
import matplotlib.pyplot as plt
import cv2
from PIL import Image
npimg = cv2.imread("/content/bar.png")
image = Image.fromarray(npimg)
plt.imshow(image)
decoder = PDF417Decoder(image)
if (decoder.decode() > 0):
print('decoding')
decoded = decoder.barcode_data_index_to_string(0)
else:
print('could not decode')
for this high resolution image : https://i.ibb.co/SypTDfh/bar.png
also cropped the barcode region and tried again,,no luck,always failing to decode(returns nothing)
Reading through the stack trace it appears it's looking for ffmpeg
.
I don't know if this is something that can be fixed in this repo/library but I figured I'd report it so that it's known and what the fix is.
Computer: Apple MacBook Pro 16" with Apple Silicon M1
Running Python 3.9.6 in Terminal.app
>>> import pdf417decoder
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/python3.9/site-packages/pdf417decoder/__init__.py", line 1, in <module>
from pdf417decoder.Decoder import PDF417Decoder
File "/python3.9/site-packages/pdf417decoder/Decoder.py", line 4, in <module>
import cv2
File "/python3.9/site-packages/cv2/__init__.py", line 5, in <module>
from .cv2 import *
ImportError: dlopen(/python3.9/site-packages/cv2/cv2.cpython-39-darwin.so, 2): Library not loaded: /opt/homebrew/opt/ffmpeg/lib/libavcodec.58.dylib
Referenced from: /python3.9/site-packages/cv2/cv2.cpython-39-darwin.so
Reason: image not found
I installed ffmpeg
through Homebrew and it ran fine.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.