From 934c94030ab7fca93a5f2192d8256b97a37ae527 Mon Sep 17 00:00:00 2001 From: gb <741021719@qq.com> Date: Mon, 12 Sep 2022 12:27:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=9B=9B=E4=B8=AA=E6=96=B9?= =?UTF-8?q?=E4=BD=8D=E9=99=A4=E7=A9=BF=E5=AD=94=E4=B8=8E=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E9=80=9A=E4=BF=A1=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hgdriver/hgdev/common_setting.h | 4 ++++ hgdriver/hgdev/hg_scanner.cpp | 25 ++++++++++++++++++++++++- hgdriver/hgdev/hg_scanner.h | 9 ++++++--- hgdriver/hgdev/hg_scanner_200.cpp | 1 + hgdriver/hgdev/hg_scanner_239.cpp | 1 + hgdriver/hgdev/hg_scanner_300.cpp | 1 + hgdriver/hgdev/hg_scanner_302.cpp | 1 + hgdriver/hgdev/hg_scanner_400.cpp | 1 + hgdriver/hgdev/hg_scanner_402.cpp | 1 + hgdriver/hgdev/hg_scanner_439.cpp | 1 + 10 files changed, 41 insertions(+), 4 deletions(-) diff --git a/hgdriver/hgdev/common_setting.h b/hgdriver/hgdev/common_setting.h index c430860..41f5e92 100644 --- a/hgdriver/hgdev/common_setting.h +++ b/hgdriver/hgdev/common_setting.h @@ -835,6 +835,10 @@ typedef struct _scan_conf bool fadeback; /**< 背景除色>*/ int fadebackrange; bool isuoloadexceptionimage; /**< 是否保留双张出图>*/ + int fillholeratio_up; // 上侧除穿孔比率,0为不除。[0,50],added on 2022-09-12 + int fillholeratio_down; // 下侧除穿孔比率,0为不除。[0,50],added on 2022-09-12 + int fillholeratio_left; // 左侧除穿孔比率,0为不除。[0,50],added on 2022-09-12 + int fillholeratio_right; // 右侧除穿孔比率,0为不除。[0,50],added on 2022-09-12 uint32_t reserve[1024]; /**< 预留4096字节做协议扩展*/ }SCANCONF ,*LPSCANCONF; diff --git a/hgdriver/hgdev/hg_scanner.cpp b/hgdriver/hgdev/hg_scanner.cpp index 6fb6faf..bfff613 100644 --- a/hgdriver/hgdev/hg_scanner.cpp +++ b/hgdriver/hgdev/hg_scanner.cpp @@ -89,7 +89,7 @@ hg_scanner::hg_scanner(ScannerSerial serial , const char* dev_name, usb_io* io) : name_(dev_name ? dev_name : ""), io_(io), status_(SCANNER_ERR_NOT_START) , scan_count_(-1), run_(true), paper_size_(TwSS::A4), erase_bkg_range_(10) - , noise_range_(30), omit_empty_level_(50), resolution_(200), rid_hole_range_(.1f) + , noise_range_(30), omit_empty_level_(50), resolution_(200), rid_hole_range_(10.0f) , bright_(128), contrast_(4), gamma_(1.0f), threshold_(40), anti_noise_(8), margin_(5) , fractate_level_(50), ui_ev_cb_(ui_default_callback), scan_life_(NULL) , notify_setting_result_(false), user_cancel_(false), cb_mem_(true), test_1_paper_(false) @@ -2354,6 +2354,29 @@ int hg_scanner::save_final_image(hg_imgproc::LPIMGHEAD head, void* buf) else return SCANNER_ERR_INSUFFICIENT_MEMORY; } +void hg_scanner::adjust_filling_hole(LPSCANCONF conf) +{ + int maxval = 0; +#define SET_FILL_HOLE(member, me) \ + conf->fillholeratio_##member = isremove_##me##_hole ? isremove_##me##_hole_threshold * 100 + .5f : 0; \ + if(conf->fillholeratio_##member < 0) \ + conf->fillholeratio_##member = 0; \ + else if(conf->fillholeratio_##member > 50) \ + conf->fillholeratio_##member = 50; \ + if(maxval < conf->fillholeratio_##member) \ + maxval = conf->fillholeratio_##member; + + SET_FILL_HOLE(up, top); + SET_FILL_HOLE(down, low); + SET_FILL_HOLE(left, left); + SET_FILL_HOLE(right, right); + + if (maxval) + { + conf->fillhole.is_fillhole = true; + conf->fillhole.fillholeratio = maxval; + } +} int hg_scanner::is_running(void) { if (!scan_life_) diff --git a/hgdriver/hgdev/hg_scanner.h b/hgdriver/hgdev/hg_scanner.h index e1e4143..d2b2161 100644 --- a/hgdriver/hgdev/hg_scanner.h +++ b/hgdriver/hgdev/hg_scanner.h @@ -198,11 +198,12 @@ protected: protected: volatile bool run_; volatile bool user_cancel_; - platform_event wait_usb_; - platform_event wait_img_; - platform_event wait_usb_result_; + platform_event wait_usb_; + platform_event wait_img_; + platform_event wait_usb_result_; usb_io* io_; std::mutex io_lock_; + std::string firmware_ver_; bool online_; int status_; bool async_io_; @@ -274,6 +275,8 @@ protected: int save_usb_data(std::shared_ptr data); int save_final_image(hg_imgproc::LPIMGHEAD head, void* buf); + void adjust_filling_hole(LPSCANCONF conf); + enum thread_running { THREAD_RUNNING_IDLE = 0, diff --git a/hgdriver/hgdev/hg_scanner_200.cpp b/hgdriver/hgdev/hg_scanner_200.cpp index 5a92d8c..4265670 100644 --- a/hgdriver/hgdev/hg_scanner_200.cpp +++ b/hgdriver/hgdev/hg_scanner_200.cpp @@ -1020,6 +1020,7 @@ else ic.fillhole.is_fillhole = image_prc_param_.bits.rid_hole; ic.fillhole.fillholeratio = rid_hole_range_; + adjust_filling_hole(&ic); ic.detachnoise.is_detachnoise = image_prc_param_.bits.noise_optimize; ic.detachnoise.detachnoise = noise_range_; diff --git a/hgdriver/hgdev/hg_scanner_239.cpp b/hgdriver/hgdev/hg_scanner_239.cpp index cf827e0..7d43b7f 100644 --- a/hgdriver/hgdev/hg_scanner_239.cpp +++ b/hgdriver/hgdev/hg_scanner_239.cpp @@ -926,6 +926,7 @@ int hg_scanner_239::writedown_image_configuration(void) ic.hardwarecaps.lowpowermode = LowPowerMode::Min_None; //暂无参数 设置休眠时间 两个参数3399未使用 ic.fillhole.is_fillhole = image_prc_param_.bits.rid_hole; ic.fillhole.fillholeratio = rid_hole_range_; + adjust_filling_hole(&ic); ic.detachnoise.is_detachnoise = image_prc_param_.bits.noise_optimize; ic.detachnoise.detachnoise = noise_range_; ic.is_autotext = image_prc_param_.bits.text_direction == TEXT_DIRECTION_AUTO ? 1 :0; diff --git a/hgdriver/hgdev/hg_scanner_300.cpp b/hgdriver/hgdev/hg_scanner_300.cpp index dfc9230..15801ba 100644 --- a/hgdriver/hgdev/hg_scanner_300.cpp +++ b/hgdriver/hgdev/hg_scanner_300.cpp @@ -946,6 +946,7 @@ void hg_scanner_300::writedown_image_configuration(void) ic.hardwarecaps.lowpowermode = LowPowerMode::Min_None; //暂无参数 设置休眠时间 两个参数3399未使用 ic.fillhole.is_fillhole = image_prc_param_.bits.rid_hole; ic.fillhole.fillholeratio = rid_hole_range_; + adjust_filling_hole(&ic); ic.detachnoise.is_detachnoise = image_prc_param_.bits.noise_optimize; ic.detachnoise.detachnoise = noise_range_; ic.is_autotext = image_prc_param_.bits.text_direction == TEXT_DIRECTION_AUTO ? 1 :0; diff --git a/hgdriver/hgdev/hg_scanner_302.cpp b/hgdriver/hgdev/hg_scanner_302.cpp index 50fa415..620eca3 100644 --- a/hgdriver/hgdev/hg_scanner_302.cpp +++ b/hgdriver/hgdev/hg_scanner_302.cpp @@ -1023,6 +1023,7 @@ int hg_scanner_302::writedown_image_configuration(void) ic.hardwarecaps.lowpowermode = LowPowerMode::Min_None; //暂无参数 设置休眠时间 两个参数3399未使用 ic.fillhole.is_fillhole = image_prc_param_.bits.rid_hole; ic.fillhole.fillholeratio = rid_hole_range_; + adjust_filling_hole(&ic); ic.detachnoise.is_detachnoise = image_prc_param_.bits.noise_optimize; ic.detachnoise.detachnoise = noise_range_; ic.is_autotext = image_prc_param_.bits.text_direction == TEXT_DIRECTION_AUTO ? 1 :0; diff --git a/hgdriver/hgdev/hg_scanner_400.cpp b/hgdriver/hgdev/hg_scanner_400.cpp index 4917a40..dadf40e 100644 --- a/hgdriver/hgdev/hg_scanner_400.cpp +++ b/hgdriver/hgdev/hg_scanner_400.cpp @@ -955,6 +955,7 @@ void hg_scanner_400::writedown_image_configuration(void) ic.fillhole.is_fillhole = image_prc_param_.bits.rid_hole; ic.fillhole.fillholeratio = rid_hole_range_; + adjust_filling_hole(&ic); ic.detachnoise.is_detachnoise = image_prc_param_.bits.noise_optimize; ic.detachnoise.detachnoise = noise_range_; diff --git a/hgdriver/hgdev/hg_scanner_402.cpp b/hgdriver/hgdev/hg_scanner_402.cpp index fd1407e..c09dc85 100644 --- a/hgdriver/hgdev/hg_scanner_402.cpp +++ b/hgdriver/hgdev/hg_scanner_402.cpp @@ -1028,6 +1028,7 @@ int hg_scanner_402::writedown_image_configuration(void) ic.hardwarecaps.lowpowermode = LowPowerMode::Min_None; //暂无参数 设置休眠时间 两个参数3399未使用 ic.fillhole.is_fillhole = image_prc_param_.bits.rid_hole; ic.fillhole.fillholeratio = rid_hole_range_; + adjust_filling_hole(&ic); ic.detachnoise.is_detachnoise = image_prc_param_.bits.noise_optimize; ic.detachnoise.detachnoise = noise_range_; ic.is_autotext = image_prc_param_.bits.text_direction == TEXT_DIRECTION_AUTO ? 1 :0; diff --git a/hgdriver/hgdev/hg_scanner_439.cpp b/hgdriver/hgdev/hg_scanner_439.cpp index 7274ce1..e2dd936 100644 --- a/hgdriver/hgdev/hg_scanner_439.cpp +++ b/hgdriver/hgdev/hg_scanner_439.cpp @@ -898,6 +898,7 @@ int hg_scanner_439::writedown_image_configuration(void) ic.hardwarecaps.lowpowermode = LowPowerMode::Min_None; //暂无参数 设置休眠时间 两个参数3399未使用 ic.fillhole.is_fillhole = image_prc_param_.bits.rid_hole; ic.fillhole.fillholeratio = rid_hole_range_; + adjust_filling_hole(&ic); ic.detachnoise.is_detachnoise = image_prc_param_.bits.noise_optimize; ic.detachnoise.detachnoise = noise_range_; ic.is_autotext = image_prc_param_.bits.text_direction == TEXT_DIRECTION_AUTO ? 1 :0;