qrtool: Slightly lower min size for qr

This commit is contained in:
Fam Zheng 2025-09-14 18:22:26 +01:00
parent 31463f518a
commit 30dabc6f82
5 changed files with 25 additions and 25 deletions

View File

@ -95,9 +95,12 @@ bool detect_qr(ProcessState &ps, float margin_ratio, bool warp, string &err)
} }
int qr_width = max_x - min_x; int qr_width = max_x - min_x;
int qr_height = max_y - min_y; int qr_height = max_y - min_y;
if (qr_width < 200 && qr_height < 200 && qr_width < ps.orig->cols * 0.5 && qr_height < ps.orig->rows * 0.5) { float min_ratio = 0.3;
printf("(%d, %d) in (%d, %d)\n", qr_width, qr_height, ps.orig->cols, ps.orig->rows); int min_width = std::max(180, (int)(ps.orig->cols * min_ratio));
err = "qr too small"; int min_height = std::max(180, (int)(ps.orig->rows * min_ratio));
if (qr_width < min_width && qr_height < min_height) {
err = string_format("qr too small: %d x %d, thres: %d x %d",
qr_width, qr_height, min_width, min_height);
return false; return false;
} }

View File

@ -562,11 +562,20 @@ Page({
* Handle QR processing result * Handle QR processing result
*/ */
handleQRResult(result, frame, copiedFrameData = null) { handleQRResult(result, frame, copiedFrameData = null) {
// Update debug info if available // Update debug info - prioritize WASM debug image, fallback to original frame
if (result.debug_data_url) { if (this.data.enable_debug) {
this.setData({ if (result.debug_data_url) {
debug_image_data_url: result.debug_data_url // Priority 1: WASM returned a processed debug image (with QR detection overlay, etc.)
}); this.setData({
debug_image_data_url: result.debug_data_url
});
} else if (this.data.debug_current_frame_url) {
// Priority 2: No WASM debug image available, show the raw camera frame
this.setData({
debug_image_data_url: this.data.debug_current_frame_url
});
}
// If neither exists, the debug image box will remain empty/previous image
} }
// Generate hint text // Generate hint text
@ -576,7 +585,7 @@ Page({
// don't require ok as we only care about the view has a valid qrcode in it // don't require ok as we only care about the view has a valid qrcode in it
// zooming in so that it's more likely to be clear enough for upload // zooming in so that it's more likely to be clear enough for upload
if (result.qrcode && result.valid_pattern && is_emblem_qr_pattern(result.qrcode)) { if (result.qrcode && result.valid_pattern && is_emblem_qr_pattern(result.qrcode)) {
this.addDebugMessage(`QR detected and ready: ${result.qrcode}`); this.addDebugMessage(`QR detected: ${result.qrcode} ok: ${result.ok}: err ${result.err}`);
// Trigger zoom-in if function is set up // Trigger zoom-in if function is set up
if (!this.data.first_qr_found && this.on_first_qr_found) { if (!this.data.first_qr_found && this.on_first_qr_found) {
@ -785,7 +794,7 @@ Page({
updateDebugFrameUrls(frameDataUrl) { updateDebugFrameUrls(frameDataUrl) {
if (!this.data.enable_debug) return; if (!this.data.enable_debug) return;
// Just show the current frame // Store current frame URL for potential use as fallback
this.setData({ this.setData({
debug_current_frame_url: frameDataUrl debug_current_frame_url: frameDataUrl
}); });

View File

@ -23,7 +23,8 @@
<!-- WeChat native camera --> <!-- WeChat native camera -->
<camera class="camera" <camera class="camera"
flash="{{ camera_flash }}" flash="{{ camera_flash }}"
frame-size="medium" frame-size="large"
resolution="high"
bindinitdone="onCameraReady" bindinitdone="onCameraReady"
binderror="onCameraError"> binderror="onCameraError">
</camera> </camera>
@ -73,9 +74,7 @@
<view class="debug-top-row"> <view class="debug-top-row">
<view class="debug-image-box"> <view class="debug-image-box">
<image src="{{ debug_image_data_url }}"></image> <image src="{{ debug_image_data_url }}"></image>
</view> <view class="debug-label">Debug Frame</view>
<view class="debug-frame-box">
<image src="{{ debug_current_frame_url }}"></image>
</view> </view>
<view class="debug-info-panel"> <view class="debug-info-panel">
<view class="debug-items"> <view class="debug-items">

View File

@ -219,17 +219,6 @@ view.debug {
border: 1px solid rgba(239, 72, 35, 0.8); border: 1px solid rgba(239, 72, 35, 0.8);
} }
.debug-frame-box {
flex-shrink: 0;
}
.debug-frame-box image {
width: 64px;
height: 64px;
border: 1px solid rgba(35, 150, 239, 0.8);
}
.debug-frame-box .debug-label,
.debug-image-box .debug-label { .debug-image-box .debug-label {
font-size: 8px; font-size: 8px;
color: #ffffff; color: #ffffff;