You've already forked MicroPythonOS
mirror of
https://github.com/m5stack/MicroPythonOS.git
synced 2026-05-20 11:51:27 -07:00
Fix colormode QR decoding
But somehow buffer size is 8 bytes...
This commit is contained in:
@@ -39,10 +39,10 @@ static mp_obj_t qrdecode(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
if (width <= 0 || height <= 0) {
|
||||
mp_raise_ValueError(MP_ERROR_TEXT("width and height must be positive"));
|
||||
}
|
||||
QRDECODE_DEBUG_PRINT("qrdecode bufsize: %u bytes\n", bufinfo.len);
|
||||
if (bufinfo.len != (size_t)(width * height)) {
|
||||
mp_raise_ValueError(MP_ERROR_TEXT("buffer size must match width * height"));
|
||||
}
|
||||
|
||||
struct quirc *qr = quirc_new();
|
||||
if (!qr) {
|
||||
mp_raise_OSError(MP_ENOMEM);
|
||||
@@ -139,6 +139,7 @@ static mp_obj_t qrdecode_rgb565(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
if (width <= 0 || height <= 0) {
|
||||
mp_raise_ValueError(MP_ERROR_TEXT("width and height must be positive"));
|
||||
}
|
||||
QRDECODE_DEBUG_PRINT("qrdecode bufsize: %u bytes\n", bufinfo.len);
|
||||
if (bufinfo.len != (size_t)(width * height * 2)) {
|
||||
mp_raise_ValueError(MP_ERROR_TEXT("buffer size must match width * height * 2 for RGB565"));
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import lvgl as lv
|
||||
import time
|
||||
|
||||
try:
|
||||
import webcam
|
||||
@@ -16,8 +17,8 @@ class CameraApp(Activity):
|
||||
DEFAULT_WIDTH = 320 # 240 would be better but webcam doesn't support this (yet)
|
||||
DEFAULT_HEIGHT = 240
|
||||
PACKAGE = "com.micropythonos.camera"
|
||||
#DEFAULT_CONFIG = "config.json"
|
||||
#QRCODE_CONFIG = "config_qrmode.json"
|
||||
CONFIGFILE = "config.json"
|
||||
SCANQR_CONFIG = "config_scanqr_mode.json"
|
||||
|
||||
button_width = 60
|
||||
button_height = 45
|
||||
@@ -48,9 +49,9 @@ class CameraApp(Activity):
|
||||
status_label_cont = None
|
||||
|
||||
def onCreate(self):
|
||||
from mpos.config import SharedPreferences
|
||||
self.prefs = SharedPreferences(self.PACKAGE)
|
||||
self.scanqr_mode = self.getIntent().extras.get("scanqr_mode")
|
||||
from mpos.config import SharedPreferences
|
||||
self.prefs = SharedPreferences(self.PACKAGE, filename=self.SCANQR_CONFIG if self.scanqr_mode else self.CONFIGFILE)
|
||||
|
||||
self.main_screen = lv.obj()
|
||||
self.main_screen.set_style_pad_all(1, 0)
|
||||
@@ -219,7 +220,10 @@ class CameraApp(Activity):
|
||||
import qrdecode
|
||||
import utime
|
||||
before = time.ticks_ms()
|
||||
result = qrdecode.qrdecode(self.image_dsc.data, self.width, self.height)
|
||||
if self.colormode:
|
||||
result = qrdecode.qrdecode_rgb565(self.image_dsc.data, self.width, self.height)
|
||||
else:
|
||||
result = qrdecode.qrdecode(self.image_dsc.data, self.width, self.height)
|
||||
after = time.ticks_ms()
|
||||
#result = bytearray("INSERT_QR_HERE", "utf-8")
|
||||
if not result:
|
||||
|
||||
Reference in New Issue
Block a user