|
10 | 10 | #include "utils/malloc_ext.h" |
11 | 11 | #include "utils/util.h" |
12 | 12 |
|
13 | | -#define SCAN_EXTRA_MARGIN 20 |
| 13 | +#define SCAN_MARGIN 20 |
14 | 14 |
|
15 | 15 | // Inspect qrcodes and try to extract payload - whether any were seen and any |
16 | 16 | // string data extracted are stored in the qr_data struct passed. |
@@ -131,17 +131,14 @@ bool scan_qr(const size_t width, const size_t height, const uint8_t* data, const |
131 | 131 | qr_data->ds = JADE_MALLOC_DRAM(sizeof(struct datastream)); |
132 | 132 | JADE_ASSERT(qr_data->ds); |
133 | 133 |
|
134 | | - // Also correctly size the internal image buffer since we know the size of the camera images/display. |
135 | | - const uint16_t ideal_scan_box_size |
136 | | - = min_u16(camera_displayed_image_width(), camera_displayed_image_height()) + SCAN_EXTRA_MARGIN; |
137 | | - const uint16_t scan_width = min_u16(ideal_scan_box_size, CAMERA_IMAGE_WIDTH); |
138 | | - const uint16_t scan_height = min_u16(ideal_scan_box_size, CAMERA_IMAGE_HEIGHT); |
139 | | - const int qret = quirc_resize(qr_data->q, scan_width, scan_height); |
| 134 | + // Also correctly size the internal image buffer since we know the size of the camera images. |
| 135 | + const uint16_t scan_width = min_u16(CAMERA_IMAGE_WIDTH, CAMERA_IMAGE_HEIGHT) - SCAN_MARGIN; |
| 136 | + const int qret = quirc_resize(qr_data->q, scan_width, scan_width); |
140 | 137 | JADE_ASSERT(qret == 0); |
141 | 138 | qr_data->len = 0; |
142 | 139 |
|
143 | | - JADE_LOGI("SCAN WIDTH: %u", scan_width); |
144 | | - JADE_LOGI("SCAN HEIGHT: %u", scan_height); |
| 140 | + JADE_LOGE("SCAN WIDTH: %u", scan_width); |
| 141 | + JADE_LOGE("SCAN HEIGHT: %u", scan_width); |
145 | 142 |
|
146 | 143 | const bool ret = qr_recognize(width, height, data, len, qr_data); |
147 | 144 |
|
@@ -174,18 +171,15 @@ bool jade_camera_scan_qr( |
174 | 171 | qr_data->ds = JADE_MALLOC_DRAM(sizeof(struct datastream)); |
175 | 172 | JADE_ASSERT(qr_data->ds); |
176 | 173 |
|
177 | | - // Also correctly size the internal image buffer since we know the size of the camera images/display. |
| 174 | + // Also correctly size the internal image buffer since we know the size of the camera images. |
178 | 175 | // This image buffer is then reused for every camera image frame processed. |
179 | | - const uint16_t ideal_scan_box_size |
180 | | - = min_u16(camera_displayed_image_width(), camera_displayed_image_height()) + SCAN_EXTRA_MARGIN; |
181 | | - const uint16_t scan_width = min_u16(ideal_scan_box_size, CAMERA_IMAGE_WIDTH); |
182 | | - const uint16_t scan_height = min_u16(ideal_scan_box_size, CAMERA_IMAGE_HEIGHT); |
183 | | - const int qret = quirc_resize(qr_data->q, scan_width, scan_height); |
| 176 | + const uint16_t scan_width = min_u16(CAMERA_IMAGE_WIDTH, CAMERA_IMAGE_HEIGHT) - SCAN_MARGIN; |
| 177 | + const int qret = quirc_resize(qr_data->q, scan_width, scan_width); |
184 | 178 | JADE_ASSERT(qret == 0); |
185 | 179 | qr_data->len = 0; |
186 | 180 |
|
187 | | - JADE_LOGI("SCAN WIDTH: %u", scan_width); |
188 | | - JADE_LOGI("SCAN HEIGHT: %u", scan_height); |
| 181 | + JADE_LOGE("SCAN WIDTH: %u", scan_width); |
| 182 | + JADE_LOGE("SCAN HEIGHT: %u", scan_width); |
189 | 183 |
|
190 | 184 | // Run the camera task trying to interpet frames as qr-codes |
191 | 185 | const bool show_camera_ui = true; |
|
0 commit comments