From 0bd8a93f14a4f2c44ada7e27eef57efa38d8af63 Mon Sep 17 00:00:00 2001 From: Fam Zheng Date: Thu, 20 Mar 2025 23:10:46 -0700 Subject: [PATCH] alg: Factor in camera_sensitivity in sobel check --- alg/libqr.cpp | 2 +- alg/libqr.h | 1 + alg/qrtool_wasm.cpp | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/alg/libqr.cpp b/alg/libqr.cpp index 16f1618..c7827e7 100644 --- a/alg/libqr.cpp +++ b/alg/libqr.cpp @@ -242,7 +242,7 @@ bool check_blur_by_laplacian(ProcessState &ps, Mat &gray, string &err) static bool check_blur_by_sobel(ProcessState &ps, Mat &gray, string &err) { - const float thres = 15; + const float thres = ps.sobel_thres; Mat sobel_x, sobel_y; Sobel(gray, sobel_x, CV_64F, 1, 0, 3); Sobel(gray, sobel_y, CV_64F, 0, 1, 3); diff --git a/alg/libqr.h b/alg/libqr.h index ffc06c1..bd69077 100644 --- a/alg/libqr.h +++ b/alg/libqr.h @@ -25,6 +25,7 @@ struct ProcessState { string qrcode = ""; double clarity; float laplacian_thres = 0.1; + float sobel_thres = 15; int sharpness_method = 2; }; diff --git a/alg/qrtool_wasm.cpp b/alg/qrtool_wasm.cpp index 6cfd914..88910a4 100644 --- a/alg/qrtool_wasm.cpp +++ b/alg/qrtool_wasm.cpp @@ -29,6 +29,7 @@ const char *qrtool_angle(uint8_t *data, float camera_sensitivity) { ProcessState ps; ps.laplacian_thres = camera_sensitivity / 10.0; + ps.sobel_thres = camera_sensitivity * 15; auto start = std::chrono::system_clock::now(); static char ret[512]; printf("qrtool_angle, width: %d height %d\n", width, height);