239增加镜头脏污检测功能

This commit is contained in:
yangjiaxuan 2023-10-25 15:00:31 +08:00
parent e6080d803f
commit 392fc37f30
6 changed files with 50 additions and 8 deletions

View File

@ -615,6 +615,13 @@ typedef struct _scan_conf
uint8_t fold_concatmode; /**< 对折拼接模式 0左右,1上下2自动对折>*/ uint8_t fold_concatmode; /**< 对折拼接模式 0左右,1上下2自动对折>*/
int HsvFilterType; /**< 答题卡留红出杂色功能类型 暂定为0*/ int HsvFilterType; /**< 答题卡留红出杂色功能类型 暂定为0*/
bool is_colorcast; /**< 色偏校正*/ bool is_colorcast; /**< 色偏校正*/
int discare_edge; /**< 跳过空白页边缘缩进>*/
int discare_dilate; /**< 调过空白页纸张杂点阈值>*/
double discare_meanth; /**< 调过空白页文稿底色阈值>*/
bool en_contaminationdetection; /**< 脏污检测使能>*/
uint8_t contaminationdetection_threshold_1; /**< 脏污检测第一阈值,超过该阈值视为存在脏污>*/
uint8_t contaminationdetection_threshold_2; /**< 脏污检测第二阈值配合width使用超过该阈值且连续宽度达到width视为存在脏污>*/
uint32_t contaminationdetection_width; /**< 脏污检测宽度配合threshold2使用>*/
uint32_t reserve[1024]; /**< 预留4096字节做协议扩展*/ uint32_t reserve[1024]; /**< 预留4096字节做协议扩展*/
}SCANCONF ,*LPSCANCONF; }SCANCONF ,*LPSCANCONF;
//图像参数设置 -OVER //图像参数设置 -OVER

View File

@ -670,6 +670,7 @@ void hg_scanner::init_setting_func_map(void)
setting_map_[SANE_STD_OPT_NAME_COLOR_CORRECTION] = &hg_scanner::setting_color_correction; setting_map_[SANE_STD_OPT_NAME_COLOR_CORRECTION] = &hg_scanner::setting_color_correction;
setting_map_[SANE_STD_OPT_NAME_WAIT_SCAN_EXIT] = &hg_scanner::setting_auto_paper_scan_exit_time; setting_map_[SANE_STD_OPT_NAME_WAIT_SCAN_EXIT] = &hg_scanner::setting_auto_paper_scan_exit_time;
setting_map_[SANE_STD_OPT_NAME_DISCARDBLANK] = &hg_scanner::setting_set_discardblank; setting_map_[SANE_STD_OPT_NAME_DISCARDBLANK] = &hg_scanner::setting_set_discardblank;
setting_map_[SANE_STD_OPT_NAME_LENS_DIRTY] = &hg_scanner::setting_detect_lens_dirty;
@ -1220,6 +1221,9 @@ void hg_scanner::working_done(void*)
case SCANNER_ERR_DEVICE_DEVS_BOOTING: case SCANNER_ERR_DEVICE_DEVS_BOOTING:
notify_ui_working_status(from_default_language(STATU_DESC_SCANNER_ERR_DEVICE_DEVS_BOOTING), SANE_EVENT_SCAN_FINISHED, status_); notify_ui_working_status(from_default_language(STATU_DESC_SCANNER_ERR_DEVICE_DEVS_BOOTING), SANE_EVENT_SCAN_FINISHED, status_);
break; break;
case SCANNER_ERR_DEVICE_LENS_DIRTY:
notify_ui_working_status(from_default_language(STATU_DESC_SCANNER_ERR_DEVICE_LENS_DIRTY), SANE_EVENT_SCAN_FINISHED, status_);
break;
default: default:
notify_ui_working_status(user_cancel_ ? hg_log::lang_load(ID_STATU_DESC_SCAN_CANCELED) : hg_log::lang_load(ID_STATU_DESC_SCAN_STOPPED), SANE_EVENT_SCAN_FINISHED, status_); notify_ui_working_status(user_cancel_ ? hg_log::lang_load(ID_STATU_DESC_SCAN_CANCELED) : hg_log::lang_load(ID_STATU_DESC_SCAN_STOPPED), SANE_EVENT_SCAN_FINISHED, status_);
break; break;
@ -2969,6 +2973,16 @@ int hg_scanner::setting_set_discardblank(void* data, long* len)
return SCANNER_ERR_RELOAD_OPT_PARAM; return SCANNER_ERR_RELOAD_OPT_PARAM;
} }
int hg_scanner::setting_detect_lens_dirty(void* data, long* len)
{
bool use = *((bool*)data);
int ret = on_detect_lens_dirty(use);
if (ret)
*((bool*)data) = use;
return ret;
}
int hg_scanner::on_color_mode_changed(int& color_mode) int hg_scanner::on_color_mode_changed(int& color_mode)
{ {
return SCANNER_ERR_DEVICE_NOT_SUPPORT; return SCANNER_ERR_DEVICE_NOT_SUPPORT;
@ -3033,6 +3047,10 @@ int hg_scanner::on_process_double_paper(bool type)
{ {
return SCANNER_ERR_DEVICE_NOT_SUPPORT; return SCANNER_ERR_DEVICE_NOT_SUPPORT;
} }
int hg_scanner::on_detect_lens_dirty(bool type)
{
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
}
void hg_scanner::on_device_reconnected(void) void hg_scanner::on_device_reconnected(void)
{ {
std::lock_guard<std::mutex> lock(io_lock_); std::lock_guard<std::mutex> lock(io_lock_);
@ -5366,6 +5384,7 @@ int hg_scanner::image_configuration(SCANCONF& ic)
{ {
ic.splitImage = false; ic.splitImage = false;
} }
ic.en_contaminationdetection = is_lens_dirty;
//多流输出优先级最高 //多流输出优先级最高
if (is_multiout) if (is_multiout)
@ -5508,5 +5527,6 @@ int hg_scanner::image_configuration(SCANCONF& ic)
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "ic.HsvFilterType=%d\r\n", ic.HsvFilterType); VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "ic.HsvFilterType=%d\r\n", ic.HsvFilterType);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "ic.is_colorcast =%d\r\n", ic.is_colorcast); VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "ic.is_colorcast =%d\r\n", ic.is_colorcast);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "ic.isuoloadexceptionimage=%d\r\n", ic.isuoloadexceptionimage); VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "ic.isuoloadexceptionimage=%d\r\n", ic.isuoloadexceptionimage);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "ic.en_contaminationdetection=%d\r\n", ic.en_contaminationdetection);
return ret; return ret;
} }

View File

@ -242,6 +242,7 @@ protected:
int setting_get_motor_ver(void* data, long* len); int setting_get_motor_ver(void* data, long* len);
int setting_get_initial_boot_time(void* data, long* len); int setting_get_initial_boot_time(void* data, long* len);
int setting_set_discardblank(void* data, long* len); int setting_set_discardblank(void* data, long* len);
int setting_detect_lens_dirty(void* data, long* len);
virtual void on_device_reconnected(void); virtual void on_device_reconnected(void);
virtual int on_scanner_closing(bool force); virtual int on_scanner_closing(bool force);
@ -262,6 +263,7 @@ protected:
virtual int on_is_auto_paper(bool isautopaper) = 0; //待纸扫描 virtual int on_is_auto_paper(bool isautopaper) = 0; //待纸扫描
virtual int on_cis_get_image(bool type) = 0; virtual int on_cis_get_image(bool type) = 0;
virtual int on_process_double_paper(bool type) = 0; //双张图像校验 virtual int on_process_double_paper(bool type) = 0; //双张图像校验
virtual int on_detect_lens_dirty(bool type); //检测镜头脏污
protected: protected:
virtual int set_setting_value(const char* name, void* data, long* len); virtual int set_setting_value(const char* name, void* data, long* len);
@ -347,6 +349,7 @@ protected:
int is_auto_paper_scan_exit_time; //待纸扫描退出时间 int is_auto_paper_scan_exit_time; //待纸扫描退出时间
bool is_auto_feedmode_; //是否启用自动分纸强度 bool is_auto_feedmode_; //是否启用自动分纸强度
bool is_discardblank; //是否启动跳过空白页 bool is_discardblank; //是否启动跳过空白页
bool is_lens_dirty; //是否检测镜头脏污
SANE_DISTORTION_VAL distortion_val; //畸变修正结构体保存 SANE_DISTORTION_VAL distortion_val; //畸变修正结构体保存

File diff suppressed because one or more lines are too long

View File

@ -73,7 +73,8 @@ protected:
virtual int on_pick_paper_threshold(double threshold)override; virtual int on_pick_paper_threshold(double threshold)override;
virtual int on_is_auto_paper(bool isautopaper)override; //待纸扫描 virtual int on_is_auto_paper(bool isautopaper)override; //待纸扫描
virtual int on_cis_get_image(bool isautopaper) override; //cis 原图获取 virtual int on_cis_get_image(bool isautopaper) override; //cis 原图获取
virtual int on_process_double_paper(bool type) override; virtual int on_process_double_paper(bool type) override; //双张图像校验
virtual int on_detect_lens_dirty(bool type); //检测镜头脏污
public: public:

View File

@ -258,6 +258,7 @@ extern "C"
RETURN_IF(err, SCANNER_ERR_DEVICE_MAYBE_IS_HOLE); RETURN_IF(err, SCANNER_ERR_DEVICE_MAYBE_IS_HOLE);
RETURN_IF(err, SCANNER_ERR_DEVICE_DEVS_BOOTING); RETURN_IF(err, SCANNER_ERR_DEVICE_DEVS_BOOTING);
RETURN_IF(err, SCANNER_ERR_DEVICE_UNKNOWN_STATUS); RETURN_IF(err, SCANNER_ERR_DEVICE_UNKNOWN_STATUS);
RETURN_IF(err, SCANNER_ERR_DEVICE_LENS_DIRTY);
if (err == SCANNER_ERR_LANG_PAK_LOST) if (err == SCANNER_ERR_LANG_PAK_LOST)
return "SCANNER_ERR_LANG_PAK_LOST"; return "SCANNER_ERR_LANG_PAK_LOST";
@ -334,6 +335,7 @@ extern "C"
RETURN_DESC_IF(err, SCANNER_ERR_DEVICE_MAYBE_IS_HOLE); RETURN_DESC_IF(err, SCANNER_ERR_DEVICE_MAYBE_IS_HOLE);
RETURN_DESC_IF(err, SCANNER_ERR_DEVICE_DEVS_BOOTING); RETURN_DESC_IF(err, SCANNER_ERR_DEVICE_DEVS_BOOTING);
RETURN_DESC_IF(err, SCANNER_ERR_DEVICE_UNKNOWN_STATUS); RETURN_DESC_IF(err, SCANNER_ERR_DEVICE_UNKNOWN_STATUS);
RETURN_DESC_IF(err, SCANNER_ERR_DEVICE_LENS_DIRTY);
if (err == SCANNER_ERR_LANG_PAK_LOST) if (err == SCANNER_ERR_LANG_PAK_LOST)
return "SCANNER_ERR_LANG_PAK_LOST"; return "SCANNER_ERR_LANG_PAK_LOST";