Skip to content

Commit 8102a74

Browse files
Time QR decoding and add kdmukai's speedups
240x240 image decoding goes from 1800ms to 406ms. Thanks, @kdmukai!
1 parent d0444f1 commit 8102a74

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

c_mpos/micropython.cmake

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,18 @@ target_sources(usermod_c_mpos INTERFACE ${MPOS_C_SOURCES})
2121
# Add include directories.
2222
target_include_directories(usermod_c_mpos INTERFACE ${MPOS_C_INCLUDES})
2323

24+
25+
target_compile_definitions(usermod_c_mpos INTERFACE
26+
# force quirc to use single precision floating point math
27+
-DQUIRC_FLOAT_TYPE=float
28+
-DQUIRC_USE_TGMATH=1
29+
)
30+
31+
# Be sure to set the -O2 "optimize" flag!!
32+
target_compile_options(usermod_c_mpos INTERFACE
33+
-O2
34+
)
35+
2436
# Link our INTERFACE library to the usermod target.
2537
target_link_libraries(usermod INTERFACE usermod_c_mpos)
2638

internal_filesystem/apps/com.micropythonos.camera/assets/camera_app.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,15 @@ def set_image_size(self):
171171
def qrdecode_one(self):
172172
try:
173173
import qrdecode
174+
import utime
175+
before = utime.ticks_ms()
174176
result = qrdecode.qrdecode_rgb565(self.current_cam_buffer, self.width, self.height)
177+
after = utime.ticks_ms()
175178
#result = bytearray("INSERT_QR_HERE", "utf-8")
176179
if not result:
177180
self.status_label.set_text(self.status_label_text_searching)
178181
else:
182+
print(f"SUCCESSFUL QR DECODE TOOK: {after-before}ms")
179183
result = remove_bom(result)
180184
result = print_qr_buffer(result)
181185
print(f"QR decoding found: {result}")

0 commit comments

Comments
 (0)