区分待纸扫描提示和扫描上传信息提示

This commit is contained in:
masayume_ht 2023-05-26 15:58:03 +08:00
parent 1cadb78e21
commit 6489f6b147
10 changed files with 116 additions and 32 deletions

View File

@ -89,3 +89,5 @@
10.对接爱云校做协议适配 --23.04.24 10.对接爱云校做协议适配 --23.04.24
11.调整文件编码格式修复指示器乱码问题 --23.04.27 11.调整文件编码格式修复指示器乱码问题 --23.04.27
12.添加分纸模式设置功能 --23.05.05 12.添加分纸模式设置功能 --23.05.05
13.更新裁切纠偏算法到1.5版本 --23.05.15
14.区分待纸扫描提示和扫描上传信息提示,防止扫描结束图像未上传完时两者争抢提示框 -23.05.26

View File

@ -57,7 +57,7 @@ void CIndicatorDlg::setindicatortext(int aquire, int updata)
void CIndicatorDlg::setindicatortext(CString text) void CIndicatorDlg::setindicatortext(CString text)
{ {
SetDlgItemText(IDC_STATIC_TIPS, text); SetDlgItemText(IDC_STATIC_TIPS2, text);
} }

View File

@ -129,6 +129,13 @@ BOOL CTwainUI::OnInitDialog()
else { else {
setvisable_autopaper(false); setvisable_autopaper(false);
} }
if ((m_hardwareVersion[5] == 'C' && atoi(m_hardwareVersion.substr(6, 4).c_str()) >= 103) || (m_hardwareVersion[5] > 'C'))
m_pageBasic->GetDlgItem(IDC_CKCOLORCAST)->ShowWindow(SW_SHOW);
else
{
((CButton*)m_pageBasic->GetDlgItem(IDC_CKCOLORCAST))->SetCheck(FALSE);
m_pageBasic->GetDlgItem(IDC_CKCOLORCAST)->ShowWindow(SW_HIDE);
}
setvisable_dogear(true); setvisable_dogear(true);
setvisable_size(true); setvisable_size(true);
setvisable_fixedpaper(false); setvisable_fixedpaper(false);
@ -145,6 +152,7 @@ BOOL CTwainUI::OnInitDialog()
{ {
setvisable_size(false); setvisable_size(false);
} }
((CButton*)m_pageBasic->GetDlgItem(IDC_RDQUALITYPRIORITY))->ShowWindow(SW_HIDE); ((CButton*)m_pageBasic->GetDlgItem(IDC_RDQUALITYPRIORITY))->ShowWindow(SW_HIDE);
((CButton*)m_pageBasic->GetDlgItem(IDC_RDSPEEDPRIORITY))->ShowWindow(SW_HIDE); ((CButton*)m_pageBasic->GetDlgItem(IDC_RDSPEEDPRIORITY))->ShowWindow(SW_HIDE);
#ifdef G400 #ifdef G400

View File

@ -303,6 +303,8 @@ void GScanO1003399::config_params(GScanCap& param)
//cfg.g200params.is_fixedpaper = param.en_fixedpaper; //cfg.g200params.is_fixedpaper = param.en_fixedpaper;
cfg.g200params.is_fixedpaper = true; //220513 路緞狂痙칵훰미땍류충꽃섞 cfg.g200params.is_fixedpaper = true; //220513 路緞狂痙칵훰미땍류충꽃섞
cfg.g200params.en_anlogic_key = true; cfg.g200params.en_anlogic_key = true;
//cfg.g200params.enabledsp_cache = true;
#ifdef G200 #ifdef G200
if ((fwversion[5] == 'A' && (atoi(fwversion.substr(6, 4).c_str()) > 1220)) || (fwversion[5] == 'B' && (atoi(fwversion.substr(6, 4).c_str()) <= 430))) if ((fwversion[5] == 'A' && (atoi(fwversion.substr(6, 4).c_str()) > 1220)) || (fwversion[5] == 'B' && (atoi(fwversion.substr(6, 4).c_str()) <= 430)))
@ -370,6 +372,7 @@ void GScanO1003399::config_params(GScanCap& param)
param39.fillholeratio_right = param.fillholeratio_right; param39.fillholeratio_right = param.fillholeratio_right;
param39.is_colorcast = param.is_colorcast; param39.is_colorcast = param.is_colorcast;
param39.fillhole.fillholeratio = std::max(std::max(std::max(param.fillholeratio_down, param.fillholeratio_up), std::max(param.fillholeratio_left, param.fillholeratio_right)),1); param39.fillhole.fillholeratio = std::max(std::max(std::max(param.fillholeratio_down, param.fillholeratio_up), std::max(param.fillholeratio_left, param.fillholeratio_right)),1);
m_usb->write_bulk(&param39, sizeof(param39)); m_usb->write_bulk(&param39, sizeof(param39));
m_param .resolution_native = param.resolution_dst >= 500.0f ? 300.0f : 200.0f; m_param .resolution_native = param.resolution_dst >= 500.0f ? 300.0f : 200.0f;
@ -606,6 +609,7 @@ void GScanO1003399::usb_run()
this->UpdateScanInfo(str); this->UpdateScanInfo(str);
std::this_thread::sleep_for(std::chrono::milliseconds(30)); std::this_thread::sleep_for(std::chrono::milliseconds(30));
} }
this->UpdateScanInfo(L" ");
if ((m_autopaper_timeout == false) || scanner_read_reg(m_usb, SR_STATUS)) if ((m_autopaper_timeout == false) || scanner_read_reg(m_usb, SR_STATUS))
return; return;
else else

View File

@ -785,9 +785,11 @@ void GScanO400::usbmain()
} }
if (sw_p.elapsed_s() < gcap.autopaper_timeout && (!autopaper_stop)) if (sw_p.elapsed_s() < gcap.autopaper_timeout && (!autopaper_stop))
break; break;
else else {
autopaper_stop = true; autopaper_stop = true;
} }
UpdateScanInfo(L" ");
}
m_pImages->setscanflags(false); m_pImages->setscanflags(false);
std::this_thread::sleep_for(std::chrono::milliseconds(500)); std::this_thread::sleep_for(std::chrono::milliseconds(500));
devState = haveError ? DevState::DEV_WRONG : DevState::DEV_STOP; devState = haveError ? DevState::DEV_WRONG : DevState::DEV_STOP;

View File

@ -4,6 +4,10 @@
#include <opencv2/imgproc/hal/hal.hpp> #include <opencv2/imgproc/hal/hal.hpp>
#include "ImageApplyDispersion.h" #include "ImageApplyDispersion.h"
#define COLOR_SCALE_THRE 0.5
#define FRONT_TOP 70
#define FX_FY 0.5f
CImageApplyAutoCrop::CImageApplyAutoCrop() CImageApplyAutoCrop::CImageApplyAutoCrop()
: m_isCrop(false) : m_isCrop(false)
, m_isDesaskew(false) , m_isDesaskew(false)
@ -15,11 +19,13 @@ CImageApplyAutoCrop::CImageApplyAutoCrop()
, m_indent(5) , m_indent(5)
, m_normalCrop(false) , m_normalCrop(false)
, m_isDispersion(true) , m_isDispersion(true)
, m_fx(1.0)
, m_fy(1.0)
{ {
} }
CImageApplyAutoCrop::CImageApplyAutoCrop(bool isCrop, bool isDesaskew, bool isFillBlank, const cv::Size& fixedSize, bool isConvex, bool isFillColor, CImageApplyAutoCrop::CImageApplyAutoCrop(bool isCrop, bool isDesaskew, bool isFillBlank, const cv::Size& fixedSize, bool isConvex, bool isFillColor,
double threshold, int noise, int indent, bool normalCrop, bool dispersion) double threshold, int noise, int indent, bool normalCrop, bool dispersion, double fx, double fy)
: m_isCrop(isCrop) : m_isCrop(isCrop)
, m_isDesaskew(isDesaskew) , m_isDesaskew(isDesaskew)
, m_isFillBlank(isFillBlank) , m_isFillBlank(isFillBlank)
@ -31,6 +37,8 @@ CImageApplyAutoCrop::CImageApplyAutoCrop(bool isCrop, bool isDesaskew, bool isFi
, m_fixedSize(fixedSize) , m_fixedSize(fixedSize)
, m_normalCrop(normalCrop) , m_normalCrop(normalCrop)
, m_isDispersion(dispersion) , m_isDispersion(dispersion)
, m_fx(fx)
, m_fy(fy)
{ {
} }
@ -42,7 +50,7 @@ void CImageApplyAutoCrop::apply(cv::Mat& pDib, int side)
{ {
cv::Mat dst; cv::Mat dst;
autoCrop_desaskew_fillBlank(pDib, dst, m_isCrop, m_isDesaskew, m_isFillBlank, m_fixedSize.width, m_fixedSize.height, autoCrop_desaskew_fillBlank(pDib, dst, m_isCrop, m_isDesaskew, m_isFillBlank, m_fixedSize.width, m_fixedSize.height,
m_isConvexHull, m_isFillColor, m_threshold, m_noise, m_indent, m_normalCrop, m_isDispersion); m_isConvexHull, m_isFillColor, m_threshold, m_noise, m_indent, m_normalCrop, m_isDispersion, m_fx, m_fy);
pDib = dst; pDib = dst;
} }
@ -59,10 +67,7 @@ void CImageApplyAutoCrop::apply(std::vector<cv::Mat>& mats, bool isTwoSide)
} }
} }
#define FRONT_TOP 70 void CImageApplyAutoCrop::myWarpAffine(cv::InputArray _src, cv::OutputArray _dst, cv::InputArray _M0, cv::Size dsize, int flags, int borderType, const cv::Scalar& borderValue)
#define FX_FY 0.5f
void myWarpAffine(cv::InputArray _src, cv::OutputArray _dst, cv::InputArray _M0, cv::Size dsize, int flags, int borderType, const cv::Scalar& borderValue)
{ {
int interpolation = flags; int interpolation = flags;
cv::Mat src = _src.getMat(), M0 = _M0.getMat(); cv::Mat src = _src.getMat(), M0 = _M0.getMat();
@ -94,7 +99,7 @@ void myWarpAffine(cv::InputArray _src, cv::OutputArray _dst, cv::InputArray _M0,
M, interpolation, borderType, borderValue.val); M, interpolation, borderType, borderValue.val);
} }
uchar getBackGroudChannelMean(const cv::Mat& gray, int total, int threshold) uchar CImageApplyAutoCrop::getBackGroudChannelMean(const cv::Mat& gray, int total, int threshold)
{ {
cv::Mat image_clone; cv::Mat image_clone;
cv::resize(gray, image_clone, cv::Size(), 0.25, 0.25); cv::resize(gray, image_clone, cv::Size(), 0.25, 0.25);
@ -133,29 +138,74 @@ uchar getBackGroudChannelMean(const cv::Mat& gray, int total, int threshold)
return 255; return 255;
} }
cv::Scalar getBackGroudColor(const cv::Mat& image, int total, int threshold) cv::Scalar CImageApplyAutoCrop::getBackGroudColor(const cv::Mat& image, int threshold)
{ {
if (image.channels() == 3) if (image.channels() == 3)
{ {
cv::Mat image_bgr[3]; uchar table[768] = { 0 };
cv::split(image, image_bgr); int hist_bgr[3][256] = { 0 };
int width = image.cols, height = image.rows, bytesPerLine = image.step;
memset(table + threshold * 3, 255, 768 - threshold * 3);
uchar bgr[3]; unsigned char* ptr_data = image.data;
for (size_t i = 0; i < 3; i++) unsigned char b = 0;
bgr[i] = getBackGroudChannelMean(image_bgr[i], total, threshold); for (uint i = 0; i < height; i++, ptr_data += bytesPerLine)
return cv::Scalar(bgr[0], bgr[1], bgr[2]); for (uint j = 0, x = 0; j < width; j++, x += 3)
{
b = table[ptr_data[x] + ptr_data[x + 1] + ptr_data[x + 2]];
for (uint k = 0; k < 3; k++)
hist_bgr[k][ptr_data[x + k] & b]++;
}
int max_vals[3] = { 0 };
cv::Scalar max_indexes(0, 0, 0);
for (uint i = 5; i < 256; i++)
for (uint j = 0; j < 3; j++)
if (hist_bgr[j][i] > max_vals[j])
{
max_vals[j] = hist_bgr[j][i];
max_indexes[j] = i;
}
return max_indexes;
} }
else else
return cv::Scalar::all(getBackGroudChannelMean(image, total, threshold)); {
uchar table[256] = { 0 };
int hist_bgr[256] = { 0 };
int width = image.cols, height = image.rows, bytesPerLine = image.step;
memset(table + threshold, 255, 256 - threshold);
unsigned char* ptr_data = image.data;
unsigned char b = 0;
for (uint i = 0; i < height; i++, ptr_data += bytesPerLine)
for (uint j = 0, x = 0; j < width; j++, x++)
hist_bgr[ptr_data[x] & table[ptr_data[x]]]++;
int max_vals = 5;
for (uint i = 5; i < 256; i++)
if (hist_bgr[i] > hist_bgr[max_vals])
max_vals = i;
return cv::Scalar(max_vals);
}
} }
CImageApplyDispersion dispersion_apply; CImageApplyDispersion m_dispersion_apply;
#define COLOR_SCALE_THRE 0.5 void CImageApplyAutoCrop::autoCrop_desaskew_fillBlank(cv::Mat& src, cv::Mat& dst, bool isAutoCrop, bool isDesaskew, bool isFillBlank, int dWidth, int dHeight,
void autoCrop_desaskew_fillBlank(const cv::Mat& src, cv::Mat& dst, bool isAutoCrop, bool isDesaskew, bool isFillBlank, int dWidth, int dHeight, bool isConvex, bool isColorBlank, double threshold, int noise, int indent, bool isNormalCrop, bool dispersion, double fx, double fy)
bool isConvex, bool isColorBlank, double threshold, int noise, int indent, bool isNormalCrop, bool dispersion)
{ {
if (src.empty()) return; if (src.empty()) return;
if (fx < 0.999999 || fx > 1.000001 || fy < 0.999999 || fy > 1.000001)
cv::resize(src, src, cv::Size(), fx, fy, cv::INTER_LINEAR);
if (!isAutoCrop && !isDesaskew && !isFillBlank && dWidth == 0 && dHeight == 0)
{
dst = src;
return;
}
if (isNormalCrop) if (isNormalCrop)
{ {
cv::Rect roi = cv::Rect((src.cols - dWidth) / 2, FRONT_TOP, dWidth, dHeight) & cv::Rect(0, 0, src.cols, src.rows); cv::Rect roi = cv::Rect((src.cols - dWidth) / 2, FRONT_TOP, dWidth, dHeight) & cv::Rect(0, 0, src.cols, src.rows);
@ -207,13 +257,13 @@ void autoCrop_desaskew_fillBlank(const cv::Mat& src, cv::Mat& dst, bool isAutoCr
if (dispersion) if (dispersion)
{ {
cv::Mat mat_dispersion = src(cv::boundingRect(maxContour)); cv::Mat mat_dispersion = src(cv::boundingRect(maxContour));
dispersion_apply.apply(mat_dispersion, 0); m_dispersion_apply.apply(mat_dispersion, 0);
} }
cv::Scalar blankColor; cv::Scalar blankColor;
if (isFillBlank) if (isFillBlank)
if (isColorBlank) if (isColorBlank)
blankColor = getBackGroudColor(resizeMat, rect.size.area() * FX_FY * FX_FY, COLOR_SCALE_THRE); blankColor = getBackGroudColor(resizeMat, 20);
else else
blankColor = cv::Scalar::all(255); blankColor = cv::Scalar::all(255);
else else

View File

@ -26,7 +26,8 @@
2022/04/24 v1.4 2022/04/24 v1.4
2022/05/03 v1.4.1 2022/05/03 v1.4.1
2022/06/09 v1.4.2 稿threshold值0.5 2022/06/09 v1.4.2 稿threshold值0.5
* v1.4.2 2022/10/31 v1.5 DPI缩放参数fx,fy
* v1.5
* ==================================================== * ====================================================
*/ */
@ -36,6 +37,7 @@
#include "ImageApply.h" #include "ImageApply.h"
class CImageApplyDispersion;
class CImageApplyAutoCrop : public CImageApply class CImageApplyAutoCrop : public CImageApply
{ {
public: public:
@ -53,9 +55,11 @@ public:
* indent [in]:indent像素访 * indent [in]:indent像素访
* normalCrop [in]:true时m_isCrop m_isDesaskew m_isFillBlank失效false * normalCrop [in]:true时m_isCrop m_isDesaskew m_isFillBlank失效false
* dispersion [in]:true时false时不除色散true * dispersion [in]:true时false时不除色散true
* fx [in]:1.0
* fy [in]:1.0
*/ */
CImageApplyAutoCrop(bool isCrop, bool isDesaskew, bool isFillBlank, const cv::Size& fixedSize, bool isConvex = true, CImageApplyAutoCrop(bool isCrop, bool isDesaskew, bool isFillBlank, const cv::Size& fixedSize, bool isConvex = true,
bool isFillColor = false, double threshold = 40, int noise = 8, int indent = 5, bool normalCrop = false, bool dispersion = true); bool isFillColor = false, double threshold = 40, int noise = 8, int indent = 5, bool normalCrop = false, bool dispersion = true, double fx = 1.0, double fy = 1.0);
virtual ~CImageApplyAutoCrop(); virtual ~CImageApplyAutoCrop();
@ -101,6 +105,16 @@ public:
void setDispersion(bool enable) { m_isDispersion = enable; } void setDispersion(bool enable) { m_isDispersion = enable; }
static void autoCrop_desaskew_fillBlank(cv::Mat& src, cv::Mat& dst, bool isAutoCrop, bool isDesaskew, bool isFillBlank, int dWidth, int dHeight,
bool isConvex = true, bool isColorBlank = false, double threshold = 40, int noise = 8, int indent = 5, bool isNormalCrop = false, bool dispersion = true,
double fx = 1.0, double fy = 1.0);
private:
static void myWarpAffine(cv::InputArray _src, cv::OutputArray _dst, cv::InputArray _M0, cv::Size dsize, int flags, int borderType, const cv::Scalar& borderValue);
static uchar getBackGroudChannelMean(const cv::Mat& gray, int total, int threshold);
static cv::Scalar getBackGroudColor(const cv::Mat& image, int threshold);
private: private:
bool m_isCrop; bool m_isCrop;
bool m_isDesaskew; bool m_isDesaskew;
@ -117,9 +131,9 @@ private:
cv::RotatedRect m_rect; cv::RotatedRect m_rect;
std::vector<cv::RotatedRect> m_rects; std::vector<cv::RotatedRect> m_rects;
std::vector<cv::Point> m_maxContour; std::vector<cv::Point> m_maxContour;
double m_fx;
double m_fy;
}; };
void autoCrop_desaskew_fillBlank(const cv::Mat& src, cv::Mat& dst, bool isAutoCrop, bool isDesaskew, bool isFillBlank, int dWidth, int dHeight,
bool isConvex = true, bool isColorBlank = false, double threshold = 40, int noise = 8, int indent = 5, bool isNormalCrop = false, bool dispersion = true);
#endif // !IMAGE_APPLY_AUTO_CROP_H #endif // !IMAGE_APPLY_AUTO_CROP_H

View File

@ -1568,6 +1568,10 @@ Result HuagaoDs::identityOpenDs(const Identity& origin) {
m_scanparam->is_switchfrontback = 0; m_scanparam->is_switchfrontback = 0;
m_scanparam->is_autodiscradblank_normal = m_scanparam->is_autodiscradblank_vince = m_scanparam->en_fold = 0; m_scanparam->is_autodiscradblank_normal = m_scanparam->is_autodiscradblank_vince = m_scanparam->en_fold = 0;
} }
//#ifdef LANXUM
// if (mech) m_scanparam->is_autodiscradblank_normal = true;
// else m_scanparam->is_autodiscradblank_normal = false;
//#endif
return success(); return success();
} }
return CapSupGetAllReset<BYTE, Bool, CapType::DuplexEnabled>(msg, data, m_scanparam->is_duplex, Bool(true)); return CapSupGetAllReset<BYTE, Bool, CapType::DuplexEnabled>(msg, data, m_scanparam->is_duplex, Bool(true));

Binary file not shown.

Binary file not shown.