We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trying to feed a PNG buffer to np.frombuffer and getting a buffer size error.
np.frombuffer
New to Python... would someone happen to know what is going on and how to fix this?
from cv2 import cv2 import pyqrcode import io import numpy as np import sys buffer = io.BytesIO() qr = pyqrcode.create("foo") qr.png(buffer, scale=2) array = np.frombuffer(buffer.getvalue()) image = cv2.imdecode(array, cv2.IMREAD_COLOR) cv2.imshow('QR code', image) cv2.waitKey(0) cv2.destroyAllWindows() sys.exit()
Thanks!
The text was updated successfully, but these errors were encountered:
Found a fix... does the following code look good to you?
from cv2 import cv2 import pyqrcode import io import numpy as np import sys buffer = io.BytesIO() qr = pyqrcode.create("foo") qr.png(buffer, scale=2) buffer.seek(0) array = np.asarray(bytearray(buffer.read()), dtype=np.uint8) image = cv2.imdecode(array, cv2.IMREAD_COLOR) cv2.imshow('QR code', image) cv2.waitKey(0) cv2.destroyAllWindows() sys.exit()
Sorry, something went wrong.
thank you so much! It actually worked!
No branches or pull requests
Trying to feed a PNG buffer to
np.frombuffer
and getting a buffer size error.New to Python... would someone happen to know what is going on and how to fix this?
Thanks!
The text was updated successfully, but these errors were encountered: