Merge branch 'dev' of http://192.168.10.5:8099/sane/code_device into dev
This commit is contained in:
commit
913b16b21e
|
@ -33,28 +33,38 @@ void CImageApplyDiscardBlank::apply(std::vector<cv::Mat>& mats, bool isTwoSide)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool maxMinCompare(const cv::Mat& img, const cv::Mat& mask, double devTh, double meanTh)
|
bool maxMinCompare(const cv::Mat& img, const cv::Mat& mask, double devTh, double bgc)
|
||||||
{
|
{
|
||||||
double min, max;
|
double min, max;
|
||||||
cv::minMaxLoc(img, &min, &max, 0, 0, mask);
|
cv::minMaxLoc(img, &min, &max, 0, 0, mask);
|
||||||
if (cv::mean(img, mask)[0] < meanTh)
|
|
||||||
return false;
|
return abs(max - bgc) < devTh && abs(min - bgc) < devTh;
|
||||||
return (max - min) < devTh;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int a = 0;
|
||||||
bool CImageApplyDiscardBlank::apply(const cv::Mat& pDib, double threshold, int edge, double devTh, double meanTh, int dilate)
|
bool CImageApplyDiscardBlank::apply(const cv::Mat& pDib, double threshold, int edge, double devTh, double meanTh, int dilate)
|
||||||
{
|
{
|
||||||
if (pDib.empty())
|
if (pDib.empty())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
double resizeScale = 1.0;
|
double resizeScale = 1.0;
|
||||||
while (pDib.cols * resizeScale > 400)
|
while ((pDib.cols * resizeScale > 500) && (pDib.rows * resizeScale > 500))
|
||||||
resizeScale /= 2;
|
resizeScale /= 2;
|
||||||
|
|
||||||
cv::Mat img_resize;
|
cv::Mat img_resize;
|
||||||
cv::resize(pDib, img_resize, cv::Size(), resizeScale, resizeScale, cv::INTER_LINEAR);
|
cv::resize(pDib, img_resize, cv::Size(), resizeScale, resizeScale, cv::INTER_LINEAR);
|
||||||
cv::blur(img_resize, img_resize, cv::Size(3, 3));
|
//cv::dilate(img_resize, img_resize, cv::getStructuringElement(cv::MORPH_ELLIPSE, cv::Size(dilate, dilate)));
|
||||||
//cv::imwrite("img_resize.jpg", img_resize);
|
cv::blur(img_resize, img_resize, cv::Size(dilate, dilate));
|
||||||
|
|
||||||
|
cv::Scalar bgc = hg::getBackGroundColor(img_resize, cv::Mat(), 20);
|
||||||
|
if (pDib.channels() == 3)
|
||||||
|
if ((bgc[0] + bgc[1] + bgc[2]) < meanTh * 3)
|
||||||
|
return false;
|
||||||
|
if (pDib.channels() == 1)
|
||||||
|
if (bgc[0] < meanTh )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
//cv::imwrite(std::to_string(a) + "r.jpg", img_resize);
|
||||||
cv::Mat threshold_img;
|
cv::Mat threshold_img;
|
||||||
if (img_resize.channels() == 3)
|
if (img_resize.channels() == 3)
|
||||||
{
|
{
|
||||||
|
@ -74,19 +84,20 @@ bool CImageApplyDiscardBlank::apply(const cv::Mat& pDib, double threshold, int e
|
||||||
contour.push_back(p);
|
contour.push_back(p);
|
||||||
|
|
||||||
cv::RotatedRect rect = hg::getBoundingRect(contour);
|
cv::RotatedRect rect = hg::getBoundingRect(contour);
|
||||||
rect.size = cv::Size2f(rect.size.width - edge * resizeScale, rect.size.height - edge * resizeScale);
|
rect.size = cv::Size2f(rect.size.width - edge * resizeScale * 2, rect.size.height - edge * resizeScale * 2);
|
||||||
cv::Point2f box[4];
|
cv::Point2f box[4];
|
||||||
rect.points(box);
|
rect.points(box);
|
||||||
|
|
||||||
contour.clear();
|
contour.clear();
|
||||||
contours.clear();
|
contours.clear();
|
||||||
|
|
||||||
for (size_t i = 0; i < 4; i++)
|
for (size_t i = 0; i < 4; i++)
|
||||||
contour.push_back(box[i]);
|
contour.push_back(box[i]);
|
||||||
contours.push_back(contour);
|
contours.push_back(contour);
|
||||||
|
|
||||||
cv::Mat mask = cv::Mat::zeros(img_resize.size(), CV_8UC1);
|
cv::Mat mask = cv::Mat::zeros(img_resize.size(), CV_8UC1);
|
||||||
hg::fillPolys(mask, contours, cv::Scalar::all(255));
|
hg::fillPolys(mask, contours, cv::Scalar::all(255));
|
||||||
//cv::imwrite("mask.jpg", mask);
|
//cv::imwrite(std::to_string(a) + "m.jpg", mask);
|
||||||
|
a++;
|
||||||
bool b = true;
|
bool b = true;
|
||||||
if (img_resize.channels() == 3)
|
if (img_resize.channels() == 3)
|
||||||
{
|
{
|
||||||
|
@ -94,11 +105,11 @@ bool CImageApplyDiscardBlank::apply(const cv::Mat& pDib, double threshold, int e
|
||||||
cv::split(img_resize, bgr);
|
cv::split(img_resize, bgr);
|
||||||
for (size_t i = 0; i < 3; i++)
|
for (size_t i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
b &= maxMinCompare(bgr[i], mask, devTh, meanTh);
|
b &= maxMinCompare(bgr[i], mask, devTh, bgc[i]);
|
||||||
if (!b) break;
|
if (!b) break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
b &= maxMinCompare(img_resize, mask, devTh, meanTh);
|
b &= maxMinCompare(img_resize, mask, devTh, bgc[0]);
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,29 +5,30 @@
|
||||||
* 作者:刘丁维
|
* 作者:刘丁维
|
||||||
* 生成时间:2020/4/21
|
* 生成时间:2020/4/21
|
||||||
* 最近修改时间:2020/4/21 v1.0
|
* 最近修改时间:2020/4/21 v1.0
|
||||||
2020/8/12 v1.1 开放setIntensity和setMinArea;取消isNormal标识位;扩大setIntensity的设置范围,从[2, 20]扩大到[1, 100]
|
2020/8/12 v1.1 开放setIntensity和setMinArea;取消isNormal标识位;扩大setIntensity的设置范围,从[2, 20]扩大到[1, 100]
|
||||||
2020/8/25 v1.1.1 纸张检测缩进,从100像素调整到20像素
|
2020/8/25 v1.1.1 纸张检测缩进,从100像素调整到20像素
|
||||||
2020/10/16 v1.2 添加新接口,能够高效便捷判断图片是否为空白页
|
2020/10/16 v1.2 添加新接口,能够高效便捷判断图片是否为空白页
|
||||||
2020/10/19 v1.2.1 修复静态空白页判断识别误判的BUG
|
2020/10/19 v1.2.1 修复静态空白页判断识别误判的BUG
|
||||||
2021/04/13 v1.3.0 增加标准/票据标识位
|
2021/04/13 v1.3.0 增加标准/票据标识位
|
||||||
2021/08/12 v1.3.1 添加防止不同opencv版本导致计算结果存在差异的代码。
|
2021/08/12 v1.3.1 添加防止不同opencv版本导致计算结果存在差异的代码。
|
||||||
2021/12/14 v1.3.2 重构算法。
|
2021/12/14 v1.3.2 重构算法。
|
||||||
2021/12/15 v1.3.3 微调参数。
|
2021/12/15 v1.3.3 微调参数。
|
||||||
2021/12/17 v1.3.4 增加背景色接口,实现对纯色纸张的空白页判定
|
2021/12/17 v1.3.4 增加背景色接口,实现对纯色纸张的空白页判定
|
||||||
2022/09/07 v1.3.5 修复部分参数传递的BUG
|
2022/09/07 v1.3.5 修复部分参数传递的BUG
|
||||||
2022/09/19 v1.4 增加模糊处理,提高空白页的过滤能力
|
2022/09/19 v1.4 增加模糊处理,提高空白页的过滤能力
|
||||||
2022/09/19 v1.4.1 调整模糊处理步骤
|
2022/09/19 v1.4.1 调整模糊处理步骤
|
||||||
2022/11/18 v1.4.2 调整默认参数
|
2022/11/18 v1.4.2 调整默认参数
|
||||||
2022/11/29 v1.5 增加纸张杂点忽略功能
|
2022/11/29 v1.5 增加纸张杂点忽略功能
|
||||||
2022/12/03 v1.5.1 调整纸张杂点忽略逻辑,避免把细条纹(有效信息)给忽略掉;默认将图像按照灰度图进行识别。
|
2022/12/03 v1.5.1 调整纸张杂点忽略逻辑,避免把细条纹(有效信息)给忽略掉;默认将图像按照灰度图进行识别。
|
||||||
2023/10/12 v1.6 添加新的空白页识别方案。采用JEPG文件大小判断是否为空白页。
|
2023/10/12 v1.6 添加新的空白页识别方案。采用JEPG文件大小判断是否为空白页。
|
||||||
2023/10/20 v1.6.1 优化JPEG文件大小判断空白页
|
2023/10/20 v1.6.1 优化JPEG文件大小判断空白页
|
||||||
2023/10/30 v1.7 调整JPEG文件大小判断空白页的算法接口
|
2023/10/30 v1.7 调整JPEG文件大小判断空白页的算法接口
|
||||||
2023/11/04 v1.7.1 增加PNG二值化文件大小判断空白页的选项
|
2023/11/04 v1.7.1 增加PNG二值化文件大小判断空白页的选项
|
||||||
2023/12/01 v1.8 取消JPEG/PNG文件大小判断空白页方案
|
2023/12/01 v1.8 取消JPEG/PNG文件大小判断空白页方案
|
||||||
2023/12/04 v1.9 提高算法效率。
|
2023/12/04 v1.9 提高算法效率。
|
||||||
2023/12/05 v1.9.1 修改错误代码;修改参数注释。
|
2023/12/05 v1.9.1 修改错误代码;修改参数注释。
|
||||||
* 版本号:v1.9.1
|
2023/12/08 v1.10 调整空白页判定条件。修复mask精度bug。
|
||||||
|
* 版本号:v1.10
|
||||||
|
|
||||||
* ====================================================
|
* ====================================================
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -84,6 +84,27 @@ void CImageApplyOutHole::apply(std::vector<cv::Mat>& mats, bool isTwoSide)
|
||||||
back = mats[1];
|
back = mats[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cv::Mat thumbnail;
|
||||||
|
cv::resize(front, thumbnail, cv::Size(200, 200));
|
||||||
|
cv::Scalar color_front = hg::getBackGroundColor(thumbnail, cv::Mat(), 20);
|
||||||
|
if (color_front[1] == 0)
|
||||||
|
if (color_front[0] < m_threshold)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (color_front[1] != 0)
|
||||||
|
if ((color_front[0] + color_front[1] + color_front[2]) < m_threshold * 3)
|
||||||
|
return;
|
||||||
|
|
||||||
|
cv::resize(back, thumbnail, cv::Size(200, 200));
|
||||||
|
cv::Scalar color_back = hg::getBackGroundColor(thumbnail, cv::Mat(), 20);
|
||||||
|
if (color_back[1] == 0)
|
||||||
|
if (color_back[0] < m_threshold)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (color_back[1] != 0)
|
||||||
|
if ((color_back[0] + color_back[1] + color_back[2]) < m_threshold * 3)
|
||||||
|
return;
|
||||||
|
|
||||||
cv::Mat front_thre, back_thre;
|
cv::Mat front_thre, back_thre;
|
||||||
hg::threshold_Mat(front, front_thre, m_threshold);
|
hg::threshold_Mat(front, front_thre, m_threshold);
|
||||||
hg::threshold_Mat(back, back_thre, m_threshold);
|
hg::threshold_Mat(back, back_thre, m_threshold);
|
||||||
|
@ -177,9 +198,6 @@ void CImageApplyOutHole::apply(std::vector<cv::Mat>& mats, bool isTwoSide)
|
||||||
for (size_t j = 0; j < hole_contours[i].size(); j++)
|
for (size_t j = 0; j < hole_contours[i].size(); j++)
|
||||||
hole_contours[i][j] /= resize_scale;
|
hole_contours[i][j] /= resize_scale;
|
||||||
|
|
||||||
cv::Mat thumbnail;
|
|
||||||
cv::resize(front(roi_front), thumbnail, cv::Size(200, 200));
|
|
||||||
cv::Scalar color = hg::getBackGroundColor(thumbnail, cv::Mat(), m_threshold);
|
|
||||||
roi_front.x /= resize_scale;
|
roi_front.x /= resize_scale;
|
||||||
roi_front.y /= resize_scale;
|
roi_front.y /= resize_scale;
|
||||||
roi_front.width /= resize_scale;
|
roi_front.width /= resize_scale;
|
||||||
|
@ -187,10 +205,10 @@ void CImageApplyOutHole::apply(std::vector<cv::Mat>& mats, bool isTwoSide)
|
||||||
for (size_t i = 0; i < hole_contours.size(); i++)
|
for (size_t i = 0; i < hole_contours.size(); i++)
|
||||||
{
|
{
|
||||||
std::vector<std::vector<cv::Point>> contourss_temp;
|
std::vector<std::vector<cv::Point>> contourss_temp;
|
||||||
dilateContour(hole_contours[i], m_borderSize / 4);
|
dilateContour(hole_contours[i], cv::max(m_borderSize / 2, 5.0f));
|
||||||
contourss_temp.push_back(hole_contours[i]);
|
contourss_temp.push_back(hole_contours[i]);
|
||||||
cv::Mat front_temp = mats[0](roi_front);
|
cv::Mat front_temp = mats[0](roi_front);
|
||||||
hg::fillPolys(front_temp, contourss_temp, color);
|
hg::fillPolys(front_temp, contourss_temp, color_front);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isTwoSide)
|
if (isTwoSide)
|
||||||
|
@ -198,8 +216,6 @@ void CImageApplyOutHole::apply(std::vector<cv::Mat>& mats, bool isTwoSide)
|
||||||
int width_ = roi_back.width;
|
int width_ = roi_back.width;
|
||||||
roi_back.x = back.cols - roi_back.width - roi_back.x; //因为之前反面图像翻转,所以现在ROI也要进行相应翻转
|
roi_back.x = back.cols - roi_back.width - roi_back.x; //因为之前反面图像翻转,所以现在ROI也要进行相应翻转
|
||||||
|
|
||||||
cv::resize(back(roi_back), thumbnail, cv::Size(200, 200));
|
|
||||||
color = hg::getBackGroundColor(thumbnail, cv::Mat(), m_threshold);
|
|
||||||
roi_back.x /= resize_scale;
|
roi_back.x /= resize_scale;
|
||||||
roi_back.y /= resize_scale;
|
roi_back.y /= resize_scale;
|
||||||
roi_back.width /= resize_scale;
|
roi_back.width /= resize_scale;
|
||||||
|
@ -217,10 +233,10 @@ void CImageApplyOutHole::apply(std::vector<cv::Mat>& mats, bool isTwoSide)
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::vector<cv::Point>> contours_temp;
|
std::vector<std::vector<cv::Point>> contours_temp;
|
||||||
dilateContour(hole_contour, m_borderSize / 4);
|
dilateContour(hole_contour, cv::max(m_borderSize / 2, 5.0f));
|
||||||
contours_temp.push_back(hole_contour);
|
contours_temp.push_back(hole_contour);
|
||||||
cv::Mat back_temp = mats[1](roi_back);
|
cv::Mat back_temp = mats[1](roi_back);
|
||||||
hg::fillPolys(back_temp, contours_temp, color);
|
hg::fillPolys(back_temp, contours_temp, color_back);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef LOG
|
#ifdef LOG
|
||||||
|
|
|
@ -29,7 +29,8 @@
|
||||||
* v1.10 2023/11/18 替换形态学膨胀孔洞轮廓,改为特征矩阵膨胀轮廓说。
|
* v1.10 2023/11/18 替换形态学膨胀孔洞轮廓,改为特征矩阵膨胀轮廓说。
|
||||||
* v1.10.1 2023/11/28 形态学kSize根据borderSize调整。
|
* v1.10.1 2023/11/28 形态学kSize根据borderSize调整。
|
||||||
* v1.11 2023/12/02 替换文稿底色提取方案;修复部分孔洞填充不完全的问题。
|
* v1.11 2023/12/02 替换文稿底色提取方案;修复部分孔洞填充不完全的问题。
|
||||||
* 版本号:v1.11
|
* v1.11.1 2023/12/08 增加机制,当发现文稿底色<阈值时,直接返回。避免浪费无意义的算力;增大填涂面积
|
||||||
|
* 版本号:v1.11.1
|
||||||
|
|
||||||
* ====================================================
|
* ====================================================
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -109,7 +109,7 @@ namespace settings
|
||||||
{200.0f, 1},
|
{200.0f, 1},
|
||||||
{240.0f, 1},
|
{240.0f, 1},
|
||||||
{300.0f, 0},
|
{300.0f, 0},
|
||||||
{600.0f, 1} //临时版本发1 原来发2
|
{600.0f, 1} //临时版本å<EFBFBD>? 原æ<C5B8>¥å<C2A5>?
|
||||||
};
|
};
|
||||||
bool is_equal(float l, float r)
|
bool is_equal(float l, float r)
|
||||||
{
|
{
|
||||||
|
@ -331,7 +331,7 @@ int hg_scanner_239::set_auto_flat(int data)
|
||||||
}
|
}
|
||||||
if ((fw[5] == 'A' && atoi(fw.substr(6, 4).c_str()) <= 9999))
|
if ((fw[5] == 'A' && atoi(fw.substr(6, 4).c_str()) <= 9999))
|
||||||
{
|
{
|
||||||
data = data == 1 ? 1 : 0; //暂时没有用。
|
data = data == 1 ? 1 : 0; //暂时没有用�
|
||||||
}
|
}
|
||||||
if (!wait_usb_.is_waiting())
|
if (!wait_usb_.is_waiting())
|
||||||
{
|
{
|
||||||
|
@ -569,7 +569,7 @@ void hg_scanner_239::init_version(void)
|
||||||
{
|
{
|
||||||
firmware_sup_wait_paper_ = year_date.compare("3B0629") >= 0 ? true : false;
|
firmware_sup_wait_paper_ = year_date.compare("3B0629") >= 0 ? true : false;
|
||||||
firmware_sup_log_export_ = true;
|
firmware_sup_log_export_ = true;
|
||||||
firmware_sup_pick_strength_ = false; //不支持
|
firmware_sup_pick_strength_ = false; //ä¸<EFBFBD>支æŒ?
|
||||||
firmware_sup_wake_device_ = year_date.compare("3C0518") >= 0 ? true : false;
|
firmware_sup_wake_device_ = year_date.compare("3C0518") >= 0 ? true : false;
|
||||||
firmware_sup_color_corr_ = year.compare("3C") >= 0 ? true : false;
|
firmware_sup_color_corr_ = year.compare("3C") >= 0 ? true : false;
|
||||||
firmware_sup_double_img = year_date.compare("3C1021") >= 0 ? true : false;
|
firmware_sup_double_img = year_date.compare("3C1021") >= 0 ? true : false;
|
||||||
|
@ -601,7 +601,7 @@ int hg_scanner_239::writedown_device_configuration(bool type, setting_hardware:
|
||||||
int ret = SCANNER_ERR_OK;
|
int ret = SCANNER_ERR_OK;
|
||||||
if (!type)
|
if (!type)
|
||||||
return ret;
|
return ret;
|
||||||
setting_hardware::HGSCANCONF_3399 p = dev_conf_; //不得改变外部的值
|
setting_hardware::HGSCANCONF_3399 p = dev_conf_; //ä¸<EFBFBD>得改å<EFBFBD>˜å¤–部的å€?
|
||||||
p.params_3399.is_autopaper = is_auto_scan();
|
p.params_3399.is_autopaper = is_auto_scan();
|
||||||
if (!dev_conf)
|
if (!dev_conf)
|
||||||
dev_conf = &p;
|
dev_conf = &p;
|
||||||
|
@ -622,7 +622,7 @@ int hg_scanner_239::writedown_device_configuration(bool type, setting_hardware:
|
||||||
dev_conf->params_3399.is_fixedpaper = false;
|
dev_conf->params_3399.is_fixedpaper = false;
|
||||||
dev_conf->params_3399.en_autosize = true;
|
dev_conf->params_3399.en_autosize = true;
|
||||||
}
|
}
|
||||||
if (!firmware_sup_auto_speed_ && image_prc_param_.bits.paper == PAPER_AUTO_MATCH)//3399 ,在3C之前的版本 匹配原始尺寸设置 12
|
if (!firmware_sup_auto_speed_ && image_prc_param_.bits.paper == PAPER_AUTO_MATCH)//3399 ,åœ?C之å‰<C3A5>的版æœ?匹é…<C3A9>原始尺寸设置 12
|
||||||
{
|
{
|
||||||
dev_conf->params_3399.paper = 12;
|
dev_conf->params_3399.paper = 12;
|
||||||
}
|
}
|
||||||
|
@ -677,9 +677,9 @@ int hg_scanner_239::writedown_image_configuration(void)
|
||||||
ret = write_register(setting3399::SR_CONFIF_IMGPROCPARAM, sizeof(SCANCONF));
|
ret = write_register(setting3399::SR_CONFIF_IMGPROCPARAM, sizeof(SCANCONF));
|
||||||
ret = io_->write_bulk(&ic, &len);
|
ret = io_->write_bulk(&ic, &len);
|
||||||
|
|
||||||
//这个地方休眠是为了当初某个型号设备下面在初始化某个协议时比较耗时,所以加上。
|
//è¿™ä¸ªåœ°æ–¹ä¼‘çœ æ˜¯ä¸ºäº†å½“åˆ<EFBFBD>æŸ<EFBFBD>个型å<EFBFBD>·è®¾å¤‡ä¸‹é<EFBFBD>¢åœ¨åˆ<EFBFBD>始化æŸ<EFBFBD>个å<EFBFBD><EFBFBD>è®®æ—¶æ¯”è¾ƒè€—æ—¶ï¼Œæ‰€ä»¥åŠ ä¸Šã€?
|
||||||
//2023/11/30 普世需要能够较为流程点击扫描到出第一张图,所以这个地方进行屏蔽,如果某天有哪台设备不出图,你可以看下这里,对版本进行判断加上这个延时的操作
|
//2023/11/30 普世需è¦<EFBFBD>能够较为æµ<EFBFBD>程点击扫æ<EFBFBD><EFBFBD>åˆ°å‡ºç¬¬ä¸€å¼ å›¾ï¼Œæ‰€ä»¥è¿™ä¸ªåœ°æ–¹è¿›è¡Œå±<EFBFBD>蔽,如果æŸ<EFBFBD>天有哪å<EFBFBD>°è®¾å¤‡ä¸<EFBFBD>å‡ºå›¾ï¼Œä½ å<EFBFBD>¯ä»¥çœ‹ä¸‹è¿™é‡Œï¼Œå¯¹ç‰ˆæœ¬è¿›è¡Œåˆ¤æ–åŠ ä¸Šè¿™ä¸ªå»¶æ—¶çš„æ“<EFBFBD>ä½?
|
||||||
// 注意debug 可能会调试不出来,因为要加载debug信息,所以发送信息就会慢点
|
// 注æ„<EFBFBD>debug å<>¯èƒ½ä¼šè°ƒè¯•ä¸<C3A4>出æ<C2BA>¥ï¼Œå› 为è¦<C3A8>åŠ è½½debugä¿¡æ<C2A1>¯ï¼Œæ‰€ä»¥å<C2A5>‘é€<C3A9>ä¿¡æ<C2A1>¯å°±ä¼šæ…¢ç‚?
|
||||||
//this_thread::sleep_for(chrono::milliseconds(500));
|
//this_thread::sleep_for(chrono::milliseconds(500));
|
||||||
//io_->set_timeout(2000);//必要延时
|
//io_->set_timeout(2000);//必要延时
|
||||||
}
|
}
|
||||||
|
@ -927,7 +927,7 @@ int hg_scanner_239::on_resolution_changed(int& dpi)
|
||||||
else
|
else
|
||||||
dev_conf_.params_3399.dpi = dpi >= 500 ? 3 : (dpi < 500 && dpi> 299) ? 2 : 1;
|
dev_conf_.params_3399.dpi = dpi >= 500 ? 3 : (dpi < 500 && dpi> 299) ? 2 : 1;
|
||||||
|
|
||||||
//dev_conf_.params_3399.dpi = 1; //dpi 华凌cis和敦南cis 默认发1无需改变
|
//dev_conf_.params_3399.dpi = 1; //dpi å<EFBFBD>Žå‡Œcis和敦å<EFBFBD>—cis 默认å<C2A4>?æ— éœ€æ”¹å<C2B9>˜
|
||||||
int ret = writedown_device_configuration();
|
int ret = writedown_device_configuration();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -985,7 +985,7 @@ int hg_scanner_239::on_skew_check_changed(bool& check)
|
||||||
int hg_scanner_239::on_skew_check_level_changed(int& check)
|
int hg_scanner_239::on_skew_check_level_changed(int& check)
|
||||||
{
|
{
|
||||||
int ret = SCANNER_ERR_OK,
|
int ret = SCANNER_ERR_OK,
|
||||||
val = check - 1,//涓婇潰璁剧疆鐨勬槸1 - 5 锛屾帴鍙楄寖鍥村€间负0 - 4锛岄粯璁?
|
val = check - 1,//涓婇潰ç’<EFBFBD>剧疆é<EFBFBD>¨å‹¬æ§? - 5 锛屾帴é<C2B4>™æ¥„寖é<E28093>¥æ<C2A5>‘€间è´? - 4锛岄粯ç’<C3A7>?
|
||||||
old = dev_conf_.params_3399.screw_detect_level;
|
old = dev_conf_.params_3399.screw_detect_level;
|
||||||
setting_hardware::HGSCANCONF_3399 cf;
|
setting_hardware::HGSCANCONF_3399 cf;
|
||||||
|
|
||||||
|
@ -1353,11 +1353,11 @@ void hg_scanner_239::thread_get_dves_image(void)
|
||||||
while (run_)//&& !user_cancel_
|
while (run_)//&& !user_cancel_
|
||||||
{
|
{
|
||||||
size = sizeof(buf);
|
size = sizeof(buf);
|
||||||
|
memset(buf, 0, size);
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(io_lock_);
|
std::lock_guard<std::mutex> lock(io_lock_);
|
||||||
|
|
||||||
memset(buf, 0, size);
|
io_->set_timeout(500); //2023 11 30之å‰<C3A5>一直使ç”?000ms ,但是为了能够快速å“<C3A5>应下次的状æ€<C3A6>ä¿¡æ<C2A1>¯è¿”回这里设置为500ms
|
||||||
io_->set_timeout(500); //2023 11 30之前一直使用1000ms ,但是为了能够快速响应下次的状态信息返回这里设置为500ms
|
|
||||||
ret = io_->read_interrupt(buf, &size);
|
ret = io_->read_interrupt(buf, &size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1366,7 +1366,7 @@ void hg_scanner_239::thread_get_dves_image(void)
|
||||||
if (sw.elapsed_s() > 120 && !is_auto_scan())
|
if (sw.elapsed_s() > 120 && !is_auto_scan())
|
||||||
{
|
{
|
||||||
status_ = ret;
|
status_ = ret;
|
||||||
notify_ui_working_status(from_default_language(STATU_DESC_SCANNER_ERR_DEVICE_GET_IMAGE_OUTTIME), SANE_EVENT_ERROR, ret); // 鍙栧浘閫氫俊瓒呮椂
|
notify_ui_working_status(from_default_language(STATU_DESC_SCANNER_ERR_DEVICE_GET_IMAGE_OUTTIME), SANE_EVENT_ERROR, ret); // é<EFBFBD>™æ §æµ˜é–«æ°«ä¿Šç“’å‘®æ¤?
|
||||||
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "get image time out:%s\n", hg_scanner_err_name(status_));
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "get image time out:%s\n", hg_scanner_err_name(status_));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1392,7 +1392,10 @@ void hg_scanner_239::thread_get_dves_image(void)
|
||||||
LOG_INFO(LOG_LEVEL_DEBUG_INFO, "User cancelled (checked when read INT timeout), we faked a 'STOP' messag to enter exiting process ...\n");
|
LOG_INFO(LOG_LEVEL_DEBUG_INFO, "User cancelled (checked when read INT timeout), we faked a 'STOP' messag to enter exiting process ...\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(1)); // for BUG-843
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (ret != SCANNER_ERR_OK)
|
else if (ret != SCANNER_ERR_OK)
|
||||||
|
@ -1422,7 +1425,7 @@ void hg_scanner_239::thread_get_dves_image(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
//break;
|
//break;
|
||||||
//杩欎釜鏃跺€欓€€鍑虹殑璇濇秷鎭氨杩樻病璇诲畬锛岄敊璇俊鎭厛淇濆瓨涓嬫潵锛屽彧鏈夎幏鍙栧埌stop鏃舵墠閫€鍑猴紝濡傛灉娌¤幏鍙栧畬閫€鍑猴紝鍙兘浼氬鑷寸浜屾鎵弿鐩存帴杩斿洖鎵弿瀹屾垚
|
//æ<EFBFBD>©æ¬Žé‡œé<EFBFBD>ƒè·ºâ‚¬æ¬“€€é<EFBFBD>‘虹殑璇濇秷éŽîˆšæ°¨æ<EFBFBD>©æ¨»ç—…璇诲畬锛岄敊璇俊éŽîˆšåŽ›æ·‡æ¿†ç“¨æ¶“嬫潵锛屽彧é<EFBFBD>ˆå¤Žå¹<EFBFBD>é<EFBFBD>™æ §åŸŒstopé<EFBFBD>ƒèˆµå¢ 閫€é<EFBFBD>‘猴ç´<EFBFBD>æ¿¡å‚›ç<EFBFBD>‰å¨ŒÂ¤å¹<EFBFBD>é<EFBFBD>™æ §ç•¬é–«â‚¬é<EFBFBD>‘猴ç´<EFBFBD>é<EFBFBD>™îˆ<EFBFBD>兘浼氬鑷寸浜屾鎵弿é<EFBFBD>©å˜å¸´æ<EFBFBD>©æ–¿æ´–鎵弿瀹屾åž?
|
||||||
}
|
}
|
||||||
if (info->From == setting3399::IMG)
|
if (info->From == setting3399::IMG)
|
||||||
{
|
{
|
||||||
|
@ -1445,8 +1448,8 @@ void hg_scanner_239::thread_get_dves_image(void)
|
||||||
//else
|
//else
|
||||||
// VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "status(0x%x) is not accept in usb thread\n", status);
|
// VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "status(0x%x) is not accept in usb thread\n", status);
|
||||||
}
|
}
|
||||||
else if (info->From == setting3399::STOPSCAN)//鍥轰欢鐗堟湰:3B0326鑾峰彇鏃犵焊鏃讹紝涓嬮潰涓柇淇℃伅浼氬厛鍙戞棤绾稿湪鍋滄鎵弿,鐒跺悗鍦ㄥ彂鏃犵焊
|
else if (info->From == setting3399::STOPSCAN)//é<EFBFBD>¥è½°æ¬¢é<EFBFBD>—å Ÿæ¹°:3B0326鑾峰彇é<E280A1>ƒçŠµç„Šé<C5A0>ƒè®¹ç´<C3A7>涓嬮潰涓柇淇℃伅浼氬厛é<E280BA>™æˆžæ£¤ç»¾ç¨¿æ¹ªé<C2AA>‹æ»„鎵å¼?é<>’跺悗é<E28094>¦ã„¥å½‚é<E2809A>ƒçŠµç„?
|
||||||
{ //姝ゆ椂int绔偣杩樿淇℃伅娌℃湁璇诲彇瀹岋紝鑰屼笖閫€鍑虹偣鍑荤户缁壂鎻忥紝涓嬮潰璁惧杩樻湭缁撴潫鎵弿
|
{ //å§<EFBFBD>ゆ椂int绔å<EFBFBD>£æ<EFBFBD>©æ¨¿î›¦æ·‡â„ƒä¼…娌℃æ¹<EFBFBD>璇诲彇瀹岋ç´<EFBFBD>鑰屼笖閫€é<EFBFBD>‘虹å<EFBFBD>£é<EFBFBD>‘è<EFBFBD>¤æˆ·ç¼<EFBFBD>壂鎻忥ç´<EFBFBD>涓嬮潰ç’<EFBFBD>惧æ<EFBFBD>©æ¨»æ¹ç¼<EFBFBD>撴潫鎵å¼?
|
||||||
if (!svdevs_err_.empty())
|
if (!svdevs_err_.empty())
|
||||||
{
|
{
|
||||||
status_ = svdevs_err_.front();
|
status_ = svdevs_err_.front();
|
||||||
|
@ -1580,7 +1583,7 @@ int hg_scanner_239::do_start(void)
|
||||||
|
|
||||||
reset();
|
reset();
|
||||||
|
|
||||||
//211220固件版本不支持返回
|
//211220固件版本ä¸<EFBFBD>支æŒ<EFBFBD>è¿”å›?
|
||||||
ret = get_scan_is_sleep(val);
|
ret = get_scan_is_sleep(val);
|
||||||
if (!val && ret == SCANNER_ERR_OK)
|
if (!val && ret == SCANNER_ERR_OK)
|
||||||
{
|
{
|
||||||
|
@ -1871,7 +1874,7 @@ int hg_scanner_239::get_scan_is_sleep(SANE_Bool& type)
|
||||||
std::lock_guard<std::mutex> lock(io_lock_);
|
std::lock_guard<std::mutex> lock(io_lock_);
|
||||||
|
|
||||||
int ret = 0,val;
|
int ret = 0,val;
|
||||||
ret = read_register(setting3399::SR_GET_SLEEP_STAUTUS, &val); //0休眠 1唤醒状态
|
ret = read_register(setting3399::SR_GET_SLEEP_STAUTUS, &val); //0ä¼‘çœ 1唤醒状æ€?
|
||||||
if (ret == SCANNER_ERR_OK)
|
if (ret == SCANNER_ERR_OK)
|
||||||
{
|
{
|
||||||
type = val == 1 ? true : false;
|
type = val == 1 ? true : false;
|
||||||
|
@ -2046,7 +2049,7 @@ int hg_scanner_239::set_scan_lock_check_val(string check_str)
|
||||||
{
|
{
|
||||||
return SCANNER_ERR_INVALID_PARAMETER;
|
return SCANNER_ERR_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
int num = 32 - keys.size(); //保持32位下发
|
int num = 32 - keys.size(); //ä¿<EFBFBD>æŒ<EFBFBD>32ä½<EFBFBD>下å<EFBFBD>?
|
||||||
if (num > 0)
|
if (num > 0)
|
||||||
{
|
{
|
||||||
std::string str(num, '0');
|
std::string str(num, '0');
|
||||||
|
@ -2106,7 +2109,7 @@ int hg_scanner_239::set_firmware_upgrade(std::string filename)
|
||||||
return SCANNER_ERR_OPEN_FILE_FAILED;
|
return SCANNER_ERR_OPEN_FILE_FAILED;
|
||||||
}
|
}
|
||||||
fwname.seekg(0, std::ios::end);
|
fwname.seekg(0, std::ios::end);
|
||||||
int total = fwname.tellg();//记录总长度
|
int total = fwname.tellg();//记录总长�
|
||||||
fwname.seekg(0, std::ios::beg);
|
fwname.seekg(0, std::ios::beg);
|
||||||
int pos = fwname.tellg();//记录pos位置
|
int pos = fwname.tellg();//记录pos位置
|
||||||
|
|
||||||
|
@ -2145,7 +2148,7 @@ int hg_scanner_239::set_firmware_upgrade(std::string filename)
|
||||||
return SCANNER_ERR_DEVICE_UPGRADE_FAIL;
|
return SCANNER_ERR_DEVICE_UPGRADE_FAIL;
|
||||||
|
|
||||||
int to_cnt = 0;
|
int to_cnt = 0;
|
||||||
// 到这个位置已经能够升级成功了 后面对升级结果做下判断
|
// 到这个ä½<EFBFBD>置已ç»<EFBFBD>能够å<EFBFBD>‡çº§æˆ<EFBFBD>功了 å<>Žé<C5BD>¢å¯¹å<C2B9>‡çº§ç»“æžœå<C593>šä¸‹åˆ¤æ–?
|
||||||
auto now = std::chrono::steady_clock::now();
|
auto now = std::chrono::steady_clock::now();
|
||||||
while (std::chrono::duration<double>(std::chrono::steady_clock::now() - now).count() < 70)
|
while (std::chrono::duration<double>(std::chrono::steady_clock::now() - now).count() < 70)
|
||||||
{
|
{
|
||||||
|
@ -2216,7 +2219,7 @@ int hg_scanner_239::set_dev_islock_file(int islockfile)
|
||||||
}
|
}
|
||||||
if (islockfile != 0 && islockfile != 1)
|
if (islockfile != 0 && islockfile != 1)
|
||||||
{
|
{
|
||||||
return SCANNER_ERR_INVALID_PARAMETER; //这个地方设置的参数必须保证正确
|
return SCANNER_ERR_INVALID_PARAMETER; //这个地方设置的å<EFBFBD>‚æ•°å¿…é¡»ä¿<EFBFBD>è¯<EFBFBD>æ£ç¡?
|
||||||
}
|
}
|
||||||
string device_log_path = "/var/log/black_list_file.txt";
|
string device_log_path = "/var/log/black_list_file.txt";
|
||||||
string str = std::to_string(islockfile);
|
string str = std::to_string(islockfile);
|
||||||
|
|
|
@ -449,7 +449,7 @@ namespace hg_imgproc
|
||||||
edgeScale[1] = low;
|
edgeScale[1] = low;
|
||||||
edgeScale[2] = l;
|
edgeScale[2] = l;
|
||||||
edgeScale[3] = r;
|
edgeScale[3] = r;
|
||||||
CImageApplyOutHole outh(val, edgeScale, 50);
|
CImageApplyOutHole outh(val, edgeScale, 20);
|
||||||
outh.apply(v, true);
|
outh.apply(v, true);
|
||||||
if (v.empty())
|
if (v.empty())
|
||||||
{
|
{
|
||||||
|
@ -1167,7 +1167,7 @@ namespace hg_imgproc
|
||||||
mats_.clear();
|
mats_.clear();
|
||||||
|
|
||||||
double threshold = 40;
|
double threshold = 40;
|
||||||
int edge = 40;
|
int edge = 100;
|
||||||
int dis = img_conf_.discardblank_percent;
|
int dis = img_conf_.discardblank_percent;
|
||||||
if (img_conf_.is_autodiscradblank_vince)
|
if (img_conf_.is_autodiscradblank_vince)
|
||||||
dis *= 1.5;
|
dis *= 1.5;
|
||||||
|
|
Loading…
Reference in New Issue