Skip to content
New issue

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

Fix QR scanning demo #5

Merged
merged 1 commit into from
Dec 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 5 additions & 12 deletions examples/qrio/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,26 @@

import time

import bitmaptools
import displayio
import espcamera
import qrio

from adafruit_pycamera import PyCamera

zoomed = displayio.Bitmap(240, 176, 65535)
pycam = PyCamera()
pycam.camera.reconfigure(
pixel_format=espcamera.PixelFormat.RGB565,
frame_size=espcamera.FrameSize.VGA,
)
pycam._mode_label.text = "QR SCAN" # pylint: disable=protected-access
pycam._res_label.text = "" # pylint: disable=protected-access
pycam.effect = 0
pycam.camera.hmirror = False
pycam.display.refresh()
qrdecoder = qrio.QRDecoder(zoomed.width, zoomed.height)
qrdecoder = qrio.QRDecoder(pycam.camera.width, pycam.camera.height)

old_payload = None
while True:
new_frame = pycam.continuous_capture()
if new_frame is None:
continue
bitmaptools.blit(zoomed, new_frame, 0, 0, x1=(640 - 240) // 2, y1=(480 - 176) // 2)
pycam.blit(zoomed)
for row in qrdecoder.decode(zoomed, qrio.PixelPolicy.RGB565_SWAPPED):
pycam.blit(new_frame)
for row in qrdecoder.decode(new_frame, qrio.PixelPolicy.RGB565_SWAPPED):
print(row)
payload = row.payload
try:
payload = payload.decode("utf-8")
Expand Down