mirror of http://192.168.1.51:8099/lmh188/twain3.0
调整部分协议
This commit is contained in:
parent
b3afcc4382
commit
2187375234
|
@ -1,65 +0,0 @@
|
|||
#pragma once
|
||||
#include <vector>
|
||||
#ifdef WIN32
|
||||
#include <io.h>
|
||||
#endif
|
||||
#include <fstream>
|
||||
#include <time.h>
|
||||
|
||||
class FileTools
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
static std::vector<std::string> getFiles(std::string path)
|
||||
{
|
||||
std::vector<std::string> files;
|
||||
getFiles(path, files);
|
||||
return files;
|
||||
}
|
||||
|
||||
static void write_log(std::string filename, std::string log)
|
||||
{
|
||||
//std::string savepath;
|
||||
//std::string str = "D:";
|
||||
//savepath = str+"\\"+filename;
|
||||
std::ofstream ofs(filename, std::ios::app);
|
||||
|
||||
time_t timp;
|
||||
struct tm* p;
|
||||
time(&timp);
|
||||
p=localtime(&timp);
|
||||
ofs << p->tm_year+1900 << "/" << p->tm_mon+1 << "/" << p->tm_mday << " " << p->tm_hour << ":" << p->tm_min << ":" << p->tm_sec << " "<<log << std::endl;
|
||||
}
|
||||
|
||||
private:
|
||||
static void getFiles(std::string path, std::vector<std::string>& files)
|
||||
{
|
||||
#ifdef WIN32
|
||||
//文件句柄
|
||||
long hFile = 0;
|
||||
//文件信息
|
||||
struct _finddata_t fileinfo;
|
||||
std::string p;
|
||||
if ((hFile = _findfirst(p.assign(path).append("\\*").c_str(), &fileinfo))!=-1)
|
||||
{
|
||||
do
|
||||
{
|
||||
//如果是目录,迭代之
|
||||
//如果不是,加入列表
|
||||
if ((fileinfo.attrib & _A_SUBDIR))
|
||||
{
|
||||
if (strcmp(fileinfo.name, ".") != 0 && strcmp(fileinfo.name, "..") != 0)
|
||||
getFiles(p.assign(path).append("\\").append(fileinfo.name), files);
|
||||
}
|
||||
else
|
||||
{
|
||||
files.push_back(p.assign(path).append("\\").append(fileinfo.name));
|
||||
}
|
||||
} while (_findnext(hFile, &fileinfo) == 0);
|
||||
_findclose(hFile);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
};
|
|
@ -28,4 +28,31 @@
|
|||
14.添加除底色功能
|
||||
15.修复折角 尺寸取图超时问题
|
||||
16.修复安卓机器usb连接断开卡死问题
|
||||
|
||||
2022年3月8日
|
||||
版本:3.3.5.7
|
||||
1.修复除背景色崩溃问题
|
||||
2.调整弹框,出现弹框前kill掉其他弹框
|
||||
3.调整进度指示器位置,在接收到一张图像后才会显示
|
||||
4.修复锐化默认值错误问题,由默认锐化改为不锐化
|
||||
5.黑白降噪json默认值由30改为10
|
||||
6.添加待纸扫描协议
|
||||
7.开放G300最大尺寸和最大尺寸自动裁切
|
||||
8.修复上批次图像未上传,下次扫描多上传问题
|
||||
2020年4月18日
|
||||
版本:3.3.5.8
|
||||
1.折角检测默认值设置为70
|
||||
2.dpi输入框添加
|
||||
3.添加多流输出
|
||||
4.添加按键停止连续扫描
|
||||
5.添加带孔扫描
|
||||
6.开放600dpi
|
||||
7.开放300/400真实dpi
|
||||
8.添加异常检测,程序崩溃后会生成dump文件记录异常(版本更新时需保存pdb文件以及源码)
|
||||
9.修复文件传输方式扫描时因文件名后缀导致崩溃问题
|
||||
10.更新穿孔移除算法
|
||||
11.最大尺寸调整为自动裁切,根据下层上传图像自动裁切大小,不再是固定幅面
|
||||
12.去掉C++与c输入输出流同步
|
||||
13.添加画质优先与速度优先模式
|
||||
14.调整互斥锁,不同设备能在同一台pc上使用
|
||||
15.调整速度优先600 dpi 按照真实300dpi 缩放
|
||||
16.协议问题排查
|
|
@ -63,6 +63,8 @@ BOOL CAboutDlg::OnInitDialog()
|
|||
HBITMAP hBitmap = ::LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BITMAP4));
|
||||
#elif defined MAKERIGHTWAY
|
||||
HBITMAP hBitmap = ::LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BITMAP5));
|
||||
#else
|
||||
HBITMAP hBitmap = ::LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BMPABOUTDLG));
|
||||
#endif
|
||||
pStatic->ModifyStyle(0xF, SS_BITMAP | SS_CENTERIMAGE);
|
||||
pStatic->SetBitmap(hBitmap);
|
||||
|
|
|
@ -60,6 +60,10 @@ static std::vector<CString> surportStyles = {
|
|||
_T("Letter"),
|
||||
_T("LEGAL"),
|
||||
_T("匹配原始尺寸"),
|
||||
#ifndef ANDROIDSERIAL
|
||||
_T("最大扫描尺寸自动裁切"),
|
||||
_T("最大扫描尺寸"),
|
||||
#endif // !ANDROIDSERIAL
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -152,7 +156,7 @@ BOOL CBasicPage::OnInitDialog()
|
|||
m_cmBoxDuplex = (CComboBox*)GetDlgItem(IDC_CMBDUPLEX);
|
||||
|
||||
m_Edit_Dpi.SetSlideLink(this, IDC_SLIDERDPI);
|
||||
m_Edit_Dpi.SetParams(100, 300, 10);
|
||||
m_Edit_Dpi.SetParams(100, 600, 10);
|
||||
m_Edit_Dpi.SetValue(200);
|
||||
|
||||
for (const CString& colorMode : color_Modes)
|
||||
|
@ -169,6 +173,7 @@ BOOL CBasicPage::OnInitDialog()
|
|||
m_cmBoxSS->SetCurSel(0);
|
||||
m_cmBoxColorMode->SetCurSel(0);
|
||||
m_cmBoxDuplex->SetCurSel(0);
|
||||
((CButton*)GetDlgItem(IDC_RDQUALITYPRIORITY))->SetCheck(FALSE);
|
||||
|
||||
#ifndef UV
|
||||
GetDlgItem(IDC_CKBENABLEUV)->ShowWindow(FALSE);
|
||||
|
@ -187,6 +192,9 @@ BEGIN_MESSAGE_MAP(CBasicPage, CTabPageSSL)
|
|||
ON_BN_CLICKED(IDC_BTNDISCARDSETTING, &CBasicPage::OnClickedBtndiscardsetting)
|
||||
ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_SLIDERDPI, &CBasicPage::OnNMReleasedcaptureSliderdpi)
|
||||
ON_BN_CLICKED(IDC_BTN_ATTRIBYTE, &CBasicPage::OnBnClickedBtnAttribyte)
|
||||
ON_EN_CHANGE(IDC_EDITDPI, &CBasicPage::OnEnChangeEditdpi)
|
||||
ON_BN_CLICKED(IDC_RDSPEEDPRIORITY, &CBasicPage::OnBnClickedRdspeedpriority)
|
||||
ON_BN_CLICKED(IDC_RDQUALITYPRIORITY, &CBasicPage::OnBnClickedRdqualitypriority)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
|
@ -195,9 +203,24 @@ END_MESSAGE_MAP()
|
|||
|
||||
void CBasicPage::OnBnClickedBtnabout()
|
||||
{
|
||||
CAboutDlg dlg(m_hdVersion, m_serialNum,m_macadder,this);
|
||||
#ifndef NOLOGO
|
||||
CAboutDlg dlg(m_hdVersion, m_serialNum, m_macadder, this);
|
||||
dlg.DoModal();
|
||||
|
||||
#else
|
||||
#ifdef G300
|
||||
std::string text = "扫描仪名称:\t\tG300 \n固件版本:\t\t\t";
|
||||
#elif defined G400
|
||||
std::string text = "扫描仪名称:\t\tG400 \n固件版本:\t\t\t";
|
||||
#elif defined G200 && defined ISG100
|
||||
std::string text = "扫描仪名称:\t\tG100 \n固件版本:\t\t\t";
|
||||
#else
|
||||
std::string text = "扫描仪名称:\t\tG200 \n固件版本:\t\t\t";
|
||||
#endif
|
||||
text += m_hdVersion.c_str();
|
||||
text += "\n序列号:\t\t\t";
|
||||
text += m_serialNum.c_str();
|
||||
::MessageBox(this->GetSafeHwnd(), CString(text.c_str()), L"关于",0);
|
||||
#endif // !NOLOGO
|
||||
}
|
||||
|
||||
|
||||
|
@ -288,52 +311,22 @@ void CBasicPage::updateCmbDuplex(BOOL insert)
|
|||
GetDlgItem(IDC_CKBSWITCHFRONTBACK)->EnableWindow(TRUE);
|
||||
}
|
||||
|
||||
if (tmp_colorindex == 0 && tmp_paperindex > 19 && tmp_resindex >= 300) {
|
||||
if (m_cmBoxDuplex->GetCurSel() == 4)
|
||||
{
|
||||
m_cmBoxDuplex->SetCurSel(1);
|
||||
}
|
||||
m_cmBoxDuplex->DeleteString(4);
|
||||
//m_cmBoxDuplex->SetCurSel(1);
|
||||
}
|
||||
else {
|
||||
if (totalcount != 5) {
|
||||
m_cmBoxDuplex->InsertString(4, TEXT("对折"));
|
||||
}
|
||||
}
|
||||
#ifdef G200
|
||||
if (m_Slider_Dpi.m_iPosition > 300 && m_cmBoxSS->GetCount() > 20)
|
||||
{
|
||||
if (m_cmBoxSS->GetCurSel() >= 20)
|
||||
m_cmBoxSS->SetCurSel(19);
|
||||
m_cmBoxSS->DeleteString(22);
|
||||
m_cmBoxSS->DeleteString(21);
|
||||
m_cmBoxSS->DeleteString(20);
|
||||
}
|
||||
else if (m_Slider_Dpi.m_iPosition <= 300 && m_cmBoxSS->GetCount() <= 20)
|
||||
{
|
||||
m_cmBoxSS->InsertString(20, _T("最大扫描尺寸自动裁切"));
|
||||
m_cmBoxSS->InsertString(21, _T("最大扫描尺寸"));
|
||||
m_cmBoxSS->InsertString(22, _T("三联试卷"));
|
||||
}
|
||||
#endif // G200
|
||||
OnNMReleasedcaptureSliderdpi(nullptr, nullptr);
|
||||
#ifndef G300
|
||||
if (tmp_paperindex == 19 || tmp_paperindex == 20 || tmp_paperindex == 21 || tmp_paperindex == 22 || tmp_paperindex == 1|| tmp_paperindex == 4|| tmp_paperindex == 5){
|
||||
(((CButton*)GetDlgItem(IDC_CKBSIZEDETECT)))->SetCheck(false);
|
||||
GetDlgItem(IDC_CKBSIZEDETECT)->EnableWindow(false);
|
||||
}
|
||||
else{
|
||||
GetDlgItem(IDC_CKBSIZEDETECT)->EnableWindow(true);
|
||||
}
|
||||
#else
|
||||
if (tmp_paperindex == 8|| tmp_paperindex == 1) {
|
||||
if (tmp_paperindex == 8|| tmp_paperindex == 1 || tmp_paperindex == 9 || tmp_paperindex == 10) {
|
||||
#endif // G200
|
||||
(((CButton*)GetDlgItem(IDC_CKBSIZEDETECT)))->SetCheck(false);
|
||||
GetDlgItem(IDC_CKBSIZEDETECT)->EnableWindow(false);
|
||||
(((CButton*)GetDlgItem(IDC_CKFIXEDPAPER)))->SetCheck(false);
|
||||
GetDlgItem(IDC_CKFIXEDPAPER)->EnableWindow(false);
|
||||
}
|
||||
else {
|
||||
GetDlgItem(IDC_CKBSIZEDETECT)->EnableWindow(true);
|
||||
GetDlgItem(IDC_CKFIXEDPAPER)->EnableWindow(true);
|
||||
}
|
||||
#endif // G200
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -343,21 +336,51 @@ void CBasicPage::OnNMReleasedcaptureSliderdpi(NMHDR* pNMHDR, LRESULT* pResult)
|
|||
// TODO: 在此添加控件通知处理程序代码
|
||||
if(pResult!=nullptr)
|
||||
*pResult = 0;
|
||||
#ifdef G200
|
||||
if (m_Slider_Dpi.m_iPosition >= 500) {
|
||||
((CButton*)GetDlgItem(IDC_RDQUALITYPRIORITY))->EnableWindow(FALSE);
|
||||
((CButton*)GetDlgItem(IDC_RDSPEEDPRIORITY))->EnableWindow(FALSE);
|
||||
((CButton*)GetDlgItem(IDC_RDQUALITYPRIORITY))->SetCheck(TRUE);
|
||||
((CButton*)GetDlgItem(IDC_RDSPEEDPRIORITY))->SetCheck(FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
((CButton*)GetDlgItem(IDC_RDQUALITYPRIORITY))->EnableWindow(TRUE);
|
||||
((CButton*)GetDlgItem(IDC_RDSPEEDPRIORITY))->EnableWindow(TRUE);
|
||||
}
|
||||
|
||||
if (m_Slider_Dpi.m_iPosition > 300 && m_cmBoxSS->GetCount() > 20)
|
||||
if (((m_Slider_Dpi.m_iPosition >= 300 && ((CButton*)GetDlgItem(IDC_RDQUALITYPRIORITY))->GetCheck()) ||
|
||||
(m_Slider_Dpi.m_iPosition >= 500 && ((CButton*)GetDlgItem(IDC_RDSPEEDPRIORITY))->GetCheck())) &&
|
||||
#ifdef G300
|
||||
m_cmBoxSS->GetCount() > 9)
|
||||
{
|
||||
if (m_cmBoxSS->GetCurSel() >= 9)
|
||||
m_cmBoxSS->SetCurSel(8);
|
||||
m_cmBoxSS->DeleteString(9);
|
||||
m_cmBoxSS->DeleteString(10);
|
||||
#else
|
||||
m_cmBoxSS->GetCount() > 20)
|
||||
{
|
||||
if (m_cmBoxSS->GetCurSel() >= 20)
|
||||
m_cmBoxSS->SetCurSel(19);
|
||||
m_cmBoxSS->DeleteString(22);
|
||||
m_cmBoxSS->DeleteString(21);
|
||||
m_cmBoxSS->DeleteString(20);
|
||||
#endif // G300
|
||||
}
|
||||
else if (m_Slider_Dpi.m_iPosition <= 300 && m_cmBoxSS->GetCount() <= 20)
|
||||
else if (((m_Slider_Dpi.m_iPosition < 300 && ((CButton*)GetDlgItem(IDC_RDQUALITYPRIORITY))->GetCheck()) ||
|
||||
(m_Slider_Dpi.m_iPosition < 500 && ((CButton*)GetDlgItem(IDC_RDSPEEDPRIORITY))->GetCheck())) &&
|
||||
#ifdef G300
|
||||
m_cmBoxSS->GetCount() <= 9)
|
||||
{
|
||||
m_cmBoxSS->InsertString(9, _T("最大扫描尺寸自动裁切"));
|
||||
m_cmBoxSS->InsertString(10, _T("最大扫描尺寸"));
|
||||
#else
|
||||
m_cmBoxSS->GetCount() <= 20)
|
||||
{
|
||||
m_cmBoxSS->InsertString(20,_T("最大扫描尺寸自动裁切"));
|
||||
m_cmBoxSS->InsertString(21,_T("最大扫描尺寸"));
|
||||
m_cmBoxSS->InsertString(22,_T("三联试卷"));
|
||||
#endif // G300
|
||||
}
|
||||
if (m_Slider_Dpi.m_iPosition > 300 && m_cmBoxDuplex->GetCount() > 4)
|
||||
{
|
||||
|
@ -369,8 +392,6 @@ void CBasicPage::OnNMReleasedcaptureSliderdpi(NMHDR* pNMHDR, LRESULT* pResult)
|
|||
{
|
||||
m_cmBoxDuplex->InsertString(4, _T("对折"));
|
||||
}
|
||||
#endif // G200
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -380,3 +401,29 @@ void CBasicPage::OnBnClickedBtnAttribyte()
|
|||
CAttributeDlg attributedlg(this);
|
||||
attributedlg.DoModal();
|
||||
}
|
||||
|
||||
|
||||
void CBasicPage::OnEnChangeEditdpi()
|
||||
{
|
||||
// TODO: 如果该控件是 RICHEDIT 控件,它将不
|
||||
// 发送此通知,除非重写 CTabPageSSL::OnInitDialog()
|
||||
// 函数并调用 CRichEditCtrl().SetEventMask(),
|
||||
// 同时将 ENM_CHANGE 标志“或”运算到掩码中。
|
||||
|
||||
// TODO: 在此添加控件通知处理程序代码
|
||||
OnNMReleasedcaptureSliderdpi(nullptr, nullptr);
|
||||
}
|
||||
|
||||
|
||||
void CBasicPage::OnBnClickedRdspeedpriority()
|
||||
{
|
||||
// TODO: 在此添加控件通知处理程序代码
|
||||
OnNMReleasedcaptureSliderdpi(nullptr, nullptr);
|
||||
}
|
||||
|
||||
|
||||
void CBasicPage::OnBnClickedRdqualitypriority()
|
||||
{
|
||||
// TODO: 在此添加控件通知处理程序代码
|
||||
OnNMReleasedcaptureSliderdpi(nullptr, nullptr);
|
||||
}
|
||||
|
|
|
@ -57,4 +57,7 @@ public:
|
|||
afx_msg void OnCbnSelchangeCblowpowermode();
|
||||
afx_msg void OnNMReleasedcaptureSliderdpi(NMHDR* pNMHDR, LRESULT* pResult);
|
||||
afx_msg void OnBnClickedBtnAttribyte();
|
||||
afx_msg void OnEnChangeEditdpi();
|
||||
afx_msg void OnBnClickedRdspeedpriority();
|
||||
afx_msg void OnBnClickedRdqualitypriority();
|
||||
};
|
||||
|
|
|
@ -100,6 +100,7 @@ BEGIN_MESSAGE_MAP(CFeedPaperPage, CTabPageSSL)
|
|||
ON_BN_CLICKED(IDC_CKSKEWDETECT, &CFeedPaperPage::OnBnClickedCkskewdetect)
|
||||
ON_CBN_SELCHANGE(IDC_CMBORENTATION, &CFeedPaperPage::OnCbnSelchangeCmborentation)
|
||||
ON_BN_CLICKED(IDC_DogEarDetection, &CFeedPaperPage::OnBnClickedDogeardetection)
|
||||
ON_BN_CLICKED(IDC_CKAUTOPAPER, &CFeedPaperPage::OnBnClickedCkautopaper)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
BOOL CFeedPaperPage::PreTranslateMessage(MSG* pMsg)
|
||||
|
@ -197,3 +198,22 @@ void CFeedPaperPage::OnBnClickedDogeardetection()
|
|||
m_slider_dogear.EnableWindow(TRUE);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CFeedPaperPage::OnBnClickedCkautopaper()
|
||||
{
|
||||
// TODO: 在此添加控件通知处理程序代码
|
||||
if (((CButton*)GetDlgItem(IDC_CKAUTOPAPER))->GetCheck())
|
||||
{
|
||||
CButton* m_tempBtn = ((CButton*)GetDlgItem(IDC_RDCONSISTSCAN));
|
||||
m_tempBtn->SetCheck(TRUE);
|
||||
m_editNum.SetWindowText( _T("-1"));
|
||||
m_radioGroupScanMode = 0;
|
||||
((CButton*)GetDlgItem(IDC_RDSPECIFYSCANNUM))->SetCheck(FALSE);
|
||||
GetDlgItem(IDC_RDSPECIFYSCANNUM)->EnableWindow(FALSE);
|
||||
m_editNum.EnableWindow(m_radioGroupScanMode);
|
||||
}
|
||||
else
|
||||
GetDlgItem(IDC_RDSPECIFYSCANNUM)->EnableWindow(TRUE);
|
||||
|
||||
}
|
||||
|
|
|
@ -50,4 +50,5 @@ public:
|
|||
afx_msg void OnCbnSelchangeCmborentation();
|
||||
|
||||
afx_msg void OnBnClickedDogeardetection();
|
||||
afx_msg void OnBnClickedCkautopaper();
|
||||
};
|
||||
|
|
|
@ -26,6 +26,13 @@ static std::vector<CString> sharpens = {
|
|||
_T("模糊"),
|
||||
_T("进一步模糊")
|
||||
};
|
||||
|
||||
static std::vector<CString> multiout = {
|
||||
_T("彩色+灰度+黑白"),
|
||||
_T("彩色+灰度"),
|
||||
_T("彩色+黑白"),
|
||||
_T("灰度+黑白")
|
||||
};
|
||||
// CImageProcPage 对话框
|
||||
|
||||
IMPLEMENT_DYNAMIC(CImageProcPage, CTabPageSSL)
|
||||
|
@ -69,12 +76,18 @@ void CImageProcPage::ImageProcPageUpdate(int val,int twss, int cmduplexsel,bool
|
|||
{
|
||||
GetDlgItem(IDC_CKHSVCORRECT)->EnableWindow(TRUE);
|
||||
GetDlgItem(IDC_CKBACKGROUNDSMOOTH)->EnableWindow(TRUE);
|
||||
GetDlgItem(IDC_CHMULTIPUT)->EnableWindow(TRUE);
|
||||
GetDlgItem(IDC_CMBMULTIOUT)->EnableWindow(((CButton*)GetDlgItem(IDC_CHMULTIPUT))->GetCheck());
|
||||
}
|
||||
else {
|
||||
GetDlgItem(IDC_CKHSVCORRECT)->EnableWindow(FALSE);
|
||||
((CButton*)GetDlgItem(IDC_CKHSVCORRECT))->SetCheck(FALSE);
|
||||
GetDlgItem(IDC_CKBACKGROUNDSMOOTH)->EnableWindow(FALSE);
|
||||
((CButton*)GetDlgItem(IDC_CKBACKGROUNDSMOOTH))->SetCheck(FALSE);
|
||||
GetDlgItem(IDC_CHMULTIPUT)->EnableWindow(FALSE);
|
||||
((CButton*)GetDlgItem(IDC_CHMULTIPUT))->SetCheck(FALSE);
|
||||
GetDlgItem(IDC_CMBMULTIOUT)->EnableWindow(FALSE);
|
||||
((CButton*)GetDlgItem(IDC_CMBMULTIOUT))->SetCheck(FALSE);
|
||||
}
|
||||
if (0 == val||val==3)//彩色
|
||||
{
|
||||
|
@ -103,9 +116,9 @@ void CImageProcPage::ImageProcPageUpdate(int val,int twss, int cmduplexsel,bool
|
|||
m_slider_detachnoise.EnableWindow(false);
|
||||
}
|
||||
#ifndef G300
|
||||
if (twss == 19 || twss == 20 || (cmduplexsel == 4) || ((CButton*)GetDlgItem(IDC_CKFILLBLACKRECT))->GetCheck() || ((CButton*)GetDlgItem(IDC_CKAUTODESKREW))->GetCheck())
|
||||
if (twss == 19 || twss == 20 || twss == 21 || (cmduplexsel == 4) || ((CButton*)GetDlgItem(IDC_CKFILLBLACKRECT))->GetCheck() || ((CButton*)GetDlgItem(IDC_CKAUTODESKREW))->GetCheck())
|
||||
#else
|
||||
if (twss == 8 || (cmduplexsel == 4) || ((CButton*)GetDlgItem(IDC_CKFILLBLACKRECT))->GetCheck() || ((CButton*)GetDlgItem(IDC_CKAUTODESKREW))->GetCheck())
|
||||
if (twss == 8 || twss == 9 || twss == 10 || (cmduplexsel == 4) || ((CButton*)GetDlgItem(IDC_CKFILLBLACKRECT))->GetCheck() || ((CButton*)GetDlgItem(IDC_CKAUTODESKREW))->GetCheck())
|
||||
#endif // !G300
|
||||
{
|
||||
((CButton*)GetDlgItem(IDC_CKCROPMODEL))->SetCheck(false);
|
||||
|
@ -172,6 +185,11 @@ BOOL CImageProcPage::OnInitDialog()
|
|||
m_cmBoxSharpen.InsertString(i, sharpens[i]);
|
||||
}
|
||||
|
||||
for (int i = 0; i < multiout.size(); i++)
|
||||
{
|
||||
((CComboBox*)GetDlgItem(IDC_CMBMULTIOUT))->InsertString(i, multiout[i]);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -183,6 +201,8 @@ BEGIN_MESSAGE_MAP(CImageProcPage, CTabPageSSL)
|
|||
ON_BN_CLICKED(IDC_CKAUTODESKREW, &CImageProcPage::OnBnClickedCkautodeskrew)
|
||||
ON_BN_CLICKED(IDC_CHECKDETACHNOISE, &CImageProcPage::OnBnClickedCheckdetachnoise)
|
||||
ON_BN_CLICKED(IDC_CKBACKGROUNDSMOOTH, &CImageProcPage::OnBnClickedCkbackgroundsmooth)
|
||||
ON_BN_CLICKED(IDC_CHMULTIPUT, &CImageProcPage::OnBnClickedChmultiput)
|
||||
ON_BN_CLICKED(IDC_CKMULTIOUTPUT, &CImageProcPage::OnBnClickedCkmultioutput)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
void CImageProcPage::EnableOutHoleCheckChanged(BOOL enable)
|
||||
|
@ -252,9 +272,9 @@ void CImageProcPage::OnBnClickedCkfillblackrect()
|
|||
((CButton*)GetDlgItem(IDC_ADVANCEDSET))->EnableWindow(false);
|
||||
}
|
||||
#ifndef G300
|
||||
if (twss == 19 || twss == 20 || (cmduplexsel == 4) || ((CButton*)GetDlgItem(IDC_CKFILLBLACKRECT))->GetCheck() || ((CButton*)GetDlgItem(IDC_CKAUTODESKREW))->GetCheck())
|
||||
if (twss == 19 || twss == 20|| twss == 21 || (cmduplexsel == 4) || ((CButton*)GetDlgItem(IDC_CKFILLBLACKRECT))->GetCheck() || ((CButton*)GetDlgItem(IDC_CKAUTODESKREW))->GetCheck())
|
||||
#else
|
||||
if (twss == 8|| (cmduplexsel == 4) || ((CButton*)GetDlgItem(IDC_CKFILLBLACKRECT))->GetCheck() || ((CButton*)GetDlgItem(IDC_CKAUTODESKREW))->GetCheck())
|
||||
if (twss == 8 || twss == 9 || twss == 10 || (cmduplexsel == 4) || ((CButton*)GetDlgItem(IDC_CKFILLBLACKRECT))->GetCheck() || ((CButton*)GetDlgItem(IDC_CKAUTODESKREW))->GetCheck())
|
||||
#endif // !G300
|
||||
{
|
||||
((CButton*)GetDlgItem(IDC_CKCROPMODEL))->SetCheck(false);
|
||||
|
@ -275,9 +295,9 @@ void CImageProcPage::OnBnClickedCkautodeskrew()
|
|||
((CButton*)GetDlgItem(IDC_ADVANCEDSET))->EnableWindow(false);
|
||||
}
|
||||
#ifndef G300
|
||||
if (twss == 19 || twss == 20 || (cmduplexsel == 4) || ((CButton*)GetDlgItem(IDC_CKFILLBLACKRECT))->GetCheck() || ((CButton*)GetDlgItem(IDC_CKAUTODESKREW))->GetCheck())
|
||||
if (twss == 19 || twss == 20 || twss == 21|| (cmduplexsel == 4) || ((CButton*)GetDlgItem(IDC_CKFILLBLACKRECT))->GetCheck() || ((CButton*)GetDlgItem(IDC_CKAUTODESKREW))->GetCheck())
|
||||
#else
|
||||
if (twss == 8 || (cmduplexsel == 4) || ((CButton*)GetDlgItem(IDC_CKFILLBLACKRECT))->GetCheck() || ((CButton*)GetDlgItem(IDC_CKAUTODESKREW))->GetCheck())
|
||||
if (twss == 8 || twss == 9 || twss == 10 || (cmduplexsel == 4) || ((CButton*)GetDlgItem(IDC_CKFILLBLACKRECT))->GetCheck() || ((CButton*)GetDlgItem(IDC_CKAUTODESKREW))->GetCheck())
|
||||
#endif // !G300
|
||||
{
|
||||
((CButton*)GetDlgItem(IDC_CKCROPMODEL))->SetCheck(false);
|
||||
|
@ -306,3 +326,37 @@ void CImageProcPage::OnBnClickedCkbackgroundsmooth()
|
|||
GetDlgItem(IDC_SLIDERFADEBACKRANGE)->EnableWindow(m_ckbfadeback);
|
||||
GetDlgItem(IDC_EDITFADEBACKRANGE)->EnableWindow(m_ckbfadeback);
|
||||
}
|
||||
|
||||
|
||||
void CImageProcPage::OnBnClickedChmultiput()
|
||||
{
|
||||
// TODO: 在此添加控件通知处理程序代码
|
||||
if (((CButton*)GetDlgItem(IDC_CHMULTIPUT))->GetCheck()) {
|
||||
GetDlgItem(IDC_CMBMULTIOUT)->EnableWindow(TRUE);
|
||||
GetDlgItem(IDC_CKMULTIOUTPUT)->EnableWindow(FALSE);
|
||||
((CButton*)GetDlgItem(IDC_CKMULTIOUTPUT))->SetCheck(FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
GetDlgItem(IDC_CMBMULTIOUT)->EnableWindow(FALSE);
|
||||
((CComboBox*)GetDlgItem(IDC_CMBMULTIOUT))->SetCurSel(0);
|
||||
GetDlgItem(IDC_CKMULTIOUTPUT)->EnableWindow(TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CImageProcPage::OnBnClickedCkmultioutput()
|
||||
{
|
||||
// TODO: 在此添加控件通知处理程序代码
|
||||
if (((CButton*)GetDlgItem(IDC_CKMULTIOUTPUT))->GetCheck()) {
|
||||
GetDlgItem(IDC_CMBMULTIOUT)->EnableWindow(FALSE);
|
||||
GetDlgItem(IDC_CHMULTIPUT)->EnableWindow(FALSE);
|
||||
((CButton*)GetDlgItem(IDC_CHMULTIPUT))->SetCheck(FALSE);
|
||||
((CComboBox*)GetDlgItem(IDC_CMBMULTIOUT))->SetCurSel(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
GetDlgItem(IDC_CMBMULTIOUT)->EnableWindow(FALSE);
|
||||
GetDlgItem(IDC_CHMULTIPUT)->EnableWindow(TRUE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,4 +65,6 @@ public:
|
|||
afx_msg void OnBnClickedCkautodeskrew();
|
||||
afx_msg void OnBnClickedCheckdetachnoise();
|
||||
afx_msg void OnBnClickedCkbackgroundsmooth();
|
||||
afx_msg void OnBnClickedChmultiput();
|
||||
afx_msg void OnBnClickedCkmultioutput();
|
||||
};
|
||||
|
|
|
@ -47,9 +47,12 @@ END_MESSAGE_MAP()
|
|||
|
||||
void CIndicatorDlg::setindicatortext(int aquire, int updata)
|
||||
{
|
||||
wchar_t text[260] = { 0 };
|
||||
_stprintf(text, L"扫描\t\t\t\t%d 页\n上传\t\t\t\t%d 面", aquire,updata);
|
||||
GetDlgItem(IDC_STATIC)->SetWindowTextW(text);
|
||||
//wchar_t text[260] = { 0 };
|
||||
CString str;
|
||||
str.Format(L"扫描\t\t\t\t%d 页\n上传\t\t\t\t%d 面", aquire, updata);
|
||||
//_stprintf(text, L"扫描\t\t\t\t%d 页\n上传\t\t\t\t%d 面", aquire,updata);
|
||||
// GetDlgItem(IDC_STATIC_TIPS)->SetWindowTextW(str);
|
||||
SetDlgItemText(IDC_STATIC_TIPS,str);
|
||||
}
|
||||
|
||||
void CIndicatorDlg::OnBnClickedBtnstopscan()
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include "CImageProcPage.h"
|
||||
#include "Device/PaperSize.h"
|
||||
#include <list>
|
||||
#include "filetools.h"
|
||||
#include "Device/filetools.h"
|
||||
#include "GscanJsonConfig.h"
|
||||
// CTwainUI 对话框
|
||||
|
||||
|
@ -80,16 +80,12 @@ BOOL CTwainUI::OnInitDialog()
|
|||
UpdateUI();
|
||||
UpdateListConfig();
|
||||
dataChangeFunction();
|
||||
#ifdef ANDROIDSERIAL
|
||||
setvisable_size(false);
|
||||
#endif // ANDROIDSERIAL
|
||||
setvisable_sleepmode(false);
|
||||
#ifdef G200
|
||||
setvisable_dogear(true);
|
||||
if (m_hardwareVersion.size() > 9)
|
||||
if (m_hardwareVersion.size() > 9 && m_hardwareVersion.substr(2,2) == "39")
|
||||
{
|
||||
if (m_hardwareVersion[5] > 'A' || atoi(m_hardwareVersion.substr(6, 4).c_str()) > 1209)
|
||||
{
|
||||
if ((m_hardwareVersion[5] == 'A' && atoi(m_hardwareVersion.substr(6, 4).c_str()) > 1209)|| (m_hardwareVersion[5] > 'A'))
|
||||
{
|
||||
if (m_mbversion >= 35211210)
|
||||
setvisable_autopaper(true);
|
||||
else
|
||||
|
@ -97,11 +93,52 @@ BOOL CTwainUI::OnInitDialog()
|
|||
}
|
||||
else
|
||||
setvisable_autopaper(false);
|
||||
if ((m_hardwareVersion[5] == 'B' && atoi(m_hardwareVersion.substr(6, 4).c_str()) >= 412)||(m_hardwareVersion[5] > 'B'))
|
||||
setvisable_fixedpaper(true);
|
||||
else
|
||||
setvisable_fixedpaper(false);
|
||||
setvisable_dogear(true);
|
||||
setvisable_size(true);
|
||||
}
|
||||
else {
|
||||
setvisable_dogear(false);
|
||||
setvisable_size(false);
|
||||
setvisable_autopaper(false);
|
||||
setvisable_fixedpaper(false);
|
||||
}
|
||||
#else
|
||||
#ifndef ANDROIDSERIAL
|
||||
setvisable_dogear(true);
|
||||
if (m_hardwareVersion.size() > 9 && m_hardwareVersion.substr(2,2) == "39")
|
||||
{
|
||||
if ((m_hardwareVersion[5] == 'B' && atoi(m_hardwareVersion.substr(6, 4).c_str()) > 422)||(m_hardwareVersion[5] > 'B')){
|
||||
setvisable_autopaper(true);
|
||||
}
|
||||
else {
|
||||
setvisable_autopaper(false);
|
||||
}
|
||||
setvisable_dogear(true);
|
||||
setvisable_size(true);
|
||||
setvisable_fixedpaper(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
setvisable_dogear(false);
|
||||
if(((atoi(m_hardwareVersion.substr(4, 2).c_str()) == 22)&& (atoi(m_hardwareVersion.substr(6,4).c_str())> 401))||((atoi(m_hardwareVersion.substr(4, 2).c_str()) > 22)))
|
||||
setvisable_size(true);
|
||||
else
|
||||
setvisable_size(false);
|
||||
setvisable_autopaper(false);
|
||||
setvisable_fixedpaper(false);
|
||||
}
|
||||
#else
|
||||
setvisable_dogear(false);
|
||||
setvisable_size(false);
|
||||
setvisable_autopaper(false);
|
||||
setvisable_fixedpaper(false);
|
||||
#endif
|
||||
#endif // G200
|
||||
//setvisable_fixedpaper(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -173,7 +210,10 @@ void CTwainUI::UpdateUI()
|
|||
m_pageBasic->m_cmBoxSS->SetCurSel(getPaparSizeIndex(settings->papertype, settings->paperAlign)); //!< 纸张类型
|
||||
m_pageBasic->m_enableSizeCheck = settings->en_sizecheck==1?TRUE:FALSE;//!< 尺寸检测
|
||||
m_pageBasic->m_bswitchfrontback = settings->is_switchfrontback ? TRUE : FALSE; //!< 交换正反面
|
||||
((CButton*)m_pageBasic->GetDlgItem(IDC_RDQUALITYPRIORITY))->SetCheck(settings->is_high_imagequality);
|
||||
((CButton*)m_pageBasic->GetDlgItem(IDC_RDSPEEDPRIORITY))->SetCheck(!settings->is_high_imagequality);
|
||||
((CButton*)m_pageBasic->GetDlgItem(IDC_CKSPLIT))->SetCheck(settings->is_split);
|
||||
((CButton*)m_pageBasic->GetDlgItem(IDC_CKFIXEDPAPER))->SetCheck(settings->en_fixedpaper);
|
||||
#ifdef UV
|
||||
m_pageBasic->m_bUV = settings->hardwarecaps.en_uv == 1 ? TRUE : FALSE;
|
||||
#endif
|
||||
|
@ -226,6 +266,11 @@ void CTwainUI::UpdateUI()
|
|||
m_pageImageProc->m_ckbDetachNoise = settings->detachnoise.is_detachnoise == TRUE ? TRUE : FALSE;//黑白降噪是否启用
|
||||
((CButton*)m_pageImageProc->GetDlgItem(IDC_CHECKDETACHNOISE))->SetCheck(m_pageImageProc->m_ckbDetachNoise);
|
||||
((CButton*)m_pageImageProc->GetDlgItem(IDC_CHECKDETACHNOISE))->EnableWindow(settings->pixtype != 2);
|
||||
((CButton*)m_pageImageProc->GetDlgItem(IDC_CHMULTIPUT))->SetCheck(settings->pixtype != 2 ? FALSE:settings->en_multi_output); // 多流输出
|
||||
m_pageImageProc->GetDlgItem(IDC_CHMULTIPUT)->EnableWindow(settings->pixtype != 2);
|
||||
|
||||
((CComboBox*)m_pageImageProc->GetDlgItem(IDC_CMBMULTIOUT))->SetCurSel(settings->pixtype != 2 ? 0 : (settings->en_multi_output?(settings->multioutput<0?0:settings->multioutput):0));
|
||||
m_pageImageProc->GetDlgItem(IDC_CMBMULTIOUT)->EnableWindow(settings->pixtype != 2 ? FALSE : settings->en_multi_output);
|
||||
m_pageImageProc->m_edit_detachnoise.SetValue(settings->detachnoise.detachnoise);
|
||||
m_pageImageProc->m_slider_detachnoise.EnableWindow(settings->detachnoise.is_detachnoise == TRUE ? TRUE : FALSE);
|
||||
m_pageImageProc->m_edit_detachnoise.EnableWindow(settings->detachnoise.is_detachnoise == TRUE ? TRUE : FALSE);
|
||||
|
@ -259,7 +304,7 @@ void CTwainUI::UpdateUI()
|
|||
m_pageFeedPaper->m_slider_dogear.SetPos(settings->dogeardistance);
|
||||
m_pageFeedPaper->m_slider_dogear.EnableWindow(((CButton*)m_pageFeedPaper->GetDlgItem(IDC_DogEarDetection))->GetCheck());
|
||||
((CComboBox*)m_pageFeedPaper->GetDlgItem(IDC_CBLOWPOWERMODE))->SetCurSel(settings->hardwarecaps.lowpowermode);
|
||||
if (settings->scannum == 65535)//连续扫描
|
||||
if (settings->scannum == 65535 || settings->hardwarecaps.is_autopaper)//连续扫描
|
||||
{
|
||||
m_pageFeedPaper->m_radioGroupScanMode = 0;
|
||||
m_pageFeedPaper->GetDlgItem(IDC_EDSCANNUM)->SetWindowText(_T("1"));
|
||||
|
@ -438,6 +483,7 @@ void CTwainUI::UpDateScanParam(PCONFIGPARAMS configItem, bool updateDs)
|
|||
configItem->Duplex = m_pageBasic->m_cmBoxDuplex->GetCurSel();//!< 单双面
|
||||
configItem->PaperSize = m_pageBasic->m_cmBoxSS->GetCurSel();//!< 纸张类型 index
|
||||
configItem->EnSwitchFrontBack = m_pageBasic->m_bswitchfrontback == TRUE ? true : false;
|
||||
settings->is_high_imagequality = ((CButton*)m_pageBasic->GetDlgItem(IDC_RDQUALITYPRIORITY))->GetCheck();
|
||||
configItem->LowPowerMode = ((CComboBox*)m_pageFeedPaper->GetDlgItem(IDC_CBLOWPOWERMODE))->GetCurSel();//!<休眠模式
|
||||
PaperStatus page = paperStatusMap[configItem->PaperSize];
|
||||
configItem->EnAutoCrop = page.Paper == TwSS::None;
|
||||
|
@ -499,6 +545,7 @@ void CTwainUI::UpDateScanParam(PCONFIGPARAMS configItem, bool updateDs)
|
|||
settings->paperAlign = (PaperAlign)paper.Orentate;
|
||||
|
||||
settings->en_sizecheck = configItem->EnSizeCheck;
|
||||
settings->en_fixedpaper = ((CButton*)m_pageBasic->GetDlgItem(IDC_CKFIXEDPAPER))->GetCheck();
|
||||
//settings->resolution_dst = Resolutions[configItem->Resolution];
|
||||
settings->resolution_dst = configItem->Resolution;
|
||||
settings->resolution_native = 200.0f;
|
||||
|
@ -578,6 +625,8 @@ void CTwainUI::UpDateScanParam(PCONFIGPARAMS configItem, bool updateDs)
|
|||
settings->fillhole.is_fillhole = configItem->EnOutHole;
|
||||
settings->fillhole.fillholeratio = configItem->OutHoleRatio;
|
||||
settings->multi_output_red = configItem->EnMultiOutPutR;
|
||||
settings->en_multi_output = ((CButton*)m_pageImageProc->GetDlgItem(IDC_CHMULTIPUT))->GetCheck();
|
||||
settings->multioutput = ((CComboBox*)m_pageImageProc->GetDlgItem(IDC_CMBMULTIOUT))->GetCurSel();
|
||||
settings->hsvcorrect = configItem->EnHsvCorrect;
|
||||
#ifdef REAL300DPI
|
||||
settings->resolution_native = settings->resolution_dst > 240.0f ? 300.0f : 200.0f;
|
||||
|
@ -684,6 +733,13 @@ void CTwainUI::setvisable_autopaper(bool flag)
|
|||
((CButton*)m_pageFeedPaper->GetDlgItem(IDC_CKAUTOPAPER))->SetCheck(false);
|
||||
}
|
||||
|
||||
void CTwainUI::setvisable_fixedpaper(bool flag)
|
||||
{
|
||||
((CButton*)m_pageBasic->GetDlgItem(IDC_CKFIXEDPAPER))->ShowWindow(flag ? SW_SHOW : SW_HIDE);
|
||||
if (!flag)
|
||||
((CButton*)m_pageBasic->GetDlgItem(IDC_CKFIXEDPAPER))->SetCheck(false);
|
||||
}
|
||||
|
||||
void CTwainUI::EnableID_OKorID_Cancel(bool enable)
|
||||
{
|
||||
GetDlgItem(IDC_CONFIRM)->EnableWindow(enable);
|
||||
|
|
|
@ -61,6 +61,8 @@ static std::map<int, PaperStatus> paperStatusMap = {
|
|||
{6,{TwSS::USLetter,PaperAlign::Rot0}},
|
||||
{7,{TwSS::USLegal,PaperAlign::Rot0}},
|
||||
{8,{TwSS::None,PaperAlign::Rot0}},
|
||||
{9,{TwSS::USStatement,PaperAlign::Rot0}},
|
||||
{10,{TwSS::MaxSize,PaperAlign::Rot0}},
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -177,6 +179,7 @@ public:
|
|||
void setvisable_sleepmode(bool flag);
|
||||
void setvisable_dogear(bool flag);
|
||||
void setvisable_autopaper(bool flag);
|
||||
void setvisable_fixedpaper(bool flag);
|
||||
void EnableID_OKorID_Cancel(bool enable);
|
||||
// 对话框数据
|
||||
#ifdef AFX_DESIGN_TIME
|
||||
|
|
|
@ -27,7 +27,7 @@ G400ScanConfig::G400ScanConfig(GScanCap& gcap)
|
|||
#endif// G300
|
||||
cfg.params.dstHeight = (int)((size.cy+200)/100);
|
||||
cfg.params.sizedetect = gcap.en_sizecheck;
|
||||
cfg.params.reversed1 = cfg.params.reversed2 = 0;
|
||||
cfg.params.reversed1 = cfg.params.reversed2 = cfg.params.lutmode = 0;
|
||||
}
|
||||
|
||||
G400ScanConfig::~G400ScanConfig()
|
||||
|
|
|
@ -18,7 +18,8 @@ public:
|
|||
unsigned int enableUV : 1;
|
||||
unsigned int enableLed : 1;
|
||||
unsigned int sizedetect : 1;
|
||||
unsigned int reversed1 : 5;
|
||||
unsigned int lutmode : 1;
|
||||
unsigned int reversed1 : 4;
|
||||
unsigned int isCorrect : 1;
|
||||
unsigned int dstHeight : 8;
|
||||
unsigned int reversed2 : 6;
|
||||
|
|
|
@ -91,6 +91,8 @@ typedef enum tagUsbSupported {
|
|||
HAVE_DOGEAR = 82,
|
||||
//
|
||||
MLTOP_TIMEOUT = 83,
|
||||
//
|
||||
PAPER_HOLE = 84,
|
||||
//USB 未连接
|
||||
USB_DISCONNECTED = 200,
|
||||
//用户点击停止
|
||||
|
@ -125,6 +127,7 @@ static map<UsbSupported, string> msgs = {
|
|||
{UsbSupported::SLEEPING,"设备处于休眠模式,请按电源键关闭休眠!"},
|
||||
{UsbSupported::HAVE_DOGEAR,"检测到有折角,停止扫描!"},
|
||||
{UsbSupported::MLTOP_TIMEOUT,"升降台抬升未到达指定位置!"},
|
||||
{UsbSupported::PAPER_HOLE,"纸张疑是有孔,请使用带孔模式扫描!"},
|
||||
};
|
||||
|
||||
enum tagEventIndex
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "GScanO1003399.h"
|
||||
#include "ImageProcess/ImageApplyHeaders.h"
|
||||
#include "ImageMultiOutput.h"
|
||||
#include "ImageProcess/ImageMulti.h"
|
||||
#include "scn_config.h"
|
||||
#include "UsbScanEx.h"
|
||||
#include "PaperSize.h"
|
||||
|
@ -82,8 +83,11 @@ void GScanO1003399::open(int vid, int pid)
|
|||
{
|
||||
m_usb = *lsusb.begin();
|
||||
m_usb->open();
|
||||
if (m_usb->is_open())
|
||||
if (m_usb->is_open()) {
|
||||
m_usb->set_usbhotplug_callback(usbhotplug_callback, this);
|
||||
scanner_write_reg(m_usb, SR_IM_CLEAR, 0);
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -125,17 +129,18 @@ int GScanO1003399::aquire_bmpdata(std::vector<unsigned char>& bmpdata)
|
|||
StopWatch sw;
|
||||
while (true)
|
||||
{
|
||||
if ((imagecount == 0) && (!scanflag) || (sw.elapsed_s() > 30))
|
||||
if ((imagecount == 0) && (!scanflag) || (sw.elapsed_s() > 60))
|
||||
{
|
||||
if (is_scan() || (m_param.hardwarecaps.is_autopaper && (sw.elapsed_s() > 30)))
|
||||
if (is_scan() || (m_param.hardwarecaps.is_autopaper && (sw.elapsed_s() > 60)))
|
||||
{
|
||||
sw.reset();
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||||
continue;
|
||||
}
|
||||
|
||||
DoEvents();
|
||||
this_thread::sleep_for(chrono::milliseconds(1));
|
||||
if (sw.elapsed_s() > 30.0)
|
||||
if (sw.elapsed_s() > 60.0)
|
||||
{
|
||||
devState = DEV_STOP;
|
||||
Stop_scan();
|
||||
|
@ -161,6 +166,7 @@ int GScanO1003399::aquire_bmpdata(std::vector<unsigned char>& bmpdata)
|
|||
bmpdata = *(m_imagedata.Take());
|
||||
UpdateScanInfo(get_imgnReaded(), countNTransfered());
|
||||
imagecount--;
|
||||
FileTools::writelog(log_INFO, "imagecount =" + to_string(imagecount));
|
||||
sw.reset();
|
||||
return 0;
|
||||
}
|
||||
|
@ -193,7 +199,7 @@ std::string GScanO1003399::GetMacAdder()
|
|||
{
|
||||
std::string mac;
|
||||
auto fwver = GetFWVersion();
|
||||
if (fwver[5] > 'A' && atoi(fwver.substr(6, 4).c_str()) >= 111) {
|
||||
if ((fwver[5] == 'B' && atoi(fwver.substr(6, 4).c_str()) >= 111)||(fwver[5] > 'B')) {
|
||||
if (m_usb.get() && m_usb->is_connected())
|
||||
{
|
||||
scanner_write_reg(m_usb, SR_GET_MACADDR, 0);
|
||||
|
@ -242,7 +248,7 @@ bool GScanO1003399::is_scan()
|
|||
|
||||
BOOL GScanO1003399::Get_Scanner_PaperOn()
|
||||
{
|
||||
return scanner_read_reg(m_usb, SR_GET_PAPERON);
|
||||
return (scanner_read_reg(m_usb, SR_GET_PAPERON));
|
||||
//return true;
|
||||
}
|
||||
|
||||
|
@ -253,13 +259,23 @@ int GScanO1003399::Get_Roller_num()
|
|||
|
||||
void GScanO1003399::config_params(GScanCap& param)
|
||||
{
|
||||
fwversion = GetFWVersion();
|
||||
m_param = param;
|
||||
HGScanConfig cfg;
|
||||
cfg = { 0 };
|
||||
#ifdef G200
|
||||
|
||||
PaperStatus ps = { param.papertype,param.paperAlign };
|
||||
cfg.g200params.paper = SupPaperTyps.count(ps)>0 ? SupPaperTyps[ps] : 0;
|
||||
//if (fwversion.substr(2, 8) == "393B0430")
|
||||
//{
|
||||
if (param.papertype == 0)
|
||||
cfg.g200params.paper = 12; //220513 重影问题默认固定幅面采集
|
||||
else
|
||||
cfg.g200params.paper = SupPaperTyps_39.count(ps) > 0 ? SupPaperTyps_39[ps] : 0;
|
||||
//}
|
||||
//else {
|
||||
|
||||
// cfg.g200params.paper = SupPaperTyps_39.count(ps) > 0 ? SupPaperTyps_39[ps] : 0;
|
||||
//}
|
||||
if (param.filter != 3 || param.enhance_color != 0 || param.hsvcorrect)
|
||||
cfg.g200params.color = 1;//color
|
||||
else
|
||||
|
@ -275,30 +291,11 @@ void GScanO1003399::config_params(GScanCap& param)
|
|||
cfg.g200params.screw_detect_level = (unsigned int)cfg.g200params.screw_detect_enable ? secrewMaps[param.hardwarecaps.skrewdetectlevel] : 0;
|
||||
cfg.g200params.is_autopaper = param.hardwarecaps.is_autopaper;
|
||||
cfg.g200params.enable_sizecheck = param.en_sizecheck == 1 ? 1 : 0;
|
||||
cfg.g200params.is_textcorrect = cfg.g200params.unused_one = cfg.g200params.sizeerror_errorratio = 0;
|
||||
cfg.g200params.is_textcorrect = cfg.g200params.en_autosize = cfg.g200params.sizeerror_errorratio = 0;
|
||||
//cfg.g200params.is_fixedpaper = param.en_fixedpaper;
|
||||
cfg.g200params.is_fixedpaper = true; //220513 重影问题默认固定幅面采集
|
||||
cfg.g200params.en_anlogic_key = true;
|
||||
|
||||
#else
|
||||
|
||||
cfg.g400params.doubleFeeded = param.hardwarecaps.en_doublefeed == 0 ? 0 : 1;
|
||||
cfg.g400params.dpi = G400_DPI::G400_D200;//gcap.resolution_dst <= 200.0f ? G400_DPI::G400_D200 : (gcap.resolution_dst <= 300.0f ? G400_DPI::G400_D300 : G400_DPI::G400_D600);
|
||||
cfg.g400params.enableLed = 1;
|
||||
if (param.filter != 3 || param.enhance_color)
|
||||
cfg.g400params.isColor = 1;
|
||||
else
|
||||
cfg.g400params.isColor = SupPixelTypes[param.pixtype];
|
||||
cfg.g400params.enableStable = 0;//gcap.hardwarecaps.en_stapledetect==0?0:1;
|
||||
cfg.g400params.isCorrect = 1;//1 机器校正
|
||||
PaperStatus ps = { param.papertype,param.paperAlign };
|
||||
cfg.g400params.pageSize = SupPaperTyps[ps];
|
||||
CSize size;
|
||||
#ifdef G300
|
||||
size = Device::PaperSize().GetPaperSize(TwSS::A4, 200.0f, param.paperAlign);//G300 最大支持A4幅面
|
||||
#else
|
||||
size = Device::PaperSize().GetPaperSize(param.papertype, 200.0f, param.paperAlign);
|
||||
#endif// G300
|
||||
cfg.g400params.dstHeight = (int)((size.cy + 200) / 100);
|
||||
cfg.g400params.reversed1 = cfg.g400params.reversed2 = 0;
|
||||
#endif // G200
|
||||
config_scanparam(cfg);
|
||||
config_imgprocparam({sizeof(GScanCap_3399)});
|
||||
GScanCap_3399 param39{ 0 };
|
||||
|
@ -336,9 +333,9 @@ void GScanO1003399::config_params(GScanCap& param)
|
|||
param39.paperAlign = param.paperAlign;
|
||||
param39.papertype = param.papertype;
|
||||
param39.pixtype = param.pixtype;
|
||||
param39.resolution_dst = param.resolution_dst;
|
||||
param39.resolution_dst = param.is_high_imagequality ? param.resolution_dst : ( param.resolution_dst >= 500.0f ?300.0f: 200.0f);
|
||||
//param39.resolution_dst = param.resolution_dst > 300 ? 300 : param.resolution_dst;
|
||||
param39.resolution_native = param.resolution_native;
|
||||
param39.resolution_native = param.is_high_imagequality? param.resolution_native : (param.resolution_dst >= 500.0f ? 300.0f : 200.0f);
|
||||
param39.scannum = param.scannum;
|
||||
param39.sharpen = param.sharpen;
|
||||
param39.threshold = param.threshold;
|
||||
|
@ -346,18 +343,25 @@ void GScanO1003399::config_params(GScanCap& param)
|
|||
param39.normalCrop = param.normalCrop;
|
||||
param39.fadeback = param.fadeback;
|
||||
param39.fadebackrange = param.fadeback_range;
|
||||
param39.dogeardistabce = param.dogeardistance;
|
||||
m_usb->write_bulk(¶m39, sizeof(param39));
|
||||
m_param .resolution_native = param.resolution_dst >= 500.0f ? 300.0f : 200.0f;
|
||||
|
||||
}
|
||||
|
||||
void GScanO1003399::Scanner_StartScan(UINT16 count)
|
||||
{
|
||||
auto fwver = GetFWVersion();
|
||||
if (fwver[5] > 'A' || atoi(fwver.substr(6, 4).c_str()) >= 1209)
|
||||
auto fwver = fwversion;
|
||||
if ((fwver[5] == 'A' && atoi(fwver.substr(6, 4).c_str()) >= 1209)||(fwver[5] > 'A'))
|
||||
{
|
||||
#ifdef G200
|
||||
if (GetMotorFPGA() >= 35211210)
|
||||
is_kernelsnap_211209 = true;
|
||||
else
|
||||
is_kernelsnap_211209 = false;
|
||||
#else
|
||||
is_kernelsnap_211209 = true;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
is_kernelsnap_211209 = false;
|
||||
|
@ -372,6 +376,7 @@ void GScanO1003399::Scanner_StartScan(UINT16 count)
|
|||
Set_ErrorCode(0);
|
||||
getimgnum = aquirenum = imagecount = 0;
|
||||
keeplastimg = is_kernelsnap_211209 ? false : true;//true
|
||||
scanner_write_reg(m_usb, SR_IM_CLEAR, 0);
|
||||
reset();
|
||||
devState = DEV_ISRUNNING;
|
||||
if (scanner_read_reg(m_usb, SR_GET_SLEEP_STAUTUS) != 1)
|
||||
|
@ -381,7 +386,7 @@ void GScanO1003399::Scanner_StartScan(UINT16 count)
|
|||
scanflag = false;
|
||||
return;
|
||||
}
|
||||
//if (!Get_Scanner_PaperOn())
|
||||
//if (!Get_Scanner_PaperOn()) //配合连续扫描使用会出现异常
|
||||
//{
|
||||
// devState = DEV_WRONG;
|
||||
// Set_ErrorCode(NO_FEED);
|
||||
|
@ -429,7 +434,7 @@ int GScanO1003399::notifyscan()
|
|||
|
||||
void GScanO1003399::ResetScanner()
|
||||
{
|
||||
|
||||
//m_imagedata.Clear();
|
||||
}
|
||||
|
||||
bool GScanO1003399::Get_IsImageQueueEmpty()
|
||||
|
@ -440,6 +445,8 @@ bool GScanO1003399::Get_IsImageQueueEmpty()
|
|||
void GScanO1003399::reset()
|
||||
{
|
||||
devState = DEV_STOP;
|
||||
m_paths.Clear();
|
||||
imgs.Clear();
|
||||
m_imagedata.Clear();
|
||||
}
|
||||
|
||||
|
@ -522,7 +529,7 @@ void GScanO1003399::usb_run()
|
|||
{
|
||||
while (!scanner_read_reg(m_usb, SR_GET_IMAGEPROCESSDONE))
|
||||
this_thread::sleep_for(chrono::microseconds(30));
|
||||
if (scanner_read_reg(m_usb, SR_GET_KEEP_LAST_PAPER))
|
||||
if (scanner_read_reg(m_usb, SR_GET_KEEP_LAST_PAPER) && (!is_kernelsnap_211209))
|
||||
{
|
||||
FileTools::writelog(log_ERROR, "keep last paper true");
|
||||
this_thread::sleep_for(chrono::milliseconds(100));
|
||||
|
@ -619,6 +626,7 @@ bool GScanO1003399::is_dev_tx()
|
|||
return scanner_read_reg(m_usb, SR_IM_TXING);
|
||||
}
|
||||
|
||||
|
||||
void GScanO1003399::im_rx()
|
||||
{
|
||||
if (is_dev_tx())
|
||||
|
@ -642,7 +650,8 @@ void GScanO1003399::im_rx()
|
|||
pop_dev_im();
|
||||
//vector<cv::Mat> mats;
|
||||
//m_param.multi_output_red? imagecount += 2: imagecount++;
|
||||
imagecount += 1 * (m_param.multi_output_red ? 2 : 1) * (m_param.is_split ? 2 : 1);
|
||||
imagecount += 1 * (m_param.multi_output_red ? 2 : 1) * (m_param.is_split ? 2 : 1) * (m_param.en_multi_output ? (m_param.multioutput < 0 ? 1 : (m_param.multioutput == 0 ? 3 : 2)) : 1);
|
||||
FileTools::writelog(log_INFO, "imagecount im rx =" + to_string(imagecount));
|
||||
UpdateScanInfo(countNReaded(), get_imgTransfered());
|
||||
if (m_param.resolution_dst > 200.0f || m_param.papertype == 52 || m_param.papertype == 54 || m_param.papertype == 131)
|
||||
{
|
||||
|
@ -743,6 +752,13 @@ void GScanO1003399::imgproce(std::shared_ptr<std::vector<char>>& buff)
|
|||
}
|
||||
sw.reset();
|
||||
buffs.clear();
|
||||
if (m_param.is_high_imagequality == false && m_param.resolution_dst != m_param.resolution_native) {
|
||||
for (auto& node : mats)
|
||||
{
|
||||
cv::resize(node, node, cv::Size(0, 0), m_param.resolution_dst / m_param.resolution_native, m_param.resolution_dst / m_param.resolution_native);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_param.is_autotext)
|
||||
{
|
||||
//m_autotext->apply(mats, m_param.is_duplex);
|
||||
|
@ -757,6 +773,8 @@ void GScanO1003399::imgproce(std::shared_ptr<std::vector<char>>& buff)
|
|||
_tcscat(szIniFile, _T("\\twain_32\\HanvonScan\\tessdata\\osd.traineddata"));
|
||||
#elif defined MAKERIGHTWAY
|
||||
_tcscat(szIniFile, _T("\\twain_32\\RIGHTWAYSCAN\\tessdata\\osd.traineddata"));
|
||||
#elif defined NOLOGO
|
||||
_tcscat(szIniFile, _T("\\twain_32\\Scan\\tessdata\\osd.traineddata"));
|
||||
#else
|
||||
_tcscat(szIniFile, _T("\\twain_32\\HuaGoScan\\tessdata\\osd.traineddata"));
|
||||
#endif //
|
||||
|
@ -811,9 +829,16 @@ void GScanO1003399::imgproce(std::shared_ptr<std::vector<char>>& buff)
|
|||
if (m_param.pixtype == 1 && m_param.hsvcorrect)
|
||||
if (mats[i].channels() == 3)
|
||||
cvtColor(mats[i], mats[i], cv::COLOR_BGR2GRAY);
|
||||
idata = (isbwimg|| m_param.pixtype == 0 || (((m_param.automaticcolortype == 0) && (m_param.automaticcolor == true)) && (mats[i].channels() == 1))) ? (IMat2Bmp)Mat2BmpBw(mats[i], m_param.resolution_dst) : (IMat2Bmp)Mat2Bmp(mats[i], m_param.resolution_dst);
|
||||
m_imagedata.Put(idata.getBmpDataBuffer());
|
||||
idata.~IMat2Bmp();
|
||||
//cv::imwrite("D:\\img\\" + to_string(num++) + ".jpg", mats[i]);
|
||||
if (m_param.en_multi_output) {
|
||||
MultiOut(mats[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
idata = (isbwimg || m_param.pixtype == 0 || (((m_param.automaticcolortype == 0) && (m_param.automaticcolor == true)) && (mats[i].channels() == 1))) ? (IMat2Bmp)Mat2BmpBw(mats[i], m_param.resolution_dst) : (IMat2Bmp)Mat2Bmp(mats[i], m_param.resolution_dst);
|
||||
m_imagedata.Put(idata.getBmpDataBuffer());
|
||||
idata.~IMat2Bmp();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -839,6 +864,51 @@ void GScanO1003399::imgproce(std::shared_ptr<std::vector<char>>& buff)
|
|||
mats.clear();
|
||||
}
|
||||
|
||||
void GScanO1003399::MultiOut(cv::Mat& pDid)
|
||||
{
|
||||
IMageMulti imgmulti(m_param.multioutput);
|
||||
auto rets = imgmulti.apply(pDid);
|
||||
switch (m_param.multioutput)
|
||||
{
|
||||
case 0: {
|
||||
for (int x = 0; x < rets.size(); x++) {
|
||||
if (rets[x].empty())
|
||||
continue;
|
||||
if (x == 2)
|
||||
m_imagedata.Put(Mat2BmpBw(rets[x], m_param.resolution_dst).getBmpDataBuffer());
|
||||
else
|
||||
m_imagedata.Put(Mat2Bmp(rets[x], m_param.resolution_dst).getBmpDataBuffer());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
for (auto& node : rets) {
|
||||
if (node.empty())
|
||||
continue;
|
||||
m_imagedata.Put(Mat2Bmp(node, m_param.resolution_dst).getBmpDataBuffer());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
case 3: {
|
||||
for (int x = 0; x < rets.size(); x++) {
|
||||
if (rets[x].empty())
|
||||
continue;
|
||||
if (x == 1)
|
||||
m_imagedata.Put(Mat2BmpBw(rets[x], m_param.resolution_dst).getBmpDataBuffer());
|
||||
else
|
||||
{
|
||||
m_param.multioutput == 2 ? void(0):cv::cvtColor(rets[x], rets[x], cv::COLOR_BGR2GRAY);
|
||||
m_imagedata.Put(Mat2Bmp(rets[x], m_param.resolution_dst).getBmpDataBuffer());
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int GScanO1003399::codeconvter(HGEIntInfo code)
|
||||
{
|
||||
if (code.From == HGType::FPGA)
|
||||
|
@ -871,6 +941,8 @@ int GScanO1003399::codeconvter(HGEIntInfo code)
|
|||
return AQUIRE_IMAGE_TIMEOUT;
|
||||
case 0x20000:
|
||||
return SIZE_ERROR;
|
||||
case 0x40000:
|
||||
return PAPER_HOLE;
|
||||
case 0x80000:
|
||||
return MLTOP_TIMEOUT;
|
||||
default:
|
||||
|
@ -904,7 +976,25 @@ int GScanO1003399::codeconvter(HGEIntInfo code)
|
|||
}
|
||||
}
|
||||
if (code.From == HGType::STOPSCAN)
|
||||
return -1;
|
||||
{
|
||||
switch (code.Code)
|
||||
{
|
||||
case 0:
|
||||
return -1;
|
||||
case 1:
|
||||
if (m_param.hardwarecaps.is_autopaper)
|
||||
{
|
||||
autopaperstop = true;
|
||||
if (!is_scan() && imagecount == 0)
|
||||
scanflag = false;
|
||||
}
|
||||
if (devState == DEV_ISRUNNING)
|
||||
devState = DEV_STOP;
|
||||
return 0;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -955,7 +1045,8 @@ void GScanO1003399::proc(bool bcachemode)
|
|||
}
|
||||
buffer = imgs.Take();
|
||||
}
|
||||
|
||||
//if (m_param.resolution_dst > 500)
|
||||
// std::this_thread::sleep_for(std::chrono::milliseconds(4399));
|
||||
imgproce(buffer);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,30 @@
|
|||
|
||||
|
||||
|
||||
static std::map<PaperStatus, unsigned int> SupPaperTyps_39 = {
|
||||
{{TwSS::A3,PaperAlign::Rot0},0},
|
||||
{{TwSS::A4,PaperAlign::Rot0},1},
|
||||
{{TwSS::A4,PaperAlign::Rot270},2},
|
||||
{{TwSS::A5,PaperAlign::Rot0 },3},
|
||||
{{TwSS::A5,PaperAlign::Rot270},4},
|
||||
{{TwSS::A6,PaperAlign::Rot0},5},
|
||||
{{TwSS::A6,PaperAlign::Rot270},6},
|
||||
{{TwSS::B4,PaperAlign::Rot0},7},
|
||||
{{TwSS::B5,PaperAlign::Rot0},8},
|
||||
{{TwSS::B5,PaperAlign::Rot270},9},
|
||||
{{TwSS::B6,PaperAlign::Rot0},10},
|
||||
{{TwSS::B6,PaperAlign::Rot270},11},
|
||||
{{TwSS::USLetter,PaperAlign::Rot0},14},
|
||||
{{TwSS::USLedger,PaperAlign::Rot0},12},
|
||||
{{TwSS::USLegal,PaperAlign::Rot0},13},
|
||||
{{TwSS::None,PaperAlign::Rot0},0},
|
||||
{{TwSS::USLetter,PaperAlign::Rot270},15},
|
||||
{{TwSS::USStatement,PaperAlign::Rot0},16},
|
||||
{{TwSS::MaxSize,PaperAlign::Rot0},16},
|
||||
{{TwSS::Trigeminy,PaperAlign::Rot0},16}
|
||||
};
|
||||
|
||||
|
||||
class GScanO1003399 :public IScanner
|
||||
{
|
||||
public:
|
||||
|
@ -67,6 +91,7 @@ private:
|
|||
int front_datasize();
|
||||
int im_dev_count();
|
||||
void imgproce(std::shared_ptr<std::vector<char>>& buffs);
|
||||
void MultiOut(cv::Mat& pDid);
|
||||
int codeconvter(HGEIntInfo code);
|
||||
static void usbhotplug_callback(bool isconnect, void* userdata);
|
||||
void usbhotplug(bool isleft);
|
||||
|
@ -90,6 +115,7 @@ private:
|
|||
std::shared_ptr<std::thread> m_usbthread;
|
||||
std::shared_ptr<std::vector<char>> im_data;
|
||||
BlockingQueue<std::shared_ptr<std::vector<unsigned char>>> m_imagedata;
|
||||
std::string fwversion;
|
||||
std::atomic_int imagecount;
|
||||
int preProcImgindex;//Ô¤´¦ÀíͼÏñ±àºÅ
|
||||
void* huagods;
|
||||
|
|
|
@ -203,6 +203,7 @@ void GScanO200::regist_deviceevent_callback(deviceevent_callback callback, void*
|
|||
|
||||
int GScanO200::aquire_bmpdata(std::vector<unsigned char>& bmpdata)
|
||||
{
|
||||
FileTools::writelog(log_lv::log_DEBUG," aquire_bmpdata start");
|
||||
StopWatch sw;
|
||||
while (true)
|
||||
{
|
||||
|
@ -221,12 +222,14 @@ int GScanO200::aquire_bmpdata(std::vector<unsigned char>& bmpdata)
|
|||
ResetScanner();
|
||||
auto rollernew = Get_Roller_num();
|
||||
set_scannum(abs(rollernew - roller_num));
|
||||
FileTools::writelog(log_lv::log_DEBUG, " aquire_bmpdata timeout");
|
||||
return HARDWARE_ERROR;
|
||||
}
|
||||
|
||||
if (!is_scan()) {
|
||||
auto rollernew = Get_Roller_num();
|
||||
set_scannum(abs(rollernew - roller_num));
|
||||
FileTools::writelog(log_lv::log_DEBUG, " aquire_bmpdata stop");
|
||||
if (devState == DEV_WRONG) {
|
||||
return get_ErrorCode();
|
||||
}
|
||||
|
@ -237,6 +240,7 @@ int GScanO200::aquire_bmpdata(std::vector<unsigned char>& bmpdata)
|
|||
if (m_pImages->valid()) {
|
||||
bmpdata = *(m_pImages->popBmpdata());
|
||||
UpdateScanInfo(get_imgnReaded(), countNTransfered());
|
||||
FileTools::writelog(log_lv::log_DEBUG, " aquire_bmpdata quit");
|
||||
return 0;
|
||||
}
|
||||
DoEvents();
|
||||
|
@ -372,6 +376,7 @@ void GScanO200::config_params(GScanCap& params)
|
|||
FileTools::writelog(log_INFO, "config hardware param"+to_string(cfgdata));
|
||||
m_usb->write_bulk(&usbcb, sizeof(USBCB));
|
||||
this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||
params.resolution_native = 200.0f;
|
||||
m_pImages->setparam(params);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -362,11 +362,52 @@ int GScanO400::Get_Roller_num()
|
|||
|
||||
void GScanO400::config_params(GScanCap& params)
|
||||
{
|
||||
|
||||
if (m_usb.get() && m_usb->is_connected()) {
|
||||
G400ScanConfig cfg = G400ScanConfig(params);
|
||||
gcap = params;
|
||||
UINT32 cfgdata = cfg.GetData();
|
||||
auto fw = GetFWVersion();
|
||||
if (atoi(fw.substr(4, 6).c_str()) >= 220117)
|
||||
{
|
||||
if (params.papertype == 52 || params.papertype == 54 || params.papertype == 131 || params.papertype == 0)
|
||||
cfgdata = (cfgdata & 0xffffffe0) + 18;
|
||||
}
|
||||
if (atoi(fw.substr(4, 6).c_str()) >= 220117)
|
||||
{
|
||||
int dpi = 1;
|
||||
if (params.is_high_imagequality)
|
||||
{
|
||||
if (params.resolution_dst < 300) {
|
||||
params.resolution_native = 200.0f;
|
||||
dpi = 1;
|
||||
}
|
||||
else if (params.resolution_dst >= 300 && params.resolution_dst < 500) {
|
||||
params.resolution_native = 300.0f;
|
||||
dpi = 2;
|
||||
}
|
||||
else {
|
||||
params.resolution_native = 600.0f;
|
||||
dpi = 3;
|
||||
}
|
||||
cfgdata = (cfgdata & 0xffffff3f) + (dpi << 6);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (params.resolution_dst <500)
|
||||
{
|
||||
params.resolution_native = 200.0f;
|
||||
dpi = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
params.resolution_native = 300.0f;
|
||||
dpi = 2;
|
||||
}
|
||||
cfgdata = (cfgdata & 0xffffff3f) + (dpi << 6);
|
||||
}
|
||||
}
|
||||
else
|
||||
params.resolution_native = 200.0f;
|
||||
gcap = params;
|
||||
USBCB usbcb = { CONFIGURED_DATA,cfgdata,0 };
|
||||
FileTools::writelog(log_INFO, "config hardware param" + to_string(cfgdata));
|
||||
m_usb->write_bulk(&usbcb, sizeof(USBCB));
|
||||
|
|
|
@ -383,6 +383,7 @@ void GScanO400Android::config_params(GScanCap& params)
|
|||
FileTools::writelog(log_INFO, "config hardware param" + to_string(cfgdata));
|
||||
m_usb->write_bulk(&usbcb, sizeof(USBCB));
|
||||
this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||
params.resolution_native = 200.0f;
|
||||
m_pImages->setparam(params);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -184,6 +184,12 @@ enum Scanner_Reg_Defs
|
|||
SR_GET_PAPERON,
|
||||
SR_SET_SPEEDMODE,
|
||||
SR_GET_SPEEDMODE,
|
||||
SR_GET_JOSN_SIZE,
|
||||
SR_GET_JSON,
|
||||
SR_SET_JSON_PATH,
|
||||
SR_SET_JSON,
|
||||
SR_GET_FILE_POS,
|
||||
SR_SET_FILE_POS,
|
||||
SR_GET_CUO_ERROR = 0x50,
|
||||
SR_GET_DOU_ERROR,
|
||||
SR_GET_JAM_ERROR,
|
||||
|
@ -209,7 +215,7 @@ enum Scanner_Reg_Defs
|
|||
SR_UPDATA_RECOVERY = 0x103,
|
||||
SR_UPDATA_REBOOT = 0x104,
|
||||
SR_POWEROFF = 0x105,
|
||||
SR_REBOOT = 0x106,
|
||||
SR_REBOOT = 0x106, //Heartbeat
|
||||
SR_FLAT_CLR_MAX_BRIGHT,
|
||||
SR_FLAT_GRAY_MAX_BRIGHT,
|
||||
SR_KERNEL_VERSION_INFO_LENGTH,
|
||||
|
@ -306,7 +312,9 @@ typedef union HG_ScanConfig
|
|||
unsigned int iscorrect_mod : 1;
|
||||
unsigned int is_autopaper : 1;
|
||||
unsigned int is_textcorrect : 1;
|
||||
unsigned int unused_one : 3;
|
||||
unsigned int is_fixedpaper : 1;
|
||||
unsigned int en_anlogic_key : 1;
|
||||
unsigned int en_autosize : 1;
|
||||
unsigned int pc_correct : 1;
|
||||
unsigned int enable_sizecheck : 1;
|
||||
unsigned int enabledsp_cache : 1;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "filetools.h"
|
||||
#include <math.h>
|
||||
#include "StopWatch.h"
|
||||
#include "ImageProcess/ImageMulti.h"
|
||||
|
||||
|
||||
using namespace cv;
|
||||
|
@ -217,13 +218,13 @@ void ImageMatQueue::setparam(const GScanCap& param)
|
|||
}
|
||||
|
||||
{
|
||||
bool islongcustomcrop = param.papertype == TwSS::USStatement;
|
||||
bool islongcustomcrop = (param.papertype == TwSS::USStatement || param.papertype == TwSS::MaxSize);
|
||||
//bool isautocrop = param.papertype == TwSS::None;
|
||||
CSize fixedSize;
|
||||
#ifdef REAL300DPI
|
||||
fixedSize = papersize.GetPaperSize(param.papertype, param.resolution_dst > 240.0f ? 300.0f : 200.0f, param.paperAlign);
|
||||
#else // REAL300DPI
|
||||
fixedSize = papersize.GetPaperSize(param.papertype, 200.0f, param.paperAlign);
|
||||
fixedSize = papersize.GetPaperSize(param.papertype, param.resolution_native, param.paperAlign);
|
||||
#endif
|
||||
bool normalCrop = ((param.autodescrew) || (islongcustomcrop ? islongcustomcrop : param.is_autocrop) || (param.fillbackground)) ? false : param.normalCrop;
|
||||
m_iaList.push_back(shared_ptr<CImageApply>(new CImageApplyAutoCrop(islongcustomcrop ? islongcustomcrop : param.is_autocrop,
|
||||
|
@ -234,6 +235,11 @@ void ImageMatQueue::setparam(const GScanCap& param)
|
|||
m_iaList.push_back(shared_ptr<CImageApply>(new CImageApplyResize(CImageApplyResize::ResizeType::DSIZE, cv::Size(fixedSize.cx, fixedSize.cy), 1.0, 1.0)));*/
|
||||
}
|
||||
|
||||
//if (param.pixtype == 2 || param.filter != 3 || param.enhance_color)
|
||||
//{
|
||||
// m_iaList.push_back(shared_ptr<CImageApplyHSVCorrect>(new CImageApplyHSVCorrect(CImageApplyHSVCorrect::CorrectOption::LowSaturation_Removal, true)));
|
||||
//}
|
||||
|
||||
if (param.fadeback && param.pixtype == 2) {
|
||||
m_iaList.push_back(shared_ptr<CImageApply>(new CImageApplyFadeBackGroudColor(100,0,param.fadeback_range)));
|
||||
}
|
||||
|
@ -255,6 +261,7 @@ void ImageMatQueue::setparam(const GScanCap& param)
|
|||
contrast = (int)(param.contrast * 0.018);
|
||||
m_iaList.push_back(shared_ptr<CImageApply>(new CImageApplyAdjustColors(bright, contrast, param.gamma)));
|
||||
}
|
||||
|
||||
//答题卡除红
|
||||
if (scanParam.hsvcorrect)
|
||||
{
|
||||
|
@ -326,6 +333,8 @@ void ImageMatQueue::setparam(const GScanCap& param)
|
|||
_tcscat(szIniFile, _T("\\twain_32\\HanvonScan\\tessdata\\osd.traineddata"));
|
||||
#elif defined MAKERIGHTWAY
|
||||
_tcscat(szIniFile, _T("\\twain_32\\RIGHTWAYSCAN\\tessdata\\osd.traineddata"));
|
||||
#elif defined NOLOGO
|
||||
_tcscat(szIniFile, _T("\\twain_32\\Scan\\tessdata\\osd.traineddata"));
|
||||
#else
|
||||
_tcscat(szIniFile, _T("\\twain_32\\HuaGoScan\\tessdata\\osd.traineddata"));
|
||||
#endif //
|
||||
|
@ -341,7 +350,6 @@ void ImageMatQueue::setparam(const GScanCap& param)
|
|||
void ImageMatQueue::EnqueueBmpBuffer(std::shared_ptr<std::vector<unsigned char>> bmpdata)
|
||||
{
|
||||
m_imagedata.Put(bmpdata);
|
||||
int aa = 0;
|
||||
}
|
||||
void ImageMatQueue::PaniusCount(int count)
|
||||
{
|
||||
|
@ -374,7 +382,6 @@ void ImageMatQueue::init_cachethread()
|
|||
static int index = 0;
|
||||
void ImageMatQueue::cache_run()
|
||||
{
|
||||
std::ios::sync_with_stdio(false);
|
||||
while (benablecache)
|
||||
{
|
||||
if (m_rawBuffs.Size() == 0)
|
||||
|
@ -429,6 +436,59 @@ void ImageMatQueue::cache_run()
|
|||
}
|
||||
}
|
||||
|
||||
void ImageMatQueue::MultiOut(cv::Mat& pDid)
|
||||
{
|
||||
IMageMulti imgmulti(scanParam.multioutput);
|
||||
auto rets = imgmulti.apply(pDid);
|
||||
switch (scanParam.multioutput)
|
||||
{
|
||||
case 0: {
|
||||
for (int x = 0; x < rets.size(); x++) {
|
||||
if(rets[x].empty())
|
||||
continue;
|
||||
std::shared_ptr<std::vector<uchar>> data;
|
||||
if(x == 2)
|
||||
data = Mat2BmpBw(rets[x], scanParam.resolution_dst).getBmpDataBuffer();
|
||||
else
|
||||
data = Mat2Bmp(rets[x], scanParam.resolution_dst).getBmpDataBuffer();
|
||||
EnqueueBmpBuffer(data);
|
||||
data.reset();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
for (auto& node : rets) {
|
||||
if(node.empty())
|
||||
continue;
|
||||
auto data = Mat2Bmp(node, scanParam.resolution_dst).getBmpDataBuffer();
|
||||
EnqueueBmpBuffer(data);
|
||||
data.reset();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
case 3:{
|
||||
for (int x = 0; x < rets.size(); x++) {
|
||||
if (rets[x].empty())
|
||||
continue;
|
||||
std::shared_ptr<std::vector<uchar>> data;
|
||||
if (x == 1)
|
||||
data = Mat2BmpBw(rets[x], scanParam.resolution_dst).getBmpDataBuffer();
|
||||
else
|
||||
{
|
||||
scanParam.multioutput == 2 ? void(0) : cv::cvtColor(rets[x], rets[x], cv::COLOR_BGR2GRAY);
|
||||
data = Mat2Bmp(rets[x], scanParam.resolution_dst).getBmpDataBuffer();
|
||||
}
|
||||
EnqueueBmpBuffer(data);
|
||||
data.reset();
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ImageMatQueue::clear_cachefiles()
|
||||
{
|
||||
while (m_imgCacheinfo.Size() > 0)
|
||||
|
@ -463,6 +523,7 @@ void ImageMatQueue::proc()
|
|||
}
|
||||
string msg;
|
||||
auto info = m_imgCacheinfo.Take();
|
||||
FileTools::writelog(log_DEBUG, "get tmp file "+info.path);
|
||||
if (info.path.length() == 0 || !isFileExist(info.path))
|
||||
{
|
||||
msg = "error while checking file :" + info.path + " ,file lost";
|
||||
|
@ -488,13 +549,13 @@ void ImageMatQueue::proc()
|
|||
FileTools::writelog(log_ERROR, msg);
|
||||
}
|
||||
sw.reset();
|
||||
auto imgfront = imread(info.path, rmc);
|
||||
cv::Mat imgfront = imread(info.path, rmc);
|
||||
msg = "reading image front time elapsed_ms:" + std::to_string(sw.elapsed_ms());
|
||||
FileTools::writelog(log_ERROR, msg);
|
||||
FileTools::writelog(log_DEBUG, msg);
|
||||
sw.reset();
|
||||
auto imgback = imread(back.path, rmc);
|
||||
cv::Mat imgback = imread(back.path, rmc);
|
||||
msg = "reading image back time elapsed_ms:" + std::to_string(sw.elapsed_ms());
|
||||
FileTools::writelog(log_ERROR, msg);
|
||||
FileTools::writelog(log_DEBUG, msg);
|
||||
sw.reset();
|
||||
if (!imgfront.empty() && !imgback.empty())
|
||||
{
|
||||
|
@ -580,7 +641,7 @@ void ImageMatQueue::proc()
|
|||
}
|
||||
#endif
|
||||
}//g400 serials
|
||||
|
||||
FileTools::writelog(log_DEBUG, " start image process ");
|
||||
std::vector<cv::RotatedRect> rects;
|
||||
std::vector<int> angleResults;
|
||||
bool isDesaskew = false;
|
||||
|
@ -618,6 +679,7 @@ void ImageMatQueue::proc()
|
|||
uvmats.clear();
|
||||
}
|
||||
#endif
|
||||
FileTools::writelog(log_DEBUG, " image process finish");
|
||||
if (!scanParam.is_duplex && mats.size()>1) {
|
||||
mats.pop_back();
|
||||
}
|
||||
|
@ -636,14 +698,20 @@ void ImageMatQueue::proc()
|
|||
if (mats[i].channels() == 3)
|
||||
cvtColor(mats[i], mats[i], cv::COLOR_BGR2GRAY);
|
||||
#endif
|
||||
idata = (scanParam.pixtype == 0 || (((scanParam.automaticcolortype == 0) && (scanParam.automaticcolor == true)) && (mats[i].channels() == 1))) ?
|
||||
(IMat2Bmp)Mat2BmpBw(mats[i], scanParam.resolution_dst) : Mat2Bmp(mats[i], scanParam.resolution_dst);
|
||||
if (!scanParam.multi_output_red)
|
||||
mats[i].release();
|
||||
|
||||
auto data = idata.getBmpDataBuffer();
|
||||
EnqueueBmpBuffer(data);
|
||||
data.reset();
|
||||
if (scanParam.en_multi_output) {
|
||||
MultiOut(mats[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
idata = (scanParam.pixtype == 0 || (((scanParam.automaticcolortype == 0) && (scanParam.automaticcolor == true)) && (mats[i].channels() == 1))) ?
|
||||
(IMat2Bmp)Mat2BmpBw(mats[i], scanParam.resolution_dst) : Mat2Bmp(mats[i], scanParam.resolution_dst);
|
||||
if (!scanParam.multi_output_red)
|
||||
mats[i].release();
|
||||
//cv::imwrite("D:\\img\\" + to_string(indeximg++) + ".jpg", mats[i]);
|
||||
auto data = idata.getBmpDataBuffer();
|
||||
EnqueueBmpBuffer(data);
|
||||
data.reset();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -228,6 +228,7 @@ private:
|
|||
void init_cachethread();
|
||||
void splitimg(std::vector<cv::Mat>& mats);
|
||||
void cache_run();
|
||||
void MultiOut(cv::Mat & pDid);
|
||||
//清除缓存文件
|
||||
void clear_cachefiles();
|
||||
|
||||
|
|
|
@ -26,10 +26,16 @@ namespace Device {
|
|||
papersize.insert({ B6,CSize(125,176) });
|
||||
#ifdef G400
|
||||
papersize.insert({ MaxSize,CSize(297,420 * 1.5) });
|
||||
#elif defined G300
|
||||
papersize.insert({ MaxSize,CSize(210,335 * 2) });
|
||||
#else
|
||||
papersize.insert({ MaxSize,CSize(297,420 * 2) });
|
||||
#endif
|
||||
#ifdef G300
|
||||
papersize.insert({ USStatement,CSize(210,297 * 1.5) });
|
||||
#else
|
||||
papersize.insert({ USStatement,CSize(297,420 * 1.5) });
|
||||
#endif // G300
|
||||
papersize.insert({ USLetter,CSize(216,279) });
|
||||
papersize.insert({ USLegal,CSize(216,356) });
|
||||
papersize.insert({ USLedger,CSize(279,432) });
|
||||
|
@ -41,7 +47,6 @@ namespace Device {
|
|||
|
||||
CSize PaperSize::GetPaperSize(DWORD paperType, float dpi,int orentation)
|
||||
{
|
||||
|
||||
if (papersize.find((TwSS)paperType) != papersize.end() && (dpi > 99 && dpi < 601)) {
|
||||
CSize resize(2338,3307);
|
||||
if (orentation == 0){
|
||||
|
|
|
@ -469,6 +469,8 @@ CString GetHidedlgPath()
|
|||
_tcscat(szIniFile, _T("\\twain_32\\LANXUMSCAN\\hidedlg.exe"));
|
||||
#elif defined MAKERIGHTWAY
|
||||
_tcscat(szIniFile, _T("\\twain_32\\RIGHTWAYSCAN\\hidedlg.exe"));
|
||||
#elif defined NOLOGO
|
||||
_tcscat(szIniFile, _T("\\twain_32\\Scan\\hidedlg.exe"));
|
||||
#else // MAKEHUAGAO
|
||||
_tcscat(szIniFile, _T("\\twain_32\\ZhibenScan\\hidedlg.exe"));
|
||||
#endif
|
||||
|
|
|
@ -33,6 +33,7 @@ const std::string ENUVMODEL = "bUVmodel";
|
|||
#endif
|
||||
const std::string PAPARSIZE = "iPaparSize";
|
||||
const std::string ENSIZECHECK = "iEnSizeCheck";
|
||||
const std::string ENFIXEDPAPER = "bEnFixedPaper";
|
||||
const std::string PAPERALIGN = "iPaperAlign";
|
||||
const std::string RESOLUTION = "iResolution";
|
||||
const std::string DUPLEX = "iDuplex";
|
||||
|
@ -43,6 +44,7 @@ const std::string DB_AREANUM = "iAreaNum";
|
|||
const std::string DB_DEVNMAX = "iDevnMax";
|
||||
const std::string FLOD = "bFlod";
|
||||
const std::string AUTOCROP = "bAuotCrop";
|
||||
const std::string HIGH_IMAGE_QUALITY = "bHighimagequality";
|
||||
const std::string SWITCHFRONTBACK = "bSwitchFrontBack";
|
||||
const std::string SPLIT = "bSplit";
|
||||
|
||||
|
@ -61,6 +63,8 @@ const std::string SHARPENTYPE = "iSharpen";
|
|||
const std::string FILLBLACK = "bFillBlcak";
|
||||
const std::string AUTODESCREW = "bAutoDescrew";
|
||||
const std::string MULTIOUTPUT = "iMultiOutPut";
|
||||
const std::string EN_MULTIOUT = "bMultiOut";
|
||||
const std::string MULTIOUTTYPE = "iMultiOut";
|
||||
const std::string OUTHOLE = "bOutHole";
|
||||
const std::string OUTHOLERATIO = "iOutHoleRatio";
|
||||
const std::string DETACHNOISE = "detachnoise";
|
||||
|
@ -229,53 +233,57 @@ typedef enum SharpenBlur :short {
|
|||
|
||||
struct GScanCap
|
||||
{
|
||||
uint8_t papertype; /**< the current paper source ADF or Flatbed*/
|
||||
PaperAlign paperAlign;
|
||||
uint8_t en_sizecheck; /**< 尺寸检测*/
|
||||
float imageRotateDegree;
|
||||
uint8_t is_duplex; /**< True to use duplex false for simplex, ignored if flatbed*/
|
||||
uint8_t en_fold; /**<对折*/
|
||||
int pixtype; /**< type of pixels to transfer image as */
|
||||
int automaticcolor; /**<顔色自動識別*/
|
||||
int automaticcolortype; /**<顔色自動識別后非彩色上傳類型*/
|
||||
//ScanRect scanrect;
|
||||
float resolution_dst; /**< horizontal resolution */
|
||||
float resolution_native;
|
||||
float gamma; /**< Gamma */
|
||||
float contrast; /**< Contrast */
|
||||
float brightness; /**< Brightness */
|
||||
float threshold; /**< Threshold */
|
||||
bool fadeback; /**< 除底色*/
|
||||
int fadeback_range; /**< 除底色范围*/
|
||||
uint8_t is_autocontrast; /**< 自动对比度*/
|
||||
uint8_t is_autocrop; /**< 自动裁切*/
|
||||
bool normalCrop; /**<传统模式自动裁切*/
|
||||
bool is_split; /**< 图像拆分*/
|
||||
uint8_t is_autodiscradblank_normal; /**< 自动丢弃空白页通用*/
|
||||
int discardblank_percent; /**<跳过空白页阀值*/
|
||||
uint8_t is_autodiscradblank_vince;/**自动丢弃空白页发票*/
|
||||
uint8_t is_switchfrontback; /**交换正反面*/
|
||||
uint8_t autodescrew; /**< 自动纠偏*/
|
||||
uint8_t multi_output_red; /*多流输出*/
|
||||
uint8_t hsvcorrect; /**<答题卡除红*/
|
||||
uint8_t filter; /**< 除色*/
|
||||
uint8_t papertype; /**< the current paper source ADF or Flatbed*/
|
||||
PaperAlign paperAlign;
|
||||
bool en_fixedpaper; /**< 敦南固定幅面扫描*/
|
||||
uint8_t en_sizecheck; /**< 尺寸检测*/
|
||||
float imageRotateDegree;
|
||||
uint8_t is_duplex; /**< True to use duplex false for simplex, ignored if flatbed*/
|
||||
uint8_t en_fold; /**<对折*/
|
||||
int pixtype; /**< type of pixels to transfer image as */
|
||||
int automaticcolor; /**<顔色自動識別*/
|
||||
int automaticcolortype; /**<顔色自動識別后非彩色上傳類型*/
|
||||
//ScanRect scanrect;
|
||||
float resolution_dst; /**< horizontal resolution */
|
||||
float resolution_native;
|
||||
float gamma; /**< Gamma */
|
||||
float contrast; /**< Contrast */
|
||||
float brightness; /**< Brightness */
|
||||
float threshold; /**< Threshold */
|
||||
bool fadeback; /**< 除底色*/
|
||||
int fadeback_range; /**< 除底色范围*/
|
||||
uint8_t is_autocontrast; /**< 自动对比度*/
|
||||
uint8_t is_autocrop; /**< 自动裁切*/
|
||||
bool normalCrop; /**<传统模式自动裁切*/
|
||||
bool is_split; /**< 图像拆分*/
|
||||
bool is_high_imagequality; /**< 画质优先*/
|
||||
uint8_t is_autodiscradblank_normal; /**< 自动丢弃空白页通用*/
|
||||
int discardblank_percent; /**<跳过空白页阀值*/
|
||||
uint8_t is_autodiscradblank_vince; /**自动丢弃空白页发票*/
|
||||
uint8_t is_switchfrontback; /**交换正反面*/
|
||||
uint8_t autodescrew; /**< 自动纠偏*/
|
||||
uint8_t multi_output_red; /*多流输出除红*/
|
||||
bool en_multi_output; /**< 多流输出*/
|
||||
int8_t multioutput;
|
||||
uint8_t hsvcorrect; /**<答题卡除红*/
|
||||
uint8_t filter; /**< 除色*/
|
||||
uint8_t sharpen;
|
||||
uint8_t enhance_color; /**< 颜色增强*/
|
||||
uint8_t fillbackground; /**< 填黑框*/
|
||||
bool is_convex; /**< 填黑框模式,true为凸多边形填充,false为凹多边形填充,默认true*/
|
||||
int noise; /**< 除噪像素,能够消除noise宽度的背景竖条纹干扰,默认40*/
|
||||
int indent; /**< 轮廓缩进,裁剪、纠偏或者黑底填充时,对探索到的纸张轮廓进行缩进indent像素,默认5*/
|
||||
int AutoCrop_threshold; /**< 自动裁剪二值化阈值,取值范围(0, 255),默认40*/
|
||||
unsigned short scannum; /**< 扫描张数*/
|
||||
uint8_t is_backrotate180; /**< 背面旋转180*/
|
||||
uint8_t is_dogeardetection; /**<折角检测*/
|
||||
uint32_t dogeardistance; /**<折角检测范围*/
|
||||
HardwareCaps hardwarecaps; /**< 硬件扫描参数*/
|
||||
FillHole fillhole;
|
||||
DetachNoise detachnoise; /**< 黑白降噪*/
|
||||
uint8_t is_autotext; /**< 自动文本方向识别*/
|
||||
std::string Caption;
|
||||
std::string SavePath;
|
||||
uint8_t enhance_color; /**< 颜色增强*/
|
||||
uint8_t fillbackground; /**< 填黑框*/
|
||||
bool is_convex; /**< 填黑框模式,true为凸多边形填充,false为凹多边形填充,默认true*/
|
||||
int noise; /**< 除噪像素,能够消除noise宽度的背景竖条纹干扰,默认40*/
|
||||
int indent; /**< 轮廓缩进,裁剪、纠偏或者黑底填充时,对探索到的纸张轮廓进行缩进indent像素,默认5*/
|
||||
int AutoCrop_threshold; /**< 自动裁剪二值化阈值,取值范围(0, 255),默认40*/
|
||||
unsigned short scannum; /**< 扫描张数*/
|
||||
uint8_t is_backrotate180; /**< 背面旋转180*/
|
||||
uint8_t is_dogeardetection; /**<折角检测*/
|
||||
uint32_t dogeardistance; /**<折角检测范围*/
|
||||
HardwareCaps hardwarecaps; /**< 硬件扫描参数*/
|
||||
FillHole fillhole;
|
||||
DetachNoise detachnoise; /**< 黑白降噪*/
|
||||
uint8_t is_autotext; /**< 自动文本方向识别*/
|
||||
std::string Caption;
|
||||
std::string SavePath;
|
||||
};
|
||||
|
||||
typedef struct tagCrop_Rect
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
#include <vector>
|
||||
#include <io.h>
|
||||
#include <fstream>
|
||||
#include <Windows.h>
|
||||
#include <TlHelp32.h>
|
||||
#include <timeapi.h>
|
||||
#include <time.h>
|
||||
#include <fcntl.h>
|
||||
|
@ -133,6 +135,30 @@ public:
|
|||
return path;
|
||||
}
|
||||
|
||||
static std::wstring get_errorlog_path_w()
|
||||
{
|
||||
TCHAR szIniFile[MAX_PATH] = { 0 };
|
||||
SHGetSpecialFolderPath(NULL, szIniFile, CSIDL_LOCAL_APPDATA, TRUE);
|
||||
_tcscat(szIniFile, HUAGAO_SCAN);
|
||||
_tcscat(szIniFile, TWAIN_ERROR_PATH);
|
||||
auto path = TCHAR2STRING(szIniFile);
|
||||
if (!isFolderExist(path.data()))
|
||||
createDirectory(path.data());
|
||||
return std::wstring(szIniFile);
|
||||
}
|
||||
|
||||
static std::string get_errorlog_path()
|
||||
{
|
||||
TCHAR szIniFile[MAX_PATH] = { 0 };
|
||||
SHGetSpecialFolderPath(NULL, szIniFile, CSIDL_LOCAL_APPDATA, TRUE);
|
||||
_tcscat(szIniFile, HUAGAO_SCAN);
|
||||
_tcscat(szIniFile, TWAIN_ERROR_PATH);
|
||||
auto path = TCHAR2STRING(szIniFile);
|
||||
if (!isFolderExist(path.data()))
|
||||
createDirectory(path.data());
|
||||
return path;
|
||||
}
|
||||
|
||||
static void deletedir(CString szPath)
|
||||
{
|
||||
CFileFind ff;
|
||||
|
@ -170,6 +196,45 @@ public:
|
|||
}
|
||||
return filesize;
|
||||
}
|
||||
|
||||
static bool kill_process(WCHAR* lpszProcessName)
|
||||
{
|
||||
unsigned int pid = -1;
|
||||
bool retval = true;
|
||||
|
||||
if (lpszProcessName == NULL)
|
||||
return false;
|
||||
|
||||
DWORD dwRet = 0;
|
||||
HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
|
||||
PROCESSENTRY32 processInfo;
|
||||
processInfo.dwSize = sizeof(PROCESSENTRY32);
|
||||
int flag = Process32First(hSnapshot, &processInfo);
|
||||
|
||||
while (flag != 0)
|
||||
{
|
||||
if (StrCmpCW(processInfo.szExeFile, lpszProcessName) == 0)
|
||||
{
|
||||
pid = processInfo.th32ProcessID;
|
||||
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, TRUE, pid);
|
||||
|
||||
if (TerminateProcess(hProcess, 0) != TRUE)
|
||||
{
|
||||
retval = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
flag = Process32Next(hSnapshot, &processInfo);
|
||||
}
|
||||
|
||||
CloseHandle(hSnapshot);
|
||||
|
||||
if (pid == -1)
|
||||
return false;
|
||||
|
||||
return retval;
|
||||
}
|
||||
private:
|
||||
static void getFiles(std::string path, std::vector<std::string>& files)
|
||||
{
|
||||
|
|
|
@ -95,7 +95,9 @@ void GscanJsonConfig::SaveGscanCapConfig(const GScanCap & gcap, const std::strin
|
|||
outJson["Config"].Add(PAPARSIZE, (int)(gcap.papertype));
|
||||
outJson["Config"].Add(PAPERALIGN, (int)(gcap.paperAlign));
|
||||
outJson["Config"].Add(ENSIZECHECK, (bool)(gcap.en_sizecheck), false);
|
||||
outJson["Config"].Add(ENFIXEDPAPER, (bool)(gcap.en_fixedpaper), false);
|
||||
outJson["Config"].Add(AUTOCROP, (bool)(gcap.is_autocrop), false);
|
||||
outJson["Config"].Add(HIGH_IMAGE_QUALITY, (bool)(gcap.is_high_imagequality), false);
|
||||
outJson["Config"].Add(RESOLUTION, (int)(gcap.resolution_dst));
|
||||
outJson["Config"].Add(DUPLEX, (bool)(gcap.is_duplex),false);
|
||||
outJson["Config"].Add(DISCARBLANK, (bool)(gcap.is_autodiscradblank_normal), false);
|
||||
|
@ -120,6 +122,8 @@ void GscanJsonConfig::SaveGscanCapConfig(const GScanCap & gcap, const std::strin
|
|||
outJson["Config"].Add(AUTODESCREW, (bool)(gcap.autodescrew), false);
|
||||
outJson["Config"].Add(FILLBLACK, (bool)(gcap.fillbackground), false);
|
||||
outJson["Config"].Add(MULTIOUTPUT, (bool)(gcap.multi_output_red), false);
|
||||
outJson["Config"].Add(EN_MULTIOUT, (bool)(gcap.en_multi_output), false);
|
||||
outJson["Config"].Add(MULTIOUTTYPE, (int)(gcap.multioutput));
|
||||
outJson["Config"].Add(OUTHOLE, (bool)(gcap.fillhole.is_fillhole), false);
|
||||
outJson["Config"].Add(OUTHOLERATIO, (int)(gcap.fillhole.fillholeratio));
|
||||
outJson["Config"].Add(DETACHNOISE, (bool)(gcap.detachnoise.is_detachnoise), false);
|
||||
|
@ -223,7 +227,9 @@ void GscanJsonConfig::WriteJsonArrayToFile(std::vector<GScanCap> cfgArray, const
|
|||
root["Config"][PAPARSIZE].Add((int)cfgArray[i].papertype);
|
||||
root["Config"][PAPERALIGN].Add((int)cfgArray[i].paperAlign);
|
||||
root["Config"][ENSIZECHECK].Add(i, (bool)cfgArray[i].en_sizecheck);
|
||||
root["Config"][ENFIXEDPAPER].Add(i, (bool)cfgArray[i].en_fixedpaper);
|
||||
root["Config"][AUTOCROP].Add(i, (bool)cfgArray[i].is_autocrop);
|
||||
root["Config"][HIGH_IMAGE_QUALITY].Add(i, (bool)cfgArray[i].is_high_imagequality);
|
||||
root["Config"][RESOLUTION].Add((int)cfgArray[i].resolution_dst);
|
||||
root["Config"][DUPLEX].Add(i,(bool)cfgArray[i].is_duplex);
|
||||
root["Config"][DISCARBLANK].Add(i, (bool)cfgArray[i].is_autodiscradblank_normal);
|
||||
|
@ -248,6 +254,8 @@ void GscanJsonConfig::WriteJsonArrayToFile(std::vector<GScanCap> cfgArray, const
|
|||
root["Config"][AUTODESCREW].Add(i, (bool)cfgArray[i].autodescrew);
|
||||
root["Config"][FILLBLACK].Add(i, (bool)cfgArray[i].fillbackground);
|
||||
root["Config"][MULTIOUTPUT].Add(i, (bool)cfgArray[i].multi_output_red);
|
||||
root["Config"][EN_MULTIOUT].Add(i, (bool)cfgArray[i].en_multi_output);
|
||||
root["Config"][MULTIOUTTYPE].Add((int)cfgArray[i].multioutput);
|
||||
root["Config"][OUTHOLE].Add(i, (bool)cfgArray[i].fillhole.is_fillhole);
|
||||
root["Config"][OUTHOLERATIO].Add((int)cfgArray[i].fillhole.fillholeratio);
|
||||
root["Config"][DETACHNOISE].Add(i, (bool)cfgArray[i].detachnoise.is_detachnoise);
|
||||
|
@ -381,10 +389,14 @@ std::vector<GScanCap> GscanJsonConfig::parseJsonFromString(const std::string str
|
|||
root["Config"].Get(AUTOMATICCOLORTYPR, itmautomaticcolortype);
|
||||
neb::CJsonObject itmAutoCrop;
|
||||
root["Config"].Get(AUTOCROP, itmAutoCrop);
|
||||
neb::CJsonObject itmImageQuality;
|
||||
root["Config"].Get(HIGH_IMAGE_QUALITY, itmImageQuality);
|
||||
neb::CJsonObject itmPaperAlign;
|
||||
root["Config"].Get(PAPERALIGN, itmPaperAlign);
|
||||
neb::CJsonObject itmSizeCheck;
|
||||
root["Config"].Get(ENSIZECHECK, itmSizeCheck);
|
||||
neb::CJsonObject itmFixedPaper;
|
||||
root["Config"].Get(ENFIXEDPAPER, itmFixedPaper);
|
||||
neb::CJsonObject itmRes;
|
||||
root["Config"].Get(RESOLUTION, itmRes);
|
||||
neb::CJsonObject itmDulpex;
|
||||
|
@ -431,6 +443,10 @@ std::vector<GScanCap> GscanJsonConfig::parseJsonFromString(const std::string str
|
|||
root["Config"].Get(FILLBLACK, itmFillBlack);
|
||||
neb::CJsonObject itmMultiOutput;
|
||||
root["Config"].Get(MULTIOUTPUT, itmMultiOutput);
|
||||
neb::CJsonObject itmEnMultiOut;
|
||||
root["Config"].Get(EN_MULTIOUT, itmEnMultiOut);
|
||||
neb::CJsonObject itmMultiOutType;
|
||||
root["Config"].Get(MULTIOUTTYPE, itmMultiOutType);
|
||||
neb::CJsonObject itmOutHole;
|
||||
root["Config"].Get(OUTHOLE, itmOutHole);
|
||||
neb::CJsonObject itmOutHoleRatio;
|
||||
|
@ -508,8 +524,12 @@ std::vector<GScanCap> GscanJsonConfig::parseJsonFromString(const std::string str
|
|||
cfp.paperAlign = (PaperAlign)i_value;
|
||||
itmSizeCheck.Get(i, b_value);
|
||||
cfp.en_sizecheck = b_value ? 1 : 0;
|
||||
itmFixedPaper.Get(i, b_value);
|
||||
cfp.en_fixedpaper = b_value ? 1 : 0;
|
||||
itmAutoCrop.Get(i, b_value);
|
||||
cfp.is_autocrop = b_value ? 1 : 0;
|
||||
itmImageQuality.Get(i, b_value);
|
||||
cfp.is_high_imagequality = b_value ? 1 : 0;
|
||||
itmRes.Get(i, i_value);
|
||||
cfp.resolution_dst = i_value;
|
||||
itmDulpex.Get(i, b_value);
|
||||
|
@ -555,6 +575,10 @@ std::vector<GScanCap> GscanJsonConfig::parseJsonFromString(const std::string str
|
|||
cfp.fillbackground = b_value ? 1 : 0;
|
||||
itmMultiOutput.Get(i, b_value);
|
||||
cfp.multi_output_red = b_value ? 1 : 0;
|
||||
itmEnMultiOut.Get(i, b_value);
|
||||
cfp.en_multi_output = b_value ? 1 : 0;
|
||||
itmMultiOutType.Get(i, i_value);
|
||||
cfp.multioutput = i_value;
|
||||
itmOutHole.Get(i, b_value);
|
||||
cfp.fillhole.is_fillhole = b_value ? 1 : 0;
|
||||
itmOutHoleRatio.Get(i, i_value);
|
||||
|
@ -634,8 +658,12 @@ std::vector<GScanCap> GscanJsonConfig::parseJsonFromString(const std::string str
|
|||
cfp.paperAlign =(PaperAlign) index;
|
||||
root["Config"].Get(ENSIZECHECK, bvalue);
|
||||
cfp.en_sizecheck = bvalue ? 1 : 0;
|
||||
root["Config"].Get(ENFIXEDPAPER, bvalue);
|
||||
cfp.en_fixedpaper = bvalue ? 1 : 0;
|
||||
root["Config"].Get(AUTOCROP, bvalue);
|
||||
cfp.is_autocrop = bvalue?1:0;
|
||||
root["Config"].Get(HIGH_IMAGE_QUALITY, bvalue);
|
||||
cfp.is_high_imagequality = bvalue ? 1 : 0;
|
||||
root["Config"].Get(RESOLUTION, index);
|
||||
cfp.resolution_dst = index;
|
||||
root["Config"].Get(DUPLEX, bvalue);
|
||||
|
@ -678,6 +706,10 @@ std::vector<GScanCap> GscanJsonConfig::parseJsonFromString(const std::string str
|
|||
cfp.fillbackground = bvalue?1:0;
|
||||
root["Config"].Get(MULTIOUTPUT, bvalue);
|
||||
cfp.multi_output_red = bvalue?1:0;
|
||||
root["Config"].Get(EN_MULTIOUT, bvalue);
|
||||
cfp.en_multi_output = bvalue ? 1 : 0;
|
||||
root["Config"].Get(MULTIOUTTYPE, index);
|
||||
cfp.multioutput = index;
|
||||
root["Config"].Get(OUTHOLE, bvalue);
|
||||
cfp.fillhole.is_fillhole = bvalue?1:0;
|
||||
root["Config"].Get(OUTHOLERATIO, index);
|
||||
|
@ -767,7 +799,9 @@ json GscanJsonConfig::GscancapToJson(GScanCap& cap)
|
|||
js[CONFIG][PAPARSIZE] = cap.papertype;
|
||||
js[CONFIG][PAPERALIGN] = cap.paperAlign;
|
||||
js[CONFIG][ENSIZECHECK] = cap.en_sizecheck;
|
||||
js[CONFIG][ENFIXEDPAPER] = cap.en_fixedpaper;
|
||||
js[CONFIG][AUTOCROP] = cap.is_autocrop;
|
||||
js[CONFIG][HIGH_IMAGE_QUALITY] = cap.is_high_imagequality;
|
||||
js[CONFIG][RESOLUTION] = cap.resolution_dst;
|
||||
js[CONFIG][DUPLEX] = cap.is_duplex;
|
||||
js[CONFIG][DISCARBLANK] = cap.is_autodiscradblank_normal;
|
||||
|
@ -794,6 +828,8 @@ json GscanJsonConfig::GscancapToJson(GScanCap& cap)
|
|||
js[CONFIG][AUTODESCREW] = cap.autodescrew;
|
||||
js[CONFIG][FILLBLACK] = cap.fillbackground;
|
||||
js[CONFIG][MULTIOUTPUT] = cap.multi_output_red;
|
||||
js[CONFIG][EN_MULTIOUT] = cap.en_multi_output;
|
||||
js[CONFIG][MULTIOUTTYPE] = cap.multioutput;
|
||||
js[CONFIG][OUTHOLE] = cap.fillhole.is_fillhole;
|
||||
js[CONFIG][OUTHOLERATIO] = cap.fillhole.fillholeratio;
|
||||
js[CONFIG][HSVCORRECT] = cap.hsvcorrect;
|
||||
|
@ -830,7 +866,9 @@ GScanCap GscanJsonConfig::JsonToGscancap(json& js)
|
|||
cap.papertype = json_cast(js[CONFIG][PAPARSIZE]).to_int();
|
||||
cap.paperAlign = static_cast<PaperAlign>(json_cast(js[CONFIG][PAPERALIGN]).to_uint8());
|
||||
cap.en_sizecheck = json_cast(js[CONFIG][ENSIZECHECK]).to_int();
|
||||
cap.en_fixedpaper = json_cast(js[CONFIG][ENFIXEDPAPER]).to_bool();
|
||||
cap.is_autocrop = json_cast(js[CONFIG][AUTOCROP]).to_int();
|
||||
cap.is_high_imagequality =json_cast(js[CONFIG][HIGH_IMAGE_QUALITY]).to_bool();
|
||||
cap.resolution_dst = json_cast(js[CONFIG][RESOLUTION]).to_float();
|
||||
cap.is_duplex = json_cast(js[CONFIG][DUPLEX]).to_int();
|
||||
cap.is_autodiscradblank_normal = json_cast(js[CONFIG][DISCARBLANK]).to_int();
|
||||
|
@ -858,6 +896,8 @@ GScanCap GscanJsonConfig::JsonToGscancap(json& js)
|
|||
cap.autodescrew = json_cast(js[CONFIG][AUTODESCREW]).to_int();
|
||||
cap.fillbackground = json_cast(js[CONFIG][FILLBLACK]).to_int();
|
||||
cap.multi_output_red = json_cast(js[CONFIG][MULTIOUTPUT]).to_int();
|
||||
cap.en_multi_output = json_cast(js[CONFIG][EN_MULTIOUT]).to_bool();
|
||||
cap.multioutput = json_cast(js[CONFIG][MULTIOUTTYPE]).to_int();
|
||||
cap.fillhole.is_fillhole = json_cast(js[CONFIG][OUTHOLE]).to_int();
|
||||
cap.fillhole.fillholeratio = json_cast(js[CONFIG][OUTHOLERATIO]).to_int();
|
||||
cap.hsvcorrect = json_cast(js[CONFIG][HSVCORRECT]).to_int();
|
||||
|
@ -892,7 +932,9 @@ json GscanJsonConfig::GetDefaultJson()
|
|||
"iPaparSize": 0 ,
|
||||
"iPaperAlign": 0 ,
|
||||
"iEnSizeCheck": false ,
|
||||
"bEnFixedPaper": false,
|
||||
"bAuotCrop": true ,
|
||||
"bHighimagequality" : false,
|
||||
"bcropmodel": false,
|
||||
"iResolution": 200 ,
|
||||
"iDuplex": true ,
|
||||
|
@ -904,7 +946,7 @@ json GscanJsonConfig::GetDefaultJson()
|
|||
"bSplit": false ,
|
||||
"bUVmodel": false,
|
||||
"detachnoise": false ,
|
||||
"detachnoisevalue": 30 ,
|
||||
"detachnoisevalue": 10 ,
|
||||
"bfadeback": false ,
|
||||
"fadebackvalue": 40,
|
||||
"iBrightness": 0 ,
|
||||
|
@ -917,6 +959,8 @@ json GscanJsonConfig::GetDefaultJson()
|
|||
"bAutoDescrew": true ,
|
||||
"bFillBlcak": true ,
|
||||
"iMultiOutPut": false ,
|
||||
"bMultiOut": false ,
|
||||
"iMultiOut": 0 ,
|
||||
"bOutHole": false ,
|
||||
"iOutHoleRatio": 10 ,
|
||||
"bHsvCorrect": false ,
|
||||
|
@ -928,7 +972,7 @@ json GscanJsonConfig::GetDefaultJson()
|
|||
"bAutoText": false ,
|
||||
"iBackRotate180": false ,
|
||||
"dogeardetection": false ,
|
||||
"idogeardistance": 50 ,
|
||||
"idogeardistance": 70 ,
|
||||
"bScrewDetect": true ,
|
||||
"iScrewLevel": 3 ,
|
||||
"Noise": 8 ,
|
||||
|
@ -949,7 +993,9 @@ json GscanJsonConfig::GetDefaultJson()
|
|||
"iPaparSize": 0 ,
|
||||
"iPaperAlign": 0 ,
|
||||
"iEnSizeCheck": false ,
|
||||
"bEnFixedPaper": false,
|
||||
"bAuotCrop": true ,
|
||||
"bHighimagequality" : false,
|
||||
"bcropmodel": false,
|
||||
"iResolution": 200 ,
|
||||
"iDuplex": true ,
|
||||
|
@ -960,7 +1006,7 @@ json GscanJsonConfig::GetDefaultJson()
|
|||
"bSwitchFrontBack": false ,
|
||||
"bSplit": false ,
|
||||
"detachnoise": false ,
|
||||
"detachnoisevalue": 30 ,
|
||||
"detachnoisevalue": 10 ,
|
||||
"bfadeback": false ,
|
||||
"fadebackvalue": 40,
|
||||
"iBrightness": 0 ,
|
||||
|
@ -973,6 +1019,8 @@ json GscanJsonConfig::GetDefaultJson()
|
|||
"bAutoDescrew": true ,
|
||||
"bFillBlcak": true ,
|
||||
"iMultiOutPut": false ,
|
||||
"bMultiOut": false ,
|
||||
"iMultiOut": 0 ,
|
||||
"bOutHole": false ,
|
||||
"iOutHoleRatio": 10 ,
|
||||
"bHsvCorrect": false ,
|
||||
|
@ -984,7 +1032,7 @@ json GscanJsonConfig::GetDefaultJson()
|
|||
"bAutoText": false ,
|
||||
"iBackRotate180": false ,
|
||||
"dogeardetection": false ,
|
||||
"idogeardistance": 50 ,
|
||||
"idogeardistance": 70 ,
|
||||
"bScrewDetect": true ,
|
||||
"iScrewLevel": 3 ,
|
||||
"Noise": 8 ,
|
||||
|
@ -1103,6 +1151,7 @@ json Twain_config::loadjson(std::string path)
|
|||
FileTools::writelog(log_ERROR, "read json error");
|
||||
f.is_open() ? f.close() : void();
|
||||
m_json = defaultjson();
|
||||
savejson(defaultjson(), GetTwainInIPath() + TCHAR2STRING(TWAIN_CONFIG_JSON));
|
||||
return m_json;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,41 +14,61 @@ bool isColor(const cv::Mat& image)
|
|||
if (image.channels() != 3) return false;
|
||||
|
||||
cv::Mat pDib_resize;
|
||||
cv::resize(image, pDib_resize, cv::Size(image.cols / 9, image.rows / 9), 0, 0, cv::INTER_AREA);
|
||||
cv::resize(image, pDib_resize, cv::Size(image.cols / 4, image.rows / 4), 0, 0, cv::INTER_NEAREST);
|
||||
|
||||
cv::Mat hsv;
|
||||
cv::cvtColor(pDib_resize, hsv, cv::COLOR_BGR2HSV_FULL);
|
||||
std::vector<cv::Mat> hsv_channels;
|
||||
cv::split(hsv, hsv_channels);
|
||||
|
||||
cv::Mat range_h1, range_h2, range_s, range_v;
|
||||
cv::inRange(hsv_channels[0], 0, 85, range_h1);
|
||||
cv::inRange(hsv_channels[0], 170, 255, range_h2);
|
||||
cv::inRange(hsv_channels[1], 60, 255, range_s);
|
||||
cv::inRange(hsv_channels[2], 100, 255, range_v);
|
||||
cv::Mat range_s1, range_s2;
|
||||
cv::inRange(hsv_channels[1], 220, 255, range_s1); //饱和度在[220, 255]的像素
|
||||
cv::inRange(hsv_channels[1], 50, 220, range_s2); //饱和度在[50, 220]的像素
|
||||
#if 0
|
||||
cv::imwrite("range_s1.bmp", range_s1);
|
||||
cv::imwrite("range_s2.bmp", range_s2);
|
||||
#endif
|
||||
double sum = cv::sum(range_s1)[0] / 255;
|
||||
double total = range_s1.total();
|
||||
|
||||
cv::Mat thre = (range_h1 | range_h2) & range_s & range_v;
|
||||
return (cv::sum(thre)[0] / 255)> 4;
|
||||
// if (sum / total > 0.0001)
|
||||
if (sum / total > 0.001)
|
||||
return true;
|
||||
sum += cv::sum(range_s2)[0] / 255;
|
||||
// if (sum / total > 0.001)
|
||||
if (sum / total > 0.03)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isGray(const cv::Mat& image)
|
||||
{
|
||||
if (image.channels() == 3) return true;
|
||||
//if (image.channels() == 3) return true;
|
||||
|
||||
cv::Mat image_clone;
|
||||
cv::resize(image, image_clone, cv::Size(), 0.25, 0.25);
|
||||
int channels[] = { 0 };
|
||||
int histsize[] = { 256 };
|
||||
float range[] = { 0, 256 };
|
||||
const float* histRanges[] = { range };
|
||||
cv::Mat hist;
|
||||
cv::calcHist(&image_clone, 1, channels, cv::Mat(), hist, 1, histsize, histRanges, true, false);
|
||||
//cv::Mat image_clone;
|
||||
//cv::resize(image, image_clone, cv::Size(), 0.25, 0.25);
|
||||
//int channels[] = { 0 };
|
||||
//int histsize[] = { 256 };
|
||||
//float range[] = { 0, 256 };
|
||||
//const float* histRanges[] = { range };
|
||||
//cv::Mat hist;
|
||||
//cv::calcHist(&image_clone, 1, channels, cv::Mat(), hist, 1, histsize, histRanges, true, false);
|
||||
//float pixels[256] = { 0 };
|
||||
//for (size_t i = 0; i < 256; i++)
|
||||
// pixels[i] = hist.at<float>(i, 0);
|
||||
|
||||
float pixel_count0 = hist.at<float>(0, 0);
|
||||
float pixel_count255 = hist.at<float>(255, 0);
|
||||
float total = image_clone.total();
|
||||
|
||||
return ((pixel_count0 + pixel_count255) / total) > 0.95;
|
||||
//float sum = 0;
|
||||
//for (size_t i = 0; i < 40; i++)
|
||||
//{
|
||||
|
||||
//}
|
||||
//float pixel_count0 = hist.at<float>(0, 0);
|
||||
//float pixel_count255 = hist.at<float>(255, 0);
|
||||
//float total = image_clone.total();
|
||||
|
||||
//return ((pixel_count0 + pixel_count255) / total) > 0.95;
|
||||
return false;
|
||||
}
|
||||
|
||||
CImageApplyColorRecognition::CImageApplyColorRecognition(ColorRecognitionMode mode)
|
||||
|
@ -62,40 +82,49 @@ CImageApplyColorRecognition::~CImageApplyColorRecognition(void)
|
|||
|
||||
void CImageApplyColorRecognition::apply(cv::Mat& pDib, int side)
|
||||
{
|
||||
//先判断是否需要判断是彩色
|
||||
if (m_mode == AllColor || m_mode == Color_Gray || m_mode == Color_Mono)
|
||||
if (pDib.channels() != 3)
|
||||
{
|
||||
//如果是彩色,直接退出
|
||||
if (isColor(pDib))
|
||||
{
|
||||
m_result = Color;
|
||||
return;
|
||||
}
|
||||
m_result = Gray;
|
||||
return;
|
||||
}
|
||||
|
||||
if (pDib.channels() == 3)
|
||||
m_result = isColor(pDib) ? Color : Gray;
|
||||
if (m_result == Gray && pDib.channels() == 3)
|
||||
cv::cvtColor(pDib, pDib, cv::COLOR_BGR2GRAY);
|
||||
|
||||
if (m_mode == Color_Gray)
|
||||
{
|
||||
m_result = Gray;
|
||||
return;
|
||||
}
|
||||
//先判断是否需要判断是彩色
|
||||
//if (m_mode == AllColor || m_mode == Color_Gray || m_mode == Color_Mono)
|
||||
//{
|
||||
// //如果是彩色,直接退出
|
||||
// if (isColor(pDib))
|
||||
// {
|
||||
// m_result = Color;
|
||||
// return;
|
||||
// }
|
||||
//}
|
||||
|
||||
if (m_mode == Color_Mono)
|
||||
{
|
||||
m_bw.apply(pDib, side);
|
||||
m_result = Mono;
|
||||
return;
|
||||
}
|
||||
//if (pDib.channels() == 3)
|
||||
// cv::cvtColor(pDib, pDib, cv::COLOR_BGR2GRAY);
|
||||
|
||||
if (isGray(pDib))
|
||||
m_result = Gray;
|
||||
else
|
||||
{
|
||||
m_bw.apply(pDib, side);
|
||||
m_result = Mono;
|
||||
}
|
||||
//if (m_mode == Color_Gray)
|
||||
//{
|
||||
// m_result = Gray;
|
||||
// return;
|
||||
//}
|
||||
|
||||
//if (m_mode == Color_Mono)
|
||||
//{
|
||||
// m_bw.apply(pDib, side);
|
||||
// m_result = Mono;
|
||||
// return;
|
||||
//}
|
||||
|
||||
//if (isGray(pDib))
|
||||
// m_result = Gray;
|
||||
//else
|
||||
//{
|
||||
// m_bw.apply(pDib, side);
|
||||
// m_result = Mono;
|
||||
//}
|
||||
}
|
||||
|
||||
void CImageApplyColorRecognition::apply(std::vector<cv::Mat>& mats, bool isTwoSide)
|
||||
|
@ -123,4 +152,4 @@ CImageApplyColorRecognition::ColorType CImageApplyColorRecognition::getResult()
|
|||
std::vector<CImageApplyColorRecognition::ColorType> CImageApplyColorRecognition::getResults()
|
||||
{
|
||||
return m_results;
|
||||
}
|
||||
}
|
|
@ -4,10 +4,12 @@
|
|||
* 功能:色彩识别,将识别会“灰度”的24位图转化为256色8位图, 把识别为“黑白”图转化为二值化的8位图
|
||||
* 作者:刘丁维
|
||||
* 生成时间:2020/7/17
|
||||
* 最近修改时间:2020/12/15
|
||||
* 最近修改时间:2021/04/19
|
||||
* 版本号:v1.0 2020/7/17
|
||||
* v1.1 2020/12/15 调整策略,仅判断红色像素,存在红色像素为彩色,否则为灰度;删除输出结果,直接转换图像。
|
||||
* v1.2 2020/12/16 增加颜色限制模式(输出结果只可能两种),增加结果访问接口
|
||||
* v1.3 2021/04/19 修改识别策略,能够识别占比1‰的彩色图像。只区分彩色和灰度图。
|
||||
* v1.4 2021/06/18 调整二级色彩区间,从原来的[90, 200]调整为[50, 200]。
|
||||
* ====================================================
|
||||
*/
|
||||
|
||||
|
@ -16,9 +18,9 @@
|
|||
|
||||
#include "ImageApply.h"
|
||||
|
||||
class CImageApplyColorRecognition : public CImageApply
|
||||
class CImageApplyColorRecognition : public CImageApply
|
||||
{
|
||||
public :
|
||||
public:
|
||||
|
||||
//色彩识别模式
|
||||
enum ColorRecognitionMode
|
||||
|
@ -63,4 +65,4 @@ private:
|
|||
ColorRecognitionMode m_mode;
|
||||
};
|
||||
|
||||
#endif // !IMAGE_APPLY_CONCATENATION_H
|
||||
#endif // !IMAGE_APPLY_CONCATENATION_H
|
|
@ -80,7 +80,7 @@ void CImageApplyFadeBackGroudColor::fadeBackground(unsigned char* data, int byte
|
|||
|
||||
//ͳ¼Æ±³¾°É«
|
||||
int max_vals[3] = { 0 };
|
||||
int max_indexes[3];
|
||||
int max_indexes[3] = { 0 };
|
||||
|
||||
for (size_t i = 1; i < 256; i++)
|
||||
for (size_t j = 0; j < 3; j++)
|
||||
|
|
|
@ -1,144 +1,164 @@
|
|||
#include "ImageApplyHSVCorrect.h"
|
||||
#include <omp.h>
|
||||
|
||||
CImageApplyHSVCorrect::CImageApplyHSVCorrect()
|
||||
: m_table(new uint[256 * 256 * 256])
|
||||
CImageApplyHSVCorrect::CImageApplyHSVCorrect(CorrectOption mode, bool cvtColor, uint bgr)
|
||||
: m_table(new uint[256 * 256 * 256])
|
||||
{
|
||||
initLUT();
|
||||
}
|
||||
|
||||
CImageApplyHSVCorrect::CImageApplyHSVCorrect(CorrectOption mode)
|
||||
: m_table(new uint[256 * 256 * 256])
|
||||
{
|
||||
initLUT();
|
||||
switch (mode)
|
||||
{
|
||||
case CImageApplyHSVCorrect::Red_Removal:
|
||||
set_HSV_value(std::pair<uchar, uchar>(0, 63), std::pair<uchar, uchar>(20, 255), std::pair<uchar, uchar>(160, 255), 0x00FFFFFF);
|
||||
set_HSV_value(std::pair<uchar, uchar>(191, 255), std::pair<uchar, uchar>(20, 255), std::pair<uchar, uchar>(160, 255), 0x00FFFFFF);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
initLUT();
|
||||
switch (mode)
|
||||
{
|
||||
case CImageApplyHSVCorrect::Red_Removal:
|
||||
set_HSV_value(std::pair<uchar, uchar>(0, 63), std::pair<uchar, uchar>(30, 255), std::pair<uchar, uchar>(120, 255), bgr, cvtColor);
|
||||
set_HSV_value(std::pair<uchar, uchar>(200, 255), std::pair<uchar, uchar>(30, 255), std::pair<uchar, uchar>(120, 255), bgr, cvtColor);
|
||||
break;
|
||||
case CImageApplyHSVCorrect::LowSaturation_Removal:
|
||||
set_HSV_value(std::pair<uchar, uchar>(0, 255), std::pair<uchar, uchar>(0, 30), std::pair<uchar, uchar>(0, 255), bgr, cvtColor);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
CImageApplyHSVCorrect::~CImageApplyHSVCorrect()
|
||||
{
|
||||
delete [] m_table;
|
||||
delete[] m_table;
|
||||
}
|
||||
|
||||
void CImageApplyHSVCorrect::apply(cv::Mat &pDib, int side)
|
||||
void CImageApplyHSVCorrect::apply(cv::Mat& pDib, int side)
|
||||
{
|
||||
(void)side;
|
||||
if (pDib.empty() || pDib.channels() != 3) return;
|
||||
(void)side;
|
||||
if (pDib.empty() || pDib.channels() != 3) return;
|
||||
#if 0
|
||||
uchar* src = pDib.data;
|
||||
cv::Mat z = cv::Mat::zeros(pDib.size(), CV_8UC3);
|
||||
uchar* dst = z.data;
|
||||
|
||||
uchar* src = pDib.data;
|
||||
cv::Mat z = cv::Mat::zeros(pDib.size(), CV_8UC3);
|
||||
uchar* dst = z.data;
|
||||
int bytesPerLine = pDib.cols * pDib.channels();
|
||||
for (size_t i = 0, rows = pDib.rows; i < rows; i++)
|
||||
{
|
||||
uchar* ptr = pDib.ptr(i);
|
||||
for (size_t j = 0, cols = pDib.cols; j < cols; j++)
|
||||
{
|
||||
int offset = i * 3;
|
||||
int index = *reinterpret_cast<uint*>(ptr + offset) & 0x00ffffff;
|
||||
uint color = m_table[index];
|
||||
*reinterpret_cast<uint*>(dst + offset) |= color;
|
||||
}
|
||||
}
|
||||
pDib = z;
|
||||
#else
|
||||
cv::Mat bgra;
|
||||
cv::cvtColor(pDib, bgra, cv::COLOR_BGR2BGRA);
|
||||
|
||||
int total = pDib.total();
|
||||
#pragma omp parallel for
|
||||
for (int i = 0; i < total; i++)
|
||||
{
|
||||
int offset = i * 3;
|
||||
int index = *reinterpret_cast<uint*>(src + offset) & 0x00ffffff;
|
||||
uint color = m_table[index];
|
||||
*reinterpret_cast<uint*>(dst + offset) |= color;
|
||||
}
|
||||
pDib = z;
|
||||
long total = bgra.total();
|
||||
uint* ptr = bgra.ptr<uint>();
|
||||
for (long i = 0; i < total; i++)
|
||||
ptr[i] = m_table[ptr[i] & 0x00FFFFFF];
|
||||
|
||||
cv::cvtColor(bgra, pDib, cv::COLOR_BGRA2BGR);
|
||||
#endif
|
||||
}
|
||||
|
||||
void CImageApplyHSVCorrect::apply(std::vector<cv::Mat> &mats, bool isTwoSide)
|
||||
void CImageApplyHSVCorrect::apply(std::vector<cv::Mat>& mats, bool isTwoSide)
|
||||
{
|
||||
(void)isTwoSide;
|
||||
int i = 0;
|
||||
for (cv::Mat& var : mats) {
|
||||
if (i != 0 && isTwoSide == false)
|
||||
break;
|
||||
if (!var.empty())
|
||||
apply(var, 0);
|
||||
i++;
|
||||
}
|
||||
(void)isTwoSide;
|
||||
int i = 0;
|
||||
for (cv::Mat& var : mats) {
|
||||
if (i != 0 && isTwoSide == false)
|
||||
break;
|
||||
if (!var.empty())
|
||||
apply(var, 0);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
void CImageApplyHSVCorrect::initLUT()
|
||||
{
|
||||
#if 0
|
||||
uchar h, s, v;
|
||||
uchar h, s, v;
|
||||
#endif
|
||||
for (uint b = 0; b < 256; b++)
|
||||
for (uint g = 0; g < 256; g++)
|
||||
for (uint r = 0; r < 256; r++)
|
||||
{
|
||||
for (uint b = 0; b < 256; b++)
|
||||
for (uint g = 0; g < 256; g++)
|
||||
for (uint r = 0; r < 256; r++)
|
||||
{
|
||||
#if 0
|
||||
RGB_2_HSV_full(r, g, b, h, s, v);
|
||||
RGB_2_HSV_full(r, g, b, h, s, v);
|
||||
|
||||
uint index = b | (g << 8) | (r << 16);
|
||||
if (h < 12 || h > 245)
|
||||
m_table[index] = index & 0x00ffffff;
|
||||
else
|
||||
m_table[index] = (v | (v << 8) | (v << 16)) & 0x00ffffff;
|
||||
uint index = b | (g << 8) | (r << 16);
|
||||
if (h < 12 || h > 245)
|
||||
m_table[index] = index & 0x00ffffff;
|
||||
else
|
||||
m_table[index] = (v | (v << 8) | (v << 16)) & 0x00ffffff;
|
||||
#else
|
||||
m_table[b | (g << 8) | (r << 16)] = b | (g << 8) | (r << 16);
|
||||
m_table[b | (g << 8) | (r << 16)] = b | (g << 8) | (r << 16);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CImageApplyHSVCorrect::set_single(const uint src_b, const uint src_g, const uint src_r,
|
||||
const uint dst_b, const uint dst_g, const uint dst_r)
|
||||
const uint dst_b, const uint dst_g, const uint dst_r)
|
||||
{
|
||||
m_table[src_b | (src_g << 8) | (src_r << 16)] = dst_b | (dst_g << 8) | (dst_r << 16);
|
||||
m_table[src_b | (src_g << 8) | (src_r << 16)] = dst_b | (dst_g << 8) | (dst_r << 16);
|
||||
}
|
||||
|
||||
void CImageApplyHSVCorrect::set_HSV_value(const std::pair<uchar, uchar>& range_h,
|
||||
const std::pair<uchar, uchar>& range_s,
|
||||
const std::pair<uchar, uchar>& range_v,
|
||||
uint bgr)
|
||||
const std::pair<uchar, uchar>& range_s,
|
||||
const std::pair<uchar, uchar>& range_v,
|
||||
uint bgr, bool cvtGray)
|
||||
{
|
||||
uchar h, s, v;
|
||||
for (int b = 0; b < 256; b++)
|
||||
for (int g = 0; g < 256; g++)
|
||||
for (int r = 0; r < 256; r++)
|
||||
{
|
||||
RGB_2_HSV_full(r, g, b, h, s, v);
|
||||
if (contained(h, range_h) && contained(s, range_s) && contained(v, range_v))
|
||||
m_table[(b | (g << 8) | (r << 16)) & 0x00ffffff] = bgr & 0x00ffffff;
|
||||
}
|
||||
uchar h, s, v;
|
||||
for (int b = 0; b < 256; b++)
|
||||
for (int g = 0; g < 256; g++)
|
||||
for (int r = 0; r < 256; r++)
|
||||
{
|
||||
RGB_2_HSV_full(r, g, b, h, s, v);
|
||||
if (contained(h, range_h) && contained(s, range_s) && contained(v, range_v))
|
||||
{
|
||||
if (cvtGray)
|
||||
{
|
||||
int a = (b + g + r) / 3 * 0x00010101;
|
||||
m_table[(b | (g << 8) | (r << 16)) & 0x00ffffff] = (b + g + r) / 3 * 0x00010101;
|
||||
}
|
||||
else
|
||||
m_table[(b | (g << 8) | (r << 16)) & 0x00ffffff] = bgr & 0x00ffffff;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CImageApplyHSVCorrect::set_table(const uint* table)
|
||||
{
|
||||
memcpy(m_table, table, 256 * 256 * 256);
|
||||
memcpy(m_table, table, 256 * 256 * 256);
|
||||
}
|
||||
|
||||
bool CImageApplyHSVCorrect::contained(uchar value, const std::pair<uchar, uchar> &range)
|
||||
bool CImageApplyHSVCorrect::contained(uchar value, const std::pair<uchar, uchar>& range)
|
||||
{
|
||||
return value >= range.first && value <= range.second;
|
||||
return value >= range.first && value <= range.second;
|
||||
}
|
||||
|
||||
void CImageApplyHSVCorrect::RGB_2_HSV_full(int r, int g, int b, uchar& h, uchar& s, uchar& v)
|
||||
{
|
||||
int minn = cv::min(r, cv::min(g, b));
|
||||
int maxx = cv::max(r, cv::max(g, b));
|
||||
v = static_cast<uchar>(maxx); //V
|
||||
int minn = cv::min(r, cv::min(g, b));
|
||||
int maxx = cv::max(r, cv::max(g, b));
|
||||
v = static_cast<uchar>(maxx); //V
|
||||
|
||||
int delta = maxx - minn;
|
||||
float _h;
|
||||
if (maxx == 0)
|
||||
{
|
||||
h = s = v = 0;
|
||||
return;
|
||||
}
|
||||
else
|
||||
s = static_cast<uchar>(delta * 255 / maxx);
|
||||
int delta = maxx - minn;
|
||||
float _h;
|
||||
if (maxx == 0)
|
||||
{
|
||||
h = s = v = 0;
|
||||
return;
|
||||
}
|
||||
else
|
||||
s = static_cast<uchar>(delta * 255 / maxx);
|
||||
|
||||
if (r == maxx)
|
||||
_h = static_cast<float>(g - b) / static_cast<float>(delta);
|
||||
else if (g == maxx)
|
||||
_h = 2 + static_cast<float>(b - r) / static_cast<float>(delta);
|
||||
else
|
||||
_h = 4 + static_cast<float>(r - g) / static_cast<float>(delta);
|
||||
if (r == maxx)
|
||||
_h = static_cast<float>(g - b) / static_cast<float>(delta);
|
||||
else if (g == maxx)
|
||||
_h = 2 + static_cast<float>(b - r) / static_cast<float>(delta);
|
||||
else
|
||||
_h = 4 + static_cast<float>(r - g) / static_cast<float>(delta);
|
||||
|
||||
float __h = _h * 42.6666666667f;
|
||||
h = (__h >= 0) ? static_cast<uchar>(__h) : static_cast<uchar>(__h + 256);
|
||||
float __h = _h * 42.6666666667f;
|
||||
h = (__h >= 0) ? static_cast<uchar>(__h) : static_cast<uchar>(__h + 256);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
/*
|
||||
* ====================================================
|
||||
|
||||
*
|
||||
* 功能:彩色图像,色彩校正。基于LUT实现,预设BGR查值表(表达所有HVS),对BGR原图进行查值校正。
|
||||
* 作者:刘丁维
|
||||
* 生成时间:2020/3/21
|
||||
* 最近修改时间:v1.0 2020/3/21
|
||||
v1.1 2020/6/15 调整除红效果的HSV取值范围
|
||||
* 版本号:v1.1
|
||||
|
||||
* 最近修改时间:v1.0 2020/03/21
|
||||
v1.1 2020/06/15 调整除红效果的HSV取值范围
|
||||
v1.2 2021/08/02 调整内存指针,适应ROI图像的内存偏移。
|
||||
v1.3 2021/08/26 替换答题卡除红Red_Removal实现方案。
|
||||
v1.4 2022/04/22 增加功能,支持用像素灰度值填充原来彩色像素;删除默认构造函数;增加校正选项Deafault和LowSaturation_Removal
|
||||
* 版本号:v1.4
|
||||
*
|
||||
* ====================================================
|
||||
*/
|
||||
|
||||
|
@ -21,58 +24,61 @@ class CImageApplyHSVCorrect : public CImageApply
|
|||
public:
|
||||
enum CorrectOption
|
||||
{
|
||||
Deafault, //默认,无任何除色效果
|
||||
LowSaturation_Removal, //除掉低饱和度像素
|
||||
Red_Removal //除掉红色。红色定义H:[0, 85]∪[170, 255],S:[10, 255],V:[120,255]
|
||||
};
|
||||
public:
|
||||
|
||||
CImageApplyHSVCorrect();
|
||||
|
||||
/*
|
||||
* mode [in]:预设初色模式
|
||||
* cvtColor [in]:替代像素使用默认值,还是使用灰度值。true为灰度值,false为默认值
|
||||
* bgr:[in] 用uint表示BGR值,B在低位,R在高位。(当cvtGray 为false时生效)
|
||||
*/
|
||||
CImageApplyHSVCorrect(CorrectOption mode);
|
||||
CImageApplyHSVCorrect(CorrectOption mode = CorrectOption::Deafault, bool cvtColor = false, uint bgr = 0x00FFFFFF);
|
||||
|
||||
virtual ~CImageApplyHSVCorrect();
|
||||
|
||||
virtual void apply(cv::Mat& pDib,int side);
|
||||
virtual void apply(cv::Mat& pDib, int side);
|
||||
|
||||
virtual void apply(std::vector<cv::Mat>& mats, bool isTwoSide);
|
||||
|
||||
/*
|
||||
* 函数功能:初始化查值表,按照RGB(R在高位,B在低位)的32位数据进行索引,值与索引一致。
|
||||
表中索引范围[0,0x00FFFFFF]。在构造函数中会默认调用该函数。
|
||||
*/
|
||||
/*
|
||||
* 函数功能:初始化查值表,按照RGB(R在高位,B在低位)的32位数据进行索引,值与索引一致。
|
||||
表中索引范围[0,0x00FFFFFF]。在构造函数中会默认调用该函数。
|
||||
*/
|
||||
void initLUT();
|
||||
|
||||
/*
|
||||
* 函数功能:将查值表指定RGB索引值设置为目标值。
|
||||
索引 = src_b | (src_g << 8) | (src_r << 16)
|
||||
值 = dst_b | (dst_g << 8) | (dst_r << 16)
|
||||
* src_b:[in] 原查值表B通道索引
|
||||
* src_g:[in] 原查值表G通道索引
|
||||
* src_r:[in] 原查值表R通道索引
|
||||
* dst_b:[in] 目标查值表B通道值
|
||||
* dst_g:[in] 目标查值表G通道值
|
||||
* dst_r:[in] 目标查值表R通道值
|
||||
*/
|
||||
/*
|
||||
* 函数功能:将查值表指定RGB索引值设置为目标值。
|
||||
索引 = src_b | (src_g << 8) | (src_r << 16)
|
||||
值 = dst_b | (dst_g << 8) | (dst_r << 16)
|
||||
* src_b:[in] 原查值表B通道索引
|
||||
* src_g:[in] 原查值表G通道索引
|
||||
* src_r:[in] 原查值表R通道索引
|
||||
* dst_b:[in] 目标查值表B通道值
|
||||
* dst_g:[in] 目标查值表G通道值
|
||||
* dst_r:[in] 目标查值表R通道值
|
||||
*/
|
||||
void set_single(const uint src_b, const uint src_g, const uint src_r,
|
||||
const uint dst_b, const uint dst_g, const uint dst_r);
|
||||
/*
|
||||
* 函数功能:按照HSV色彩空间描述色彩范围,将该范围对应的BGR索引设置为0x00FFFFFF(默认白色)
|
||||
* range_h:[in] H分量范围,取值范围[0, 255]
|
||||
* range_s:[in] S分量范围,取值范围[0, 255]
|
||||
* range_v:[in] V分量范围,取值范围[0, 255]
|
||||
* bgr:[in] 用uint表示BGR值,B在低位,R在高位
|
||||
*/
|
||||
void set_HSV_value(const std::pair<uchar, uchar>& range_h,
|
||||
const std::pair<uchar, uchar>& range_s,
|
||||
const std::pair<uchar, uchar>& range_v,
|
||||
uint bgr = 0x00FFFFFF);
|
||||
const uint dst_b, const uint dst_g, const uint dst_r);
|
||||
|
||||
/*
|
||||
* 函数功能:设置外部查值表,表默认长度为 256 * 256 * 256 * sizeof(uint)
|
||||
* table:[in] 数组指针
|
||||
*/
|
||||
/*
|
||||
* 函数功能:按照HSV色彩空间描述色彩范围,将该范围对应的BGR索引设置为0x00FFFFFF(默认白色)
|
||||
* range_h:[in] H分量范围,取值范围[0, 255]
|
||||
* range_s:[in] S分量范围,取值范围[0, 255]
|
||||
* range_v:[in] V分量范围,取值范围[0, 255]
|
||||
* bgr:[in] 用uint表示BGR值,B在低位,R在高位。(当cvtGray 为false时生效)
|
||||
* cvtGray:[in] 为true时,根据RGB值转换为灰度值
|
||||
*/
|
||||
void set_HSV_value(const std::pair<uchar, uchar>& range_h,
|
||||
const std::pair<uchar, uchar>& range_s,
|
||||
const std::pair<uchar, uchar>& range_v,
|
||||
uint bgr = 0x00FFFFFF, bool cvtGray = false);
|
||||
|
||||
/*
|
||||
* 函数功能:设置外部查值表,表默认长度为 256 * 256 * 256 * sizeof(uint)
|
||||
* table:[in] 数组指针
|
||||
*/
|
||||
void set_table(const uint* table);
|
||||
|
||||
private:
|
||||
|
@ -85,3 +91,4 @@ private:
|
|||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
#include "ImageApplyOutHole.h"
|
||||
#include "ImageProcess_Public.h"
|
||||
|
||||
#ifdef LOG
|
||||
#include "Device/filetools.h"
|
||||
#endif // LOG
|
||||
|
||||
CImageApplyOutHole::CImageApplyOutHole(void)
|
||||
: CImageApply()
|
||||
, m_borderSize(600)
|
||||
|
@ -33,23 +29,13 @@ void CImageApplyOutHole::apply(cv::Mat& pDib, int side)
|
|||
|
||||
void CImageApplyOutHole::apply(std::vector<cv::Mat>& mats, bool isTwoSide)
|
||||
{
|
||||
#ifdef LOG
|
||||
FileTools::write_log("imgprc.txt", "enter ImageOutHole apply");
|
||||
#endif // LOG
|
||||
|
||||
if (mats.size() < 2)
|
||||
{
|
||||
#ifdef LOG
|
||||
FileTools::write_log("imgprc.txt", "exit ImageOutHole apply");
|
||||
#endif // LOG
|
||||
return;
|
||||
}
|
||||
|
||||
if (mats[0].empty() || mats[1].empty())
|
||||
{
|
||||
#ifdef LOG
|
||||
FileTools::write_log("imgprc.txt", "exit ImageOutHole apply");
|
||||
#endif // LOG
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -88,7 +74,7 @@ void CImageApplyOutHole::apply(std::vector<cv::Mat>& mats, bool isTwoSide)
|
|||
//提取正反面图像重叠部分区域
|
||||
cv::Rect roi_front, roi_back;
|
||||
cv::RotatedRect mask_rotatedRect;
|
||||
getRoi(rrect_front, rrect_back, cv::Size(front.cols, front.rows), roi_front, roi_back, mask_rotatedRect);
|
||||
getRoi(rrect_front, rrect_back, front.size(), back.size(), roi_front, roi_back, mask_rotatedRect);
|
||||
|
||||
cv::Mat roiMat_front(front_thre, roi_front); //在正面二值图像中截取重叠部分
|
||||
cv::Mat roiMat_back(back_thre, roi_back); //在反面二值图像中截取重叠部分
|
||||
|
@ -97,9 +83,6 @@ void CImageApplyOutHole::apply(std::vector<cv::Mat>& mats, bool isTwoSide)
|
|||
cv::Mat mask;
|
||||
cv::bitwise_or(roiMat_front, roiMat_back, mask); //或运算,正反面二值图像重叠
|
||||
|
||||
cv::imwrite("roiMat_front.jpg", roiMat_front);
|
||||
cv::imwrite("roiMat_back.jpg", roiMat_back);
|
||||
|
||||
//二值图像重叠图像颜色取反,膨胀,提取轮廓
|
||||
cv::bitwise_not(mask, mask); //反色
|
||||
|
||||
|
@ -115,9 +98,7 @@ void CImageApplyOutHole::apply(std::vector<cv::Mat>& mats, bool isTwoSide)
|
|||
|
||||
//过滤非孔洞的联通区域
|
||||
std::vector<std::vector<cv::Point>> hole_contours = filterPoly(contours_mask, b1_mask, mask_rotatedRect, m_edgeScale, m_borderSize);
|
||||
//for (size_t i = 0; i < hole_contours.size(); i++)
|
||||
// cv::drawContours(mask, hole_contours, static_cast<int>(i), cv::Scalar(127), 2);
|
||||
//cv::imwrite("mask.jpg", mask);
|
||||
|
||||
cv::Scalar color = getBackGroudColor(front(roi_front), rrect_front.size.area());
|
||||
for (size_t i = 0; i < hole_contours.size(); i++)
|
||||
{
|
||||
|
@ -149,62 +130,73 @@ void CImageApplyOutHole::apply(std::vector<cv::Mat>& mats, bool isTwoSide)
|
|||
#endif // LOG
|
||||
}
|
||||
|
||||
void CImageApplyOutHole::getRoi(cv::RotatedRect rrect_front, cv::RotatedRect rrect_back, cv::Size srcSize,
|
||||
cv::Rect& roi_front, cv::Rect& roi_back, cv::RotatedRect& mask_rotatedRect)
|
||||
void CImageApplyOutHole::getRoi(cv::RotatedRect rrect_front, cv::RotatedRect rrect_back, const cv::Size& srcSize_front, const cv::Size& srcSize_back, cv::Rect& roi_front,
|
||||
cv::Rect& roi_back, cv::RotatedRect& mask_rotatedRect)
|
||||
{
|
||||
cv::Size size(static_cast<int>(rrect_front.size.width + rrect_back.size.width) / 2, static_cast<int>(rrect_front.size.height + rrect_back.size.height) / 2);
|
||||
float angle = (rrect_front.angle + rrect_back.angle) / 2;
|
||||
cv::Rect roi_front_ = rrect_front.boundingRect();
|
||||
cv::Rect roi_back_ = rrect_back.boundingRect();
|
||||
|
||||
rrect_front.size = rrect_back.size = size;
|
||||
rrect_front.angle = rrect_back.angle = angle;
|
||||
cv::Size meanSize = (roi_front_.size() + roi_back_.size()) / 2;
|
||||
roi_front_.x += (roi_front_.width - meanSize.width) / 2;
|
||||
roi_front_.width = meanSize.width;
|
||||
roi_front_.y += (roi_front_.height - meanSize.height) / 2;
|
||||
roi_front_.height = meanSize.height;
|
||||
roi_back_.x += (roi_back_.width - meanSize.width) / 2;
|
||||
roi_back_.width = meanSize.width;
|
||||
roi_back_.y += (roi_back_.height - meanSize.height) / 2;
|
||||
roi_back_.height = meanSize.height;
|
||||
|
||||
roi_front = rrect_front.boundingRect();
|
||||
roi_back = rrect_back.boundingRect();
|
||||
mask_rotatedRect.angle = (rrect_front.angle + rrect_back.angle) / 2;
|
||||
mask_rotatedRect.size = (rrect_front.size + rrect_back.size) / 2.0f;
|
||||
mask_rotatedRect.center = cv::Point2f(roi_front_.size().width + roi_back_.size().width, roi_front_.size().height + roi_back_.size().height) / 4.0f;
|
||||
|
||||
if (roi_front.width != roi_back.width || roi_front.height != roi_back.height)
|
||||
roi_front = roi_front_ & cv::Rect(cv::Point(0, 0), srcSize_front);
|
||||
roi_back = roi_back_ & cv::Rect(cv::Point(0, 0), srcSize_back);
|
||||
|
||||
int offset_left_f = roi_front.x - roi_front_.x;
|
||||
int offset_left_b = roi_back.x - roi_back_.x;
|
||||
int offset_top_f = roi_front.y - roi_front_.y;
|
||||
int offset_top_b = roi_back.y - roi_back_.y;
|
||||
int offset_right_f = roi_front_.br().x - roi_front.br().x;
|
||||
int offset_right_b = roi_back_.br().x - roi_back.br().x;
|
||||
int offset_bottom_f = roi_front_.br().y - roi_front.br().y;
|
||||
int offset_bottom_b = roi_back_.br().y - roi_back.br().y;
|
||||
|
||||
if (offset_left_f > offset_left_b)
|
||||
{
|
||||
roi_front.height = roi_back.height;
|
||||
roi_front.width = roi_back.width;
|
||||
roi_back.x += offset_left_f - offset_left_b;
|
||||
roi_back.width -= offset_left_f - offset_left_b;
|
||||
mask_rotatedRect.center.x -= offset_left_f - offset_left_b;
|
||||
}
|
||||
else
|
||||
{
|
||||
roi_front.x += offset_left_b - offset_left_f;
|
||||
roi_front.width -= offset_left_b - offset_left_f;
|
||||
mask_rotatedRect.center.x -= offset_left_b - offset_left_f;
|
||||
}
|
||||
|
||||
cv::Point offset(0, 0);
|
||||
int top = std::min(roi_front.y, roi_back.y);
|
||||
if (top < 0)
|
||||
if (offset_top_f > offset_top_b)
|
||||
{
|
||||
roi_front.y -= top;
|
||||
roi_back.y -= top;
|
||||
roi_front.height += top;
|
||||
roi_back.height += top;
|
||||
offset.y += top;
|
||||
roi_back.y += offset_top_f - offset_top_b;
|
||||
roi_back.height -= offset_top_f - offset_top_b;
|
||||
mask_rotatedRect.center.y -= offset_top_f - offset_top_b;
|
||||
}
|
||||
else
|
||||
{
|
||||
roi_front.y += offset_top_b - offset_top_f;
|
||||
roi_front.height -= offset_top_b - offset_top_f;
|
||||
mask_rotatedRect.center.y -= offset_top_b - offset_top_f;
|
||||
}
|
||||
|
||||
int left = std::min(roi_front.x, roi_back.x);
|
||||
if (left < 0)
|
||||
{
|
||||
roi_front.x -= left;
|
||||
roi_back.x -= left;
|
||||
roi_front.width += left;
|
||||
roi_back.width += left;
|
||||
offset.x += left;
|
||||
}
|
||||
if (offset_right_f > offset_right_b)
|
||||
roi_back.width -= offset_right_f - offset_right_b;
|
||||
else
|
||||
roi_front.width -= offset_right_b - offset_right_f;
|
||||
|
||||
int right = std::max(roi_front.x + roi_front.width, roi_back.x + roi_back.width);
|
||||
if (right >= srcSize.width)
|
||||
{
|
||||
roi_front.width -= (right - srcSize.width + 1);
|
||||
roi_back.width -= (right - srcSize.width + 1);
|
||||
}
|
||||
|
||||
int bottom = std::max(roi_front.y + roi_front.height, roi_back.y + roi_back.height);
|
||||
if (bottom >= srcSize.height)
|
||||
{
|
||||
roi_front.height -= (bottom - srcSize.height + 1);
|
||||
roi_back.height -= (bottom - srcSize.height + 1);
|
||||
}
|
||||
|
||||
mask_rotatedRect.center = cv::Point((roi_front.width + offset.x) / 2, (roi_front.height + offset.y) / 2);
|
||||
mask_rotatedRect.size = size;
|
||||
mask_rotatedRect.angle = angle;
|
||||
if (offset_bottom_f > offset_bottom_b)
|
||||
roi_back.height -= offset_bottom_f - offset_bottom_b;
|
||||
else
|
||||
roi_front.height -= offset_bottom_b - offset_bottom_f;
|
||||
}
|
||||
|
||||
std::vector<std::vector<cv::Point>> CImageApplyOutHole::filterPoly(std::vector<std::vector<cv::Point>>& contours, const std::vector<cv::Vec4i>& m,
|
||||
|
|
|
@ -10,7 +10,8 @@
|
|||
* 2021/11/03 v1.3 增加逻辑,如果正反面图像尺寸差异超过10个像素,直接返回,不再进行除穿孔处理。
|
||||
* 2021/11/04 v1.4 增加背景抗噪机制,能够抗5像素的背景噪声。
|
||||
* 2021/11/17 v1.5 调整代码格式,避免一些由于opencv版本导致的BUG。
|
||||
* 版本号:v1.5
|
||||
* 2022/04/18 v1.6 修复由于图像超出边界导致的定位孔洞异常的BUG。
|
||||
* 版本号:v1.6
|
||||
|
||||
* ====================================================
|
||||
*/
|
||||
|
@ -20,7 +21,7 @@
|
|||
|
||||
#include "ImageApply.h"
|
||||
|
||||
class CImageApplyOutHole : public CImageApply
|
||||
class CImageApplyOutHole : public CImageApply
|
||||
{
|
||||
public:
|
||||
|
||||
|
@ -53,7 +54,7 @@ private:
|
|||
|
||||
virtual void apply(cv::Mat& pDib, int side);
|
||||
|
||||
void getRoi(cv::RotatedRect rrect_front, cv::RotatedRect rrect_back, cv::Size srcSize, cv::Rect& roi_front,
|
||||
void getRoi(cv::RotatedRect rrect_front, cv::RotatedRect rrect_back, const cv::Size& srcSize_front, const cv::Size& srcSize_back, cv::Rect& roi_front,
|
||||
cv::Rect& roi_back, cv::RotatedRect& mask_rotatedRect);
|
||||
|
||||
std::vector<std::vector<cv::Point> > filterPoly(std::vector<std::vector<cv::Point>>& contours, const std::vector<cv::Vec4i>& m, cv::RotatedRect roi,
|
||||
|
@ -71,4 +72,4 @@ private:
|
|||
double m_threshold;
|
||||
};
|
||||
|
||||
#endif // !IMAGE_APPLY_OUT_HOLE_H
|
||||
#endif // !IMAGE_APPLY_OUT_HOLE_H
|
|
@ -55,9 +55,10 @@ AfxApi CSmartEdit * GetSmartEdit( CWnd *pcwnd, int id )
|
|||
// CSmartEdit implementation
|
||||
|
||||
BEGIN_MESSAGE_MAP(CSmartEdit, CEdit)
|
||||
//{{AFX_MSG_MAP(CSmartEdit)
|
||||
ON_WM_CHAR()
|
||||
ON_CONTROL_REFLECT(EN_UPDATE, OnUpdate)
|
||||
//{{AFX_MSG_MAP(CSmartEdit)
|
||||
ON_WM_CHAR()
|
||||
ON_CONTROL_REFLECT(EN_UPDATE, OnUpdate)
|
||||
ON_WM_KILLFOCUS()
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
@ -186,7 +187,9 @@ void CSmartEdit::OnUpdate()
|
|||
if (m_iValue < m_iMin)
|
||||
{
|
||||
m_iValue = m_iMin;
|
||||
OnBadInput();
|
||||
//OnBadInput();
|
||||
|
||||
error = FALSE;
|
||||
}
|
||||
else if (m_iValue > m_iMax)
|
||||
{
|
||||
|
@ -200,21 +203,28 @@ void CSmartEdit::OnUpdate()
|
|||
if (m_pSlider)
|
||||
m_pSlider->SetSlidePos( m_iValue );
|
||||
|
||||
if( error )
|
||||
{
|
||||
int posn = m_iValue;
|
||||
m_iValue = INT_MIN;
|
||||
UpdateEdit( posn );
|
||||
}
|
||||
if (error)
|
||||
{
|
||||
int posn = m_iValue;
|
||||
m_iValue = INT_MIN;
|
||||
UpdateEdit(posn);
|
||||
}
|
||||
}
|
||||
|
||||
void CSmartEdit::OnKillFocus(CWnd* pNewWnd) {
|
||||
if(m_pSlider)
|
||||
UpdateEdit(m_pSlider->GetPos());
|
||||
CEdit::OnKillFocus(pNewWnd);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int CSmartEdit::UpdateEdit( int position )
|
||||
{
|
||||
CString buffer;
|
||||
|
||||
if( position == m_iValue )
|
||||
return FALSE; // been here already
|
||||
//if( position == m_iValue )
|
||||
// return FALSE; // been here already
|
||||
|
||||
m_iValue = position;
|
||||
if( m_bUseFp )
|
||||
|
@ -265,8 +275,9 @@ int CSmartEdit::SetParams( cint imin, cint imax, cint ticbands )
|
|||
m_iBands = ticbands;
|
||||
m_iMin = imin;
|
||||
m_iMax = imax;
|
||||
m_iRange = m_iMax - m_iMin;
|
||||
InitSlider();
|
||||
m_pSlider->SetTicFreq(m_iRange / m_iBands);
|
||||
m_pSlider ? m_pSlider->SetTicFreq(m_iRange / m_iBands) : void(0);
|
||||
SetFormatString( _T("%d") );
|
||||
WORD type = SES_NUMBERS;
|
||||
if( imin < 0 )
|
||||
|
@ -287,8 +298,8 @@ int CSmartEdit::SetParams( cdbl dmin, cdbl dmax,
|
|||
m_iMin = 0;
|
||||
m_iMax = 1000;
|
||||
InitSlider();
|
||||
m_pSlider->SetTicFreq(100);
|
||||
m_pSlider->SetLineSize(linesize);
|
||||
m_pSlider ? m_pSlider->SetTicFreq(100) : void(0);
|
||||
m_pSlider ? m_pSlider->SetLineSize(linesize) : void(0);
|
||||
SetFormatString( fmtstring );
|
||||
SetParseType( SES_FLOATINGPT );
|
||||
return TRUE;
|
||||
|
|
|
@ -135,6 +135,7 @@ protected:
|
|||
//{{AFX_MSG(CSmartEdit)
|
||||
afx_msg void OnChar(UINT, UINT, UINT);
|
||||
afx_msg void OnUpdate(); // used with a linked slider
|
||||
afx_msg void OnKillFocus(CWnd* pNewWnd);
|
||||
|
||||
//}}AFX_MSG
|
||||
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
#include "Device/UsbScanEx.h"
|
||||
#ifdef WIN32
|
||||
#include <Psapi.h>
|
||||
#include <minidumpapiset.h>
|
||||
#pragma comment (lib,"Dbghelp.lib")
|
||||
#endif // WIN32
|
||||
using namespace std;
|
||||
|
||||
|
@ -64,6 +66,11 @@ enum class CapTypeEx : unsigned short {
|
|||
TwEx_ImageSplit = 0x8108,
|
||||
TwEx_IFadeBack = 0x8109,
|
||||
TwEx_IFadeBackValue = 0x8110,
|
||||
TwEx_IToBeScan = 0x8111,
|
||||
TwEx_IEnMultiOutPut = 0x8112,
|
||||
TwEx_IEnMultiOutPutType = 0x8113,
|
||||
TwEx_IFixedPaper = 0x8114,
|
||||
TwEx_IHighImageQuality = 0x8115,
|
||||
};
|
||||
|
||||
enum class PaperSizeEx : unsigned short {
|
||||
|
@ -91,18 +98,20 @@ using namespace std::placeholders;
|
|||
TWPP_ENTRY_MFC(HuagaoDs)
|
||||
|
||||
static constexpr const Identity srcIdent(
|
||||
Version(3, 3, Language::English, Country::China, "v3.3.5.6"),
|
||||
Version(3, 3, Language::English, Country::China, "v3.3.5.8"),
|
||||
DataGroup::Image,
|
||||
#ifdef MAKEHUAGAO
|
||||
"HUAGO",
|
||||
#elif defined HANVON
|
||||
"HANVON",
|
||||
"Hanvon",
|
||||
#elif defined AUGE
|
||||
"AUGE",
|
||||
#elif defined LANXUM
|
||||
"LANXUM",
|
||||
#elif defined MAKERIGHTWAY
|
||||
"RIGHTWAY",
|
||||
#elif defined NOLOGO
|
||||
"SCAN",
|
||||
#else // MAKEHUAGAO
|
||||
"ZHIBEN",
|
||||
#endif
|
||||
|
@ -112,7 +121,7 @@ static constexpr const Identity srcIdent(
|
|||
#ifdef LANXUM
|
||||
"G62S Series",
|
||||
#elif defined HANVON
|
||||
"HW-8190F Series",
|
||||
"HW-8000",
|
||||
#else // ISG100
|
||||
"G100 Series",
|
||||
#endif
|
||||
|
@ -120,7 +129,7 @@ static constexpr const Identity srcIdent(
|
|||
#ifdef LANXUM
|
||||
"G73S Series",
|
||||
#elif defined HANVON
|
||||
"HW-9110M Series",
|
||||
"HW-9000",
|
||||
#else // ISG100
|
||||
"G200 Series",
|
||||
#endif
|
||||
|
@ -128,8 +137,12 @@ static constexpr const Identity srcIdent(
|
|||
#elif defined(G300) // G200
|
||||
#ifdef LANXUM
|
||||
"G42S Series",
|
||||
#elif defined HANVON
|
||||
"HW-7000W Series",
|
||||
#elif defined HANVON
|
||||
#ifdef ANDROIDSERIAL
|
||||
"HW-1000",
|
||||
#else
|
||||
"HW-1000NS",
|
||||
#endif // ANDROIDSERIAL
|
||||
#else // ISG100
|
||||
"G300 Series",//兼容旧极课 pm changed ,G300 Series
|
||||
#endif
|
||||
|
@ -138,7 +151,11 @@ static constexpr const Identity srcIdent(
|
|||
#ifdef LANXUM
|
||||
"G52S Series",
|
||||
#elif defined HANVON
|
||||
"HW-7000W Series",
|
||||
#ifdef ANDROIDSERIAL
|
||||
"HW-7000",
|
||||
#else
|
||||
"HW-7000NS",
|
||||
#endif // ANDROIDSERIAL
|
||||
#else // ISG100
|
||||
"G400 Series",
|
||||
#endif
|
||||
|
@ -149,10 +166,12 @@ static constexpr const Identity srcIdent(
|
|||
#ifdef ISG100
|
||||
#ifdef MAKEHUAGAO
|
||||
"HUAGOSCAN G100 TWAIN"
|
||||
#elif defined NOLOGO
|
||||
"Scan G100 TWAIN"
|
||||
#elif defined AUGE
|
||||
"AUGESCAN G100 TWAIN"
|
||||
#elif defined HANVON
|
||||
"HANVONSCAN HW-8190F TAWIN"
|
||||
"Hanvon HW-8000 TAWIN"
|
||||
#elif defined LANXUM //!LANXUM
|
||||
"LANXUMSCAN G62S TWAIN"
|
||||
#else // !MAKEHUAGAO
|
||||
|
@ -161,8 +180,10 @@ static constexpr const Identity srcIdent(
|
|||
#else // ISG100
|
||||
#ifdef MAKEHUAGAO
|
||||
"HUAGOSCAN G200 TWAIN"
|
||||
#elif defined NOLOGO
|
||||
"Scan G200 TWAIN"
|
||||
#elif defined HANVON
|
||||
"HANVONSCAN HW-9110M TAWIN"
|
||||
"Hanvon HW-9000 TAWIN"
|
||||
#elif defined LANXUM //!LANXUM
|
||||
"LANXUMSCAN G73S TWAIN"
|
||||
#else // !MAKEHUAGAO
|
||||
|
@ -179,8 +200,13 @@ static constexpr const Identity srcIdent(
|
|||
#elif defined UV && defined MAKERIGHTWAY
|
||||
"RIGHTWAYSCAN G300 TWAIN"
|
||||
#elif defined HANVON
|
||||
"HANVONSCAN HW-7000W TAWIN"
|
||||
|
||||
#ifdef ANDROIDSERIAL
|
||||
"Hanvon HW-1000 TAWIN"
|
||||
#else
|
||||
"Hanvon HW-1000NS TAWIN"
|
||||
#endif // ANDROIDSERIES
|
||||
#elif defined NOLOGO
|
||||
"Scan G300 TWAIN"
|
||||
#elif defined LANXUM //!LANXUM
|
||||
"LANXUMSCAN G42S TWAIN"
|
||||
#else // !MAKEHUAGAO
|
||||
|
@ -190,9 +216,15 @@ static constexpr const Identity srcIdent(
|
|||
#ifdef MAKEHUAGAO
|
||||
"HUAGOSCAN G400 TWAIN"
|
||||
#elif defined HANVON
|
||||
"HANVONSCAN HW-7000W TAWIN"
|
||||
#ifdef ANDROIDSERIAL
|
||||
"Hanvon HW-7000 TAWIN"
|
||||
#else
|
||||
"Hanvon HW-7000NS TAWIN"
|
||||
#endif // ANDROIDSERIES
|
||||
#elif defined LANXUM //!LANXUM
|
||||
"LANXUMSCAN G52S TWAIN"
|
||||
#elif defined NOLOGO
|
||||
"Scan G400 TWAIN"
|
||||
#else // !MAKEHUAGAO
|
||||
"ZhibenScan G400 TWAIN"
|
||||
#endif
|
||||
|
@ -312,6 +344,8 @@ static std::vector<Vid_pid> DeviceID{
|
|||
#endif // ISG100
|
||||
#elif defined G400
|
||||
{0x2903,0x7000},
|
||||
#elif defined G300
|
||||
{0x2903,0x1000},
|
||||
#endif // G200
|
||||
};
|
||||
|
||||
|
@ -328,8 +362,10 @@ static std::vector<Vid_pid> DeviceID{
|
|||
#endif // ISG100
|
||||
#elif defined G300
|
||||
{0x3072,0x0300},
|
||||
{0x3072,0x0339},
|
||||
#elif defined G400
|
||||
{0x3072,0x400},
|
||||
{0x3072,0x0400},
|
||||
{0x3072,0x0439},
|
||||
#endif // ISG100
|
||||
};
|
||||
|
||||
|
@ -358,18 +394,45 @@ static std::unique_ptr<IScanner> scanner; //(new GScanO200());
|
|||
static std::unique_ptr<IScanner> scanner(new GScanVirtual());
|
||||
#endif
|
||||
|
||||
//long __stdcall callback(_EXCEPTION_POINTERS* excp)
|
||||
//{
|
||||
// MessageBox(0, L"Error", L"error", MB_OK);
|
||||
// return EXCEPTION_CONTINUE_SEARCH;
|
||||
//}
|
||||
long __stdcall callback(EXCEPTION_POINTERS* ex)
|
||||
{
|
||||
HANDLE handle = CreateFile((FileTools::get_errorlog_path_w()+L"error.dmp").c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
if(!handle)
|
||||
return EXCEPTION_EXECUTE_HANDLER;
|
||||
MINIDUMP_EXCEPTION_INFORMATION dump;
|
||||
dump.ExceptionPointers = ex;
|
||||
dump.ThreadId = GetCurrentThreadId();
|
||||
dump.ClientPointers = TRUE;
|
||||
MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), handle, MiniDumpWithFullMemory, &dump, NULL, NULL);
|
||||
FatalAppExit(-1, L"TWAIN Error Exit ");
|
||||
return EXCEPTION_EXECUTE_HANDLER;
|
||||
}
|
||||
static std::once_flag oc;
|
||||
HuagaoDs::HuagaoDs()
|
||||
: m_scanparam(new GScanCap)
|
||||
, bmpData(new std::vector<unsigned char>)
|
||||
, hMutex(NULL)
|
||||
{
|
||||
std::call_once(oc, [&]() { log4cplus::Initializer(); });
|
||||
std::call_once(oc, [&]() {
|
||||
log4cplus::Initializer();
|
||||
SetUnhandledExceptionFilter(callback);
|
||||
//void* addr = (void*)GetProcAddress(LoadLibrary(L"kernel32.dll"), "SetUnhandledExceptionFilter"); //重写进程中SetUnhandledExceptionFilter函数地址,后续设置此函数将不再失效
|
||||
//if (addr)
|
||||
//{
|
||||
// uchar code[16];
|
||||
// memset(code, 0, 16);
|
||||
// int size = 0;
|
||||
// code[size++] = 0x33;
|
||||
// code[size++] = 0xc0;
|
||||
// code[size++] = 0xc2;
|
||||
// code[size++] = 0x04;
|
||||
// code[size++] = 0x00;
|
||||
// DWORD dwoldflag, dwtempflag;
|
||||
// VirtualProtect(addr, size, PAGE_READWRITE, &dwoldflag);
|
||||
// WriteProcessMemory(GetCurrentProcess(), addr, code, size, NULL);
|
||||
// VirtualProtect(addr, size, dwoldflag, &dwtempflag);
|
||||
//}
|
||||
});
|
||||
//log4cplus::Initializer();
|
||||
//log4cplus::deinitialize();
|
||||
/*string ss1= getOSInfo();
|
||||
|
@ -380,8 +443,6 @@ HuagaoDs::HuagaoDs()
|
|||
CString aas[10];
|
||||
GetDiskInfo(dwNum,aas);*/
|
||||
|
||||
//SetUnhandledExceptionFilter(callback);
|
||||
|
||||
//memoryinfo.reset(new std::thread([this]() {
|
||||
// PROCESS_MEMORY_COUNTERS pmc;
|
||||
// GetProcessMemoryInfo(GetCurrentProcess(), &pmc, sizeof(pmc));
|
||||
|
@ -405,13 +466,14 @@ void HuagaoDs::showmsg(std::string caption, std::string text, int retcode)
|
|||
{
|
||||
if (scanner.get()) {
|
||||
|
||||
int num = scanner->get_imgnReaded() * (m_scanparam->is_duplex ? 2 : 1) * (m_scanparam->multi_output_red ? 2 : 1) / (m_scanparam->en_fold ? 2 : 1) * (m_scanparam->is_split ? 2 : 1);
|
||||
int num = scanner->get_imgnReaded() * (m_scanparam->is_duplex ? 2 : 1) * (m_scanparam->multi_output_red ? 2 : 1) / (m_scanparam->en_fold ? 2 : 1) * (m_scanparam->is_split ? 2 : 1)
|
||||
* (m_scanparam->en_multi_output ? (m_scanparam->multioutput < 0 ? 1 : (m_scanparam->multioutput == 0 ? 3 : 2)) : 1);
|
||||
int imgread = scanner->get_imgnReaded();
|
||||
IScanner* ptr = scanner.get();
|
||||
if (typeid(*ptr) == typeid(GScanO1003399))
|
||||
{
|
||||
//readnum = readnum / 2 * (m_scanparam->en_fold ? 2 : 1);
|
||||
num = scanner->get_imgnReaded() * (m_scanparam->multi_output_red ? 2 : 1) * (m_scanparam->is_split ? 2 : 1);
|
||||
num = scanner->get_imgnReaded() * (m_scanparam->multi_output_red ? 2 : 1) * (m_scanparam->is_split ? 2 : 1) * (m_scanparam->en_multi_output ? (m_scanparam->multioutput < 0 ? 1 : (m_scanparam->multioutput == 0 ? 3 : 2)) : 1);
|
||||
if(!m_scanparam->en_fold)
|
||||
imgread /= 2;
|
||||
}
|
||||
|
@ -435,6 +497,8 @@ void HuagaoDs::showmsg(std::string caption, std::string text, int retcode)
|
|||
}
|
||||
}
|
||||
}
|
||||
FileTools::kill_process(L"hidedlg.exe");
|
||||
//system("taskkill /f /im hidedlg.exe");
|
||||
ShellExecute(NULL, TEXT("open"), GetHidedlgPath(), CString((text + " " + caption).c_str()), NULL, SW_HIDE);
|
||||
}
|
||||
|
||||
|
@ -843,9 +907,16 @@ void HuagaoDs::dogear_callback(int indexpaper)
|
|||
}
|
||||
|
||||
Result HuagaoDs::identityOpenDs(const Identity&) {
|
||||
|
||||
hMutex = CreateMutex(NULL, FALSE, _T("LookitApp"));
|
||||
if (GetLastError() == ERROR_ALREADY_EXISTS) { //如果已经存在同名的Mutex会得到这个错误.
|
||||
#ifdef G400
|
||||
hMutex = CreateMutex(NULL, FALSE, _T("LookitApp_4"));
|
||||
#elif defined G300
|
||||
hMutex = CreateMutex(NULL, FALSE, _T("LookitApp_3"));
|
||||
#elif defined ISG100
|
||||
hMutex = CreateMutex(NULL, FALSE, _T("LookitApp_1"));
|
||||
#else
|
||||
hMutex = CreateMutex(NULL, FALSE, _T("LookitApp_2"));
|
||||
#endif // G400
|
||||
if (GetLastError() == ERROR_ALREADY_EXISTS) { //如果已经存在同名的Mutex会得到这个错误.
|
||||
CloseHandle(hMutex);
|
||||
hMutex = NULL;
|
||||
//ShellExecute(NULL, TEXT("open"), GetHidedlgPath(), CString("202"), NULL, SW_HIDE);
|
||||
|
@ -871,6 +942,9 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
|
|||
else
|
||||
scanner.reset(new GScanO200());
|
||||
#else
|
||||
if (pid == 0x339 || pid == 0x439)
|
||||
scanner.reset(new GScanO1003399());
|
||||
else
|
||||
#ifdef ANDROIDSERIAL
|
||||
scanner.reset(new GScanO400Android());
|
||||
#else
|
||||
|
@ -1004,6 +1078,11 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
|
|||
if (Msg::Set == msg) {
|
||||
auto mech = data.currentItem<CapType::ICompression>();
|
||||
if (Compression::None == mech || mech == Compression::Group4) {
|
||||
if (mech == Compression::Group4)
|
||||
{
|
||||
if (m_scanparam->pixtype != 0)
|
||||
return badValue();
|
||||
}
|
||||
m_compression = mech;
|
||||
return success();
|
||||
}
|
||||
|
@ -1059,6 +1138,13 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
|
|||
m_scanparam->multi_output_red = 0;//非彩色模式下多流输出不可用
|
||||
m_scanparam->detachnoise.is_detachnoise = false;
|
||||
m_scanparam->fadeback = false;
|
||||
//if (mech == PixelType::BlackWhite)
|
||||
//{
|
||||
// if (m_scanparam->filter == (uint8)Filter::None && m_scanparam->enhance_color == Enchace_Color::Enhance_None)
|
||||
// {
|
||||
// m_scanparam->enhance_color = 1;
|
||||
// }
|
||||
//}
|
||||
}
|
||||
m_iBitdepth = mech == PixelType::Rgb ? 24 : (mech == PixelType::Gray ? 8 : 1);
|
||||
return success();
|
||||
|
@ -1109,7 +1195,7 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
|
|||
CapabilityPrintf(msg, enum2str(CapType::IJpegQuality), msg == Msg::Set ? to_string((int)data.currentItem<CapType::IJpegQuality>()) : "");
|
||||
if (Msg::Set == msg) {
|
||||
auto mech = data.currentItem<CapType::IJpegQuality>();
|
||||
if ((int)mech <= 0 || (int)mech > 100)
|
||||
if ((int)mech < 0 || (int)mech > 100)
|
||||
return badValue();
|
||||
m_jpegQuality = (int)mech;
|
||||
return success();
|
||||
|
@ -1186,6 +1272,7 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
|
|||
if (paper == (BYTE)PaperSize::None || paper == (BYTE)PaperSize::UsStatement) {
|
||||
m_scanparam->paperAlign = PaperAlign::Rot0;
|
||||
m_scanparam->en_sizecheck = 0;
|
||||
m_scanparam->en_fixedpaper = 0;
|
||||
}
|
||||
if (paper == (BYTE)PaperSize::UsStatement) {
|
||||
m_autosize = (UInt16)AutoSize::None;
|
||||
|
@ -1219,23 +1306,39 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
|
|||
};
|
||||
|
||||
#ifdef G200
|
||||
#ifndef ISG100
|
||||
m_query[(CapType)(CapTypeEx::TwEx_SizeDetect)] = msgSupportGetAllSetReset;
|
||||
m_caps[(CapType)(CapTypeEx::TwEx_SizeDetect)] = [this](Msg msg, Capability& data)->Result {
|
||||
CapabilityPrintf(msg, enum2str(CapTypeEx::TwEx_SizeDetect), msg == Msg::Set ? to_string((int)data.currentItem<Bool>()) : "");
|
||||
if (Msg::Set == msg) {
|
||||
if (m_scanparam->papertype == (uint8_t)PaperSize::None || m_scanparam->papertype == (uint8_t)PaperSize::MaxSize || m_scanparam->papertype == (uint8_t)PaperSize::UsStatement ||
|
||||
m_scanparam->papertype == (uint8_t)PaperSizeEx::Trigeminy)
|
||||
return badValue();
|
||||
auto mech = data.currentItem<Bool>();
|
||||
if (mech) {
|
||||
if (m_scanparam->papertype == (uint8_t)PaperSize::None || m_scanparam->papertype == (uint8_t)PaperSize::MaxSize || m_scanparam->papertype == (uint8_t)PaperSize::UsStatement ||
|
||||
m_scanparam->papertype == (uint8_t)PaperSizeEx::Trigeminy)
|
||||
return badValue();
|
||||
}
|
||||
m_scanparam->en_sizecheck = mech;
|
||||
return success();
|
||||
}
|
||||
return CapSupGetAllResetEx<BYTE, Bool, CapType(CapTypeEx::TwEx_SizeDetect)>(msg, data, { FALSE,TRUE }, m_scanparam->en_sizecheck, false, m_scanparam->en_sizecheck, 0);
|
||||
};
|
||||
#endif // !ISG100
|
||||
#endif // G200
|
||||
|
||||
//敦南cis固件幅面扫描
|
||||
m_query[(CapType)(CapTypeEx::TwEx_IFixedPaper)] = msgSupportGetAllSetReset;
|
||||
m_caps[(CapType)(CapTypeEx::TwEx_IFixedPaper)] = [this](Msg msg, Capability& data)->Result {
|
||||
CapabilityPrintf(msg, enum2str(CapTypeEx::TwEx_IFixedPaper), msg == Msg::Set ? to_string((int)data.currentItem<Bool>()) : "");
|
||||
if (Msg::Set == msg) {
|
||||
auto mech = data.currentItem<Bool>();
|
||||
if (mech) {
|
||||
if (m_scanparam->papertype == (uint8_t)PaperSize::None || m_scanparam->papertype == (uint8_t)PaperSize::MaxSize || m_scanparam->papertype == (uint8_t)PaperSize::UsStatement ||
|
||||
m_scanparam->papertype == (uint8_t)PaperSizeEx::Trigeminy)
|
||||
return badValue();
|
||||
}
|
||||
m_scanparam->en_fixedpaper = mech;
|
||||
return success();
|
||||
}
|
||||
return CapSupGetAllResetEx<bool, Bool, CapType(CapTypeEx::TwEx_IFixedPaper)>(msg, data, { false,true }, m_scanparam->en_fixedpaper, false, m_scanparam->en_fixedpaper, 0);
|
||||
};
|
||||
#endif // G200
|
||||
m_query[CapType::IOrientation] = msgSupportGetAllSetReset;
|
||||
m_caps[CapType::IOrientation] = [this](Msg msg, Capability& data) -> Result {
|
||||
CapabilityPrintf(msg, enum2str(CapTypeEx::IOrientation), msg == Msg::Set ? to_string((int)data.currentItem<CapType::IOrientation>()) : "");
|
||||
|
@ -1293,7 +1396,7 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
|
|||
return CapSupGetAllEx<Str255, (CapType)CapTypeEx::TwEx_HardwareVersion>(msg, data, str, str);
|
||||
};
|
||||
|
||||
#ifndef G400
|
||||
|
||||
m_query[(CapType)(CapTypeEx::TwEx_ENCODE)] = msgSupportGetAll;
|
||||
//m_caps[(CapType)(CapTypeEx::TwEx_HardwareVersion)] = std::bind(oneValGetString, _1, _2, scanner->GetFWVersion());
|
||||
m_caps[(CapType)(CapTypeEx::TwEx_ENCODE)] = [this](Msg msg, Capability& data)->Result {
|
||||
|
@ -1301,7 +1404,7 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
|
|||
str.setData(scanner->get_scannercode().c_str(), 32);
|
||||
return CapSupGetAllEx<Str255, (CapType)CapTypeEx::TwEx_ENCODE>(msg, data, str, str);
|
||||
};
|
||||
#endif
|
||||
|
||||
m_query[CapType::FeederLoaded] = msgSupportGetAll;
|
||||
m_caps[CapType::FeederLoaded] = [this](Msg msg, Capability& data) -> Result {
|
||||
CapabilityPrintf(msg, enum2str(CapType::FeederLoaded));
|
||||
|
@ -1441,7 +1544,19 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
|
|||
return success();
|
||||
}
|
||||
//return CapSupGetAllReset<Bool, Bool, CapType::AutoScan>(msg, data, { FALSE,TRUE }, m_autoscan, Bool(true), m_autoscan ? 1 : 0, 0);
|
||||
return CapSupGetAllReset<Bool, Bool, CapType::AutoScan>(msg, data, m_autoscan, FALSE);
|
||||
return CapSupGetAllReset<Bool, Bool, CapType::AutoScan>(msg, data, m_autoscan, TRUE);
|
||||
};
|
||||
|
||||
m_query[CapType(CapTypeEx::TwEx_IHighImageQuality)] = msgSupportGetAllSetReset;
|
||||
m_caps[CapType(CapTypeEx::TwEx_IHighImageQuality)] = [this](Msg msg, Capability& data)->Result {
|
||||
CapabilityPrintf(msg, enum2str(CapTypeEx::TwEx_IHighImageQuality), msg == Msg::Set ? to_string((int)data.currentItem<BOOL>()) : "");
|
||||
if (Msg::Set == msg) {
|
||||
auto tmp = data.currentItem<BOOL>();
|
||||
m_scanparam->is_high_imagequality = tmp;
|
||||
return success();
|
||||
}
|
||||
//return CapSupGetAllReset<Bool, Bool, CapType::AutoScan>(msg, data, { FALSE,TRUE }, m_autoscan, Bool(true), m_autoscan ? 1 : 0, 0);
|
||||
return CapSupGetAllResetEx<bool, Bool, (CapType)CapTypeEx::TwEx_IHighImageQuality>(msg, data, m_scanparam->is_high_imagequality, false);
|
||||
};
|
||||
|
||||
m_query[CapType::IAutoSize] = msgSupportGetAllSetReset;
|
||||
|
@ -1580,10 +1695,14 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
|
|||
CapabilityPrintf(msg, enum2str(CapTypeEx::TwEx_IBackRotate180), msg == Msg::Set ? to_string((int)data.currentItem<Bool>()) : "");
|
||||
if (Msg::Set == msg) {
|
||||
auto mech = data.currentItem<Bool>();
|
||||
if (m_scanparam->is_duplex && mech)
|
||||
m_scanparam->is_backrotate180 = mech;
|
||||
else
|
||||
return badValue();
|
||||
if (mech)
|
||||
{
|
||||
if (!m_scanparam->is_duplex)
|
||||
{
|
||||
return badValue();
|
||||
}
|
||||
}
|
||||
m_scanparam->is_backrotate180 = mech;
|
||||
return success();
|
||||
}
|
||||
return CapSupGetAllResetEx<BYTE, Bool, (CapType)CapTypeEx::TwEx_IBackRotate180>(msg, data, m_scanparam->is_backrotate180, false);
|
||||
|
@ -1685,9 +1804,11 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
|
|||
m_caps[(CapType)(CapTypeEx::TwEx_IDetachNoise)] = [this](Msg msg, Capability& data)->Result {
|
||||
CapabilityPrintf(msg, enum2str(CapTypeEx::TwEx_IDetachNoise), msg == Msg::Set ? to_string((int)data.currentItem<Bool>()) : "");
|
||||
if (Msg::Set == msg) {
|
||||
if (m_scanparam->pixtype != 0)
|
||||
return badValue();
|
||||
auto mech = data.currentItem<Bool>();
|
||||
if (mech) {
|
||||
if (m_scanparam->pixtype != 0)
|
||||
return badValue();
|
||||
}
|
||||
m_scanparam->detachnoise.is_detachnoise = mech;
|
||||
return success();
|
||||
}
|
||||
|
@ -1713,9 +1834,12 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
|
|||
m_caps[(CapType)(CapTypeEx::TwEx_IFadeBack)] = [this](Msg msg, Capability& data)->Result {
|
||||
CapabilityPrintf(msg, enum2str(CapTypeEx::TwEx_IFadeBack), msg == Msg::Set ? to_string((int)data.currentItem<Bool>()) : "");
|
||||
if (Msg::Set == msg) {
|
||||
if (m_scanparam->pixtype != 2)
|
||||
return badValue();
|
||||
auto mech = data.currentItem<Bool>();
|
||||
if (mech)
|
||||
{
|
||||
if (m_scanparam->pixtype != 2)
|
||||
return badValue();
|
||||
}
|
||||
m_scanparam->fadeback = mech;
|
||||
return success();
|
||||
}
|
||||
|
@ -1741,7 +1865,7 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
|
|||
CapabilityPrintf(msg, enum2str(CapTypeEx::TwEx_IMultiOutputRed), msg == Msg::Set ? to_string((int)data.currentItem<Bool>()) : "");
|
||||
if (Msg::Set == msg) {
|
||||
auto mech = data.currentItem<Bool>();
|
||||
if (m_scanparam->pixtype == (BYTE)PixelType::Rgb)
|
||||
if (m_scanparam->pixtype == (BYTE)PixelType::Rgb &&(!m_scanparam->en_multi_output))
|
||||
m_scanparam->multi_output_red = mech;
|
||||
else
|
||||
return badValue();
|
||||
|
@ -1751,14 +1875,48 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
|
|||
return CapSupGetAllResetEx<BYTE, Bool, (CapType)CapTypeEx::TwEx_IMultiOutputRed>(msg, data, m_scanparam->multi_output_red, false);
|
||||
//return CapSupGetAllResetEx<BYTE, Bool, (CapType)CapTypeEx::TwEx_IMultiOutputRed>(msg, data, { FALSE,TRUE }, m_scanparam->multi_output_red, FALSE, m_scanparam->multi_output_red ? 1 : 0, 0);
|
||||
};
|
||||
//多流输出使能
|
||||
m_query[(CapType)(CapTypeEx::TwEx_IEnMultiOutPut)] = msgSupportGetAllSetReset;
|
||||
m_caps[(CapType)(CapTypeEx::TwEx_IEnMultiOutPut)] = [this](Msg msg, Capability& data)->Result {
|
||||
CapabilityPrintf(msg, enum2str(CapTypeEx::TwEx_IEnMultiOutPut), msg == Msg::Set ? to_string((int)data.currentItem<Bool>()) : "");
|
||||
if (Msg::Set == msg) {
|
||||
auto mech = data.currentItem<Bool>();
|
||||
if (m_scanparam->pixtype == (BYTE)PixelType::Rgb && (!m_scanparam->multi_output_red))
|
||||
m_scanparam->en_multi_output = mech;
|
||||
else
|
||||
return badValue();
|
||||
return success();
|
||||
}
|
||||
return CapSupGetAllResetEx<bool, Bool, (CapType)CapTypeEx::TwEx_IEnMultiOutPut>(msg, data, m_scanparam->en_multi_output, false);
|
||||
//return CapSupGetAllResetEx<BYTE, Bool, (CapType)CapTypeEx::TwEx_IEnMultiOutPut>(msg, data, { FALSE,TRUE }, m_scanparam->en_multi_output, FALSE, m_scanparam->en_multi_output ? 1 : 0, 0);
|
||||
};
|
||||
|
||||
//多流输出类型
|
||||
m_query[(CapType)(CapTypeEx::TwEx_IEnMultiOutPutType)] = msgSupportGetAllSetReset;
|
||||
m_caps[(CapType)(CapTypeEx::TwEx_IEnMultiOutPutType)] = [this](Msg msg, Capability& data)->Result {
|
||||
CapabilityPrintf(msg, enum2str(CapTypeEx::TwEx_IEnMultiOutPutType), msg == Msg::Set ? to_string((int)data.currentItem<Int32>()) : "");
|
||||
if (Msg::Set == msg) {
|
||||
auto mech = data.currentItem<Int32>();
|
||||
if (m_scanparam->pixtype == (BYTE)PixelType::Rgb && (!m_scanparam->multi_output_red) && m_scanparam->en_multi_output)
|
||||
m_scanparam->multioutput = mech;
|
||||
else
|
||||
return badValue();
|
||||
return success();
|
||||
}
|
||||
return CapSupGetAllResetEx<int8_t, Int32, (CapType)CapTypeEx::TwEx_IEnMultiOutPutType>(msg, data, m_scanparam->multioutput, 0);
|
||||
};
|
||||
|
||||
//答题卡除红
|
||||
m_query[(CapType)(CapTypeEx::TwEx_HsvCorrect)] = msgSupportGetAllSetReset;
|
||||
m_caps[(CapType)(CapTypeEx::TwEx_HsvCorrect)] = [this](Msg msg, Capability& data)->Result {
|
||||
CapabilityPrintf(msg, enum2str(CapTypeEx::TwEx_HsvCorrect), msg == Msg::Set ? to_string((int)data.currentItem<Bool>()) : "");
|
||||
if (Msg::Set == msg) {
|
||||
auto mech = data.currentItem<Bool>();
|
||||
if (mech && m_scanparam->pixtype != (int)PixelType::Rgb)
|
||||
return badValue();
|
||||
if (mech){
|
||||
if (m_scanparam->pixtype != (int)PixelType::Rgb)
|
||||
return badValue();
|
||||
}
|
||||
|
||||
m_scanparam->hsvcorrect = mech;
|
||||
return success();
|
||||
}
|
||||
|
@ -1822,7 +1980,7 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
|
|||
m_scanparam->sharpen = (BYTE)mech;
|
||||
return success();
|
||||
}
|
||||
return CapSupGetAllResetEx<BYTE, SharpenBlur, (CapType)CapTypeEx::TwEx_Sharpen>(msg, data, m_scanparam->sharpen, SharpenBlur::Sharpen_Normal);
|
||||
return CapSupGetAllResetEx<BYTE, SharpenBlur, (CapType)CapTypeEx::TwEx_Sharpen>(msg, data, m_scanparam->sharpen, SharpenBlur::Sharpen_None);
|
||||
//return CapSupGetAllResetEx<BYTE, SharpenBlur, (CapType)CapTypeEx::TwEx_Sharpen>(msg, data, { SharpenBlur::Sharpen_None,SharpenBlur::Sharpen_Normal,SharpenBlur::Sharpen_More,SharpenBlur::Sharpen_Blur,SharpenBlur::Sharpen_Blur_More }, m_scanparam->sharpen, SharpenBlur::Sharpen_None, m_scanparam->sharpen, 0);
|
||||
};
|
||||
|
||||
|
@ -1972,7 +2130,7 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
|
|||
return badValue();
|
||||
return success();
|
||||
}
|
||||
return CapSupGetAllResetEx<UInt32, UInt32, (CapType)CapTypeEx::TwEx_DogEarDistance>(msg, data, m_scanparam->dogeardistance, 50);
|
||||
return CapSupGetAllResetEx<UInt32, UInt32, (CapType)CapTypeEx::TwEx_DogEarDistance>(msg, data, m_scanparam->dogeardistance, 70);
|
||||
};
|
||||
|
||||
//双张检测 与官方标准定义有所差异 此协议修改为bool型 爱云校使用bool类型,其余使用标准twain协议
|
||||
|
@ -2000,12 +2158,12 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
|
|||
default:
|
||||
return { ReturnCode::Failure, ConditionCode::CapBadOperation };
|
||||
}
|
||||
/*if (Msg::Set == msg) {
|
||||
auto mech = data.currentItem<UInt16>();
|
||||
m_scanparam->hardwarecaps.en_doublefeed = mech ? 1 : 0;
|
||||
return success();
|
||||
}
|
||||
return CapSupGetAllResetEx<BYTE, UInt16, CapType::DoubleFeedDetection>(msg, data, m_scanparam->hardwarecaps.en_doublefeed, TRUE);*/
|
||||
//if (Msg::Set == msg) {
|
||||
// auto mech = data.currentItem<UInt16>();
|
||||
// m_scanparam->hardwarecaps.en_doublefeed = mech ? 1 : 0;
|
||||
// return success();
|
||||
//}
|
||||
//return CapSupGetAllResetEx<BYTE, UInt16, CapType::DoubleFeedDetection>(msg, data, m_scanparam->hardwarecaps.en_doublefeed, TRUE);
|
||||
};
|
||||
|
||||
#ifdef G200
|
||||
|
@ -2023,6 +2181,20 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
|
|||
// { LowPowerMode::Min_None,LowPowerMode::Min_5,LowPowerMode::Min_10,LowPowerMode::Min_20, LowPowerMode::Min_30, LowPowerMode::Min_60, LowPowerMode::Min_120, LowPowerMode::Min_240 },
|
||||
// m_scanparam->hardwarecaps.lowpowermode, LowPowerMode::Min_30, (BYTE)m_scanparam->hardwarecaps.lowpowermode, 4);
|
||||
};
|
||||
//待纸扫描
|
||||
m_query[(CapType)(CapTypeEx::TwEx_IToBeScan)] = msgSupportGetAllSetReset;
|
||||
m_caps[(CapType)(CapTypeEx::TwEx_IToBeScan)] = [this](Msg msg, Capability& data)->Result {
|
||||
CapabilityPrintf(msg, enum2str(CapTypeEx::TwEx_IToBeScan), msg == Msg::Set ? to_string((float)data.currentItem<BOOL>()) : "");
|
||||
if (Msg::Set == msg) {
|
||||
auto mech = data.currentItem<BOOL>();
|
||||
m_scanparam->hardwarecaps.is_autopaper = mech;
|
||||
if (mech)
|
||||
m_scanparam->scannum = -1;
|
||||
return success();
|
||||
}
|
||||
return CapSupGetAllResetEx<uint8_t, BOOL, (CapType)CapTypeEx::TwEx_IToBeScan>(msg, data, m_scanparam->hardwarecaps.is_autopaper, FALSE);
|
||||
};
|
||||
|
||||
#endif // LANXUM
|
||||
|
||||
m_query[(CapType)(CapTypeEx::TwEx_CropModel)] = msgSupportGetAllSetReset;
|
||||
|
@ -2081,6 +2253,7 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
|
|||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
return success();
|
||||
}
|
||||
|
||||
|
@ -2142,7 +2315,8 @@ Result HuagaoDs::pendingXfersEnd(const Identity&, PendingXfers& data) {
|
|||
{
|
||||
if (!(m_scanparam->is_autodiscradblank_normal || m_scanparam->is_autodiscradblank_vince))
|
||||
{
|
||||
int num = scanner->get_scannum() * (m_scanparam->is_duplex ? 2 : 1) * (m_scanparam->multi_output_red ? 2 : 1) / (m_scanparam->en_fold ? 2 : 1) * (m_scanparam->is_split ? 2 : 1);
|
||||
int num = scanner->get_scannum() * (m_scanparam->is_duplex ? 2 : 1) * (m_scanparam->multi_output_red ? 2 : 1) / (m_scanparam->en_fold ? 2 : 1) * (m_scanparam->is_split ? 2 : 1)
|
||||
* (m_scanparam->en_multi_output ? (m_scanparam->multioutput < 0 ? 1 : (m_scanparam->multioutput == 0 ? 3 : 2)) : 1);
|
||||
if ((num - scanner->get_imgTransfered()) != 0)
|
||||
{
|
||||
showmsg("提示", msgs[LOSE_IMAGE]);
|
||||
|
@ -2211,13 +2385,13 @@ Result HuagaoDs::userInterfaceEnable(const Identity&, UserInterface& ui) {
|
|||
if (!ui.showUi()) {
|
||||
// this is an exception when we want to set state explicitly, notifyXferReady can be called only in enabled state
|
||||
// with hidden UI, the usual workflow DsState::Enabled -> notifyXferReady() -> DsState::XferReady is a single step
|
||||
#ifndef G200
|
||||
while (!scanner->Get_Scanner_PaperOn())
|
||||
{
|
||||
if (MessageBox(NULL, L"检测到无纸,请添加纸张", L"提示", MB_YESNO | MB_SYSTEMMODAL) == IDNO)
|
||||
return seqError();
|
||||
}
|
||||
#endif // !G200
|
||||
//#ifndef G200
|
||||
// while (!scanner->Get_Scanner_PaperOn())
|
||||
// {
|
||||
// if (MessageBox(NULL, L"检测到无纸,请添加纸张", L"提示", MB_YESNO | MB_SYSTEMMODAL) == IDNO)
|
||||
// return seqError();
|
||||
// }
|
||||
//#endif // !G200
|
||||
|
||||
if (!scanner->IsConnected())
|
||||
scanner->open(vid, pid);
|
||||
|
@ -2249,7 +2423,8 @@ Result HuagaoDs::userInterfaceEnableUiOnly(const Identity&, UserInterface& ui) {
|
|||
|
||||
Result HuagaoDs::imageInfoGet(const Identity&, ImageInfo& data) {
|
||||
// our image does not change
|
||||
if (m_pendingXfers == 0 || bmpData->size() == 0)
|
||||
//if (m_pendingXfers == 0 || bmpData->size() == 0)
|
||||
if(bmpData->size() == 0)
|
||||
return success();
|
||||
auto dib = header();
|
||||
data.setBitsPerPixel(static_cast<Int16>(dib->biBitCount));
|
||||
|
@ -2347,6 +2522,8 @@ Result HuagaoDs::imageMemXferGet(const Identity& origin, ImageMemXfer& data) {
|
|||
|
||||
auto lock = data.memory().data();
|
||||
char* out = lock.data();
|
||||
|
||||
auto bmpsize = bmpData->size();
|
||||
// bottom-up BMP -> top-down memory transfer
|
||||
if (m_compression == Compression::None)
|
||||
{
|
||||
|
@ -2358,7 +2535,6 @@ Result HuagaoDs::imageMemXferGet(const Identity& origin, ImageMemXfer& data) {
|
|||
char* line = out;
|
||||
out += bpl;
|
||||
begin -= bpl;
|
||||
|
||||
if (dib->biBitCount == 24)
|
||||
{
|
||||
//BGR BMP -> RGB memory transfer
|
||||
|
@ -2378,7 +2554,7 @@ Result HuagaoDs::imageMemXferGet(const Identity& origin, ImageMemXfer& data) {
|
|||
if (m_memXferYOff >= static_cast<UInt32>(std::abs(dib->biHeight))) {
|
||||
m_pendingXfers = 0;
|
||||
m_memXferYOff = 0;
|
||||
bmpData.reset(new std::vector<unsigned char>);
|
||||
//bmpData.reset(new std::vector<unsigned char>);
|
||||
return { ReturnCode::XferDone, ConditionCode::Success };
|
||||
}
|
||||
|
||||
|
@ -2498,7 +2674,12 @@ Twpp::Result HuagaoDs::imageFileXferGet(const Twpp::Identity& origin)
|
|||
std::vector<int> compression_params;
|
||||
compression_params.push_back(CV_IMWRITE_JPEG_QUALITY);
|
||||
compression_params.push_back(m_jpegQuality);
|
||||
cv::imwrite(filename, ims, compression_params);
|
||||
std::vector<uchar> imgdate;
|
||||
cv::imencode(".jpg", ims, imgdate, compression_params);
|
||||
std::ofstream out(filename,std::ios::binary | std::ios::out | std::ios::trunc);
|
||||
if (out.is_open())
|
||||
out.write((const char*)imgdate.data(), imgdate.size()),out.close();
|
||||
//cv::imwrite(filename, ims, compression_params);
|
||||
}
|
||||
bmpData.reset(new std::vector<unsigned char>);
|
||||
ims.release();
|
||||
|
@ -2531,20 +2712,20 @@ Twpp::Result HuagaoDs::showTwainUI(Twpp::UserInterface& ui, bool bUiOnly)
|
|||
if (!scanner->IsConnected())
|
||||
return checkDeviceOnline();
|
||||
}
|
||||
#ifndef G200
|
||||
while (!scanner->Get_Scanner_PaperOn())
|
||||
{
|
||||
if (scanner->get_ErrorCode() == SLEEPING) {
|
||||
showmsg("提示", msgs[(UsbSupported)81]);
|
||||
scanner->Set_ErrorCode(0);
|
||||
return seqError();
|
||||
}
|
||||
if (MessageBox(NULL, L"检测到无纸,请添加纸张", L"提示", MB_YESNO | MB_SYSTEMMODAL) == IDNO) {
|
||||
m_pendingXfers = 0;
|
||||
return seqError();
|
||||
}
|
||||
}
|
||||
#endif // !G200
|
||||
//#ifndef G200
|
||||
// while (!scanner->Get_Scanner_PaperOn())
|
||||
// {
|
||||
// if (scanner->get_ErrorCode() == SLEEPING) {
|
||||
// showmsg("提示", msgs[(UsbSupported)81]);
|
||||
// scanner->Set_ErrorCode(0);
|
||||
// return seqError();
|
||||
// }
|
||||
// if (MessageBox(NULL, L"检测到无纸,请添加纸张", L"提示", MB_YESNO | MB_SYSTEMMODAL) == IDNO) {
|
||||
// m_pendingXfers = 0;
|
||||
// return seqError();
|
||||
// }
|
||||
// }
|
||||
//#endif // !G200
|
||||
m_pendingXfers = 1;
|
||||
m_scanparam.reset(new GScanCap(caps));
|
||||
saveGscanCapSetting();
|
||||
|
@ -2686,7 +2867,7 @@ Twpp::Result HuagaoDs::startScan()
|
|||
// if (!scanner->IsConnected())
|
||||
// return checkDeviceOnline();
|
||||
//}
|
||||
|
||||
bmpData.reset(new std::vector<unsigned char>());
|
||||
scanner->ResetScanner();
|
||||
scanner->reset();
|
||||
FileTools::writelog(log_INFO, "start scan");
|
||||
|
@ -2712,8 +2893,8 @@ Twpp::Result HuagaoDs::startScan()
|
|||
config.setrollermsgdata(chrono::duration_cast<chrono::duration<int, ratio<24 * 60 * 60>>>(chrono::system_clock::now().time_since_epoch()).count());
|
||||
}
|
||||
}
|
||||
//m_scanparam->brightness = -142;
|
||||
//m_scanparam->contrast = 1000; // 小闲专用
|
||||
//m_scanparam->brightness =300; // 楚雄一中 500 - 142
|
||||
//m_scanparam->contrast = 0; // 小闲专用
|
||||
scanner->config_params(*m_scanparam);
|
||||
std::string info = "papertype= " + to_string(m_scanparam->papertype) +
|
||||
"\nAutoCrop_threshold= " + to_string(m_scanparam->AutoCrop_threshold) +
|
||||
|
@ -2746,6 +2927,8 @@ Twpp::Result HuagaoDs::startScan()
|
|||
"\nis_switchfrontback = " + to_string(m_scanparam->is_switchfrontback) +
|
||||
"\nis_dogeardetection = " + to_string(m_scanparam->is_dogeardetection) +
|
||||
"\nmulti_output_red = " + to_string(m_scanparam->multi_output_red) +
|
||||
"\nen_multi_output = " + to_string(m_scanparam->en_multi_output) +
|
||||
"\nmultioutput = " + to_string(m_scanparam->multioutput) +
|
||||
"\nnoise = " + to_string(m_scanparam->noise) +
|
||||
"\npaperAlign = " + to_string(m_scanparam->paperAlign) +
|
||||
"\npixtype = " + to_string(m_scanparam->pixtype) +
|
||||
|
@ -2754,22 +2937,6 @@ Twpp::Result HuagaoDs::startScan()
|
|||
"\nsharpen = " + to_string(m_scanparam->sharpen);
|
||||
FileTools::writelog(log_TRACE,info);
|
||||
|
||||
if (m_bIndicator) {
|
||||
//!< cancel button push
|
||||
auto stopFunc = [this]() {
|
||||
if (scanner.get())
|
||||
scanner->Stop_scan();
|
||||
//guiIndicator.reset();//取消扫描 关闭进度指示器
|
||||
if (guiTwain.get()) {
|
||||
((CTwainUI*)(guiTwain.get()))->EnableID_OKorID_Cancel(true);
|
||||
}
|
||||
onDeviceEvent(USER_STOP);
|
||||
};
|
||||
guiIndicator = new CIndicatorDlg(stopFunc);
|
||||
scanner->regist_indicatortext_callback([this](int aquire, int updata) { if (guiIndicator->GetSafeHwnd()) guiIndicator->setindicatortext(aquire, updata); });
|
||||
guiIndicator->Create(IDD_INDICATOR, guiTwain.get() ? guiTwain.get() : guiBridge.get());//guiTwain ? guiTwain.get() : guiBridge.get()
|
||||
guiIndicator->ShowWindow(SW_SHOWNORMAL);
|
||||
}
|
||||
scanner->UpdateScanInfo(0, 0);
|
||||
scanner->Scanner_StartScan(m_scanparam->scannum);
|
||||
if (bmpData->size() > 0)
|
||||
|
@ -2780,6 +2947,28 @@ Twpp::Result HuagaoDs::startScan()
|
|||
((CTwainUI*)(guiTwain.get()))->EnableID_OKorID_Cancel(false);
|
||||
}
|
||||
int retCode = scanner->aquire_bmpdata(*bmpData.get());
|
||||
if (retCode == 0)
|
||||
{
|
||||
if (m_bIndicator) {
|
||||
//!< cancel button push
|
||||
auto stopFunc = [this]() {
|
||||
if (scanner.get())
|
||||
scanner->Stop_scan();
|
||||
//guiIndicator.reset();//取消扫描 关闭进度指示器
|
||||
if (guiTwain.get()) {
|
||||
((CTwainUI*)(guiTwain.get()))->EnableID_OKorID_Cancel(true);
|
||||
}
|
||||
onDeviceEvent(USER_STOP);
|
||||
};
|
||||
guiIndicator = new CIndicatorDlg(stopFunc);
|
||||
scanner->regist_indicatortext_callback([this](int aquire, int updata)
|
||||
{ if (guiIndicator->GetSafeHwnd())
|
||||
guiIndicator->setindicatortext(aquire, updata);
|
||||
});
|
||||
guiIndicator->Create(IDD_INDICATOR, guiTwain.get() ? guiTwain.get() : guiBridge.get());//guiTwain ? guiTwain.get() : guiBridge.get()
|
||||
guiIndicator->ShowWindow(SW_SHOWNORMAL);
|
||||
}
|
||||
}
|
||||
if (retCode != 0) {
|
||||
scanner->Set_ErrorCode(0);
|
||||
if (guiIndicator->GetSafeHwnd())
|
||||
|
|
Binary file not shown.
Binary file not shown.
BIN
huagao/stdafx.h
BIN
huagao/stdafx.h
Binary file not shown.
Loading…
Reference in New Issue