diff --git a/huagao/CAboutDlg.cpp b/huagao/CAboutDlg.cpp index 33e97b73..44f0d28d 100644 --- a/huagao/CAboutDlg.cpp +++ b/huagao/CAboutDlg.cpp @@ -63,12 +63,14 @@ BOOL CAboutDlg::OnInitDialog() HBITMAP hBitmap = ::LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BITMAP4)); #elif defined MAKERIGHTWAY HBITMAP hBitmap = ::LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BITMAP5)); +#elif defined CUMTENN + HBITMAP hBitmap = ::LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BITMAP7)); #else HBITMAP hBitmap = ::LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BMPABOUTDLG)); #endif pStatic->ModifyStyle(0xF, SS_BITMAP | SS_CENTERIMAGE); pStatic->SetBitmap(hBitmap); -#if defined MAKEHUAGAO || defined LANXUM || defined HANVON || defined AUGE ||defined MAKERIGHTWAY +#if defined MAKEHUAGAO || defined LANXUM || defined HANVON || defined AUGE ||defined MAKERIGHTWAY || defined CUMTENN GetDlgItem(IDC_PICABOUTHUAGO)->ShowWindow(TRUE); #else GetDlgItem(IDC_PICABOUTHUAGO)->ShowWindow(FALSE); diff --git a/huagao/CBasicPage.cpp b/huagao/CBasicPage.cpp index bfd7e2a2..e62cdbd8 100644 --- a/huagao/CBasicPage.cpp +++ b/huagao/CBasicPage.cpp @@ -156,7 +156,7 @@ BOOL CBasicPage::OnInitDialog() m_cmBoxDuplex = (CComboBox*)GetDlgItem(IDC_CMBDUPLEX); m_Edit_Dpi.SetSlideLink(this, IDC_SLIDERDPI); - m_Edit_Dpi.SetParams(100, 600, 10); + m_Edit_Dpi.SetParams(100, 300, 10); m_Edit_Dpi.SetValue(200); for (const CString& colorMode : color_Modes) @@ -323,7 +323,18 @@ void CBasicPage::updateCmbDuplex(BOOL insert) GetDlgItem(IDC_CKFIXEDPAPER)->EnableWindow(false); } else { - GetDlgItem(IDC_CKBSIZEDETECT)->EnableWindow(true); + if (m_Slider_Dpi.m_iPosition >= 500) { + if (m_hdVersion.size() > 9 && m_hdVersion.substr(2, 2) == "39") + { + if ((m_hdVersion[5] == 'B' && atoi(m_hdVersion.substr(6, 4).c_str()) > 429) || (m_hdVersion[5] > 'B')) { + GetDlgItem(IDC_CKBSIZEDETECT)->EnableWindow(true); + } + } + } + else { + GetDlgItem(IDC_CKBSIZEDETECT)->EnableWindow(true); + } + GetDlgItem(IDC_CKFIXEDPAPER)->EnableWindow(true); } @@ -336,6 +347,39 @@ void CBasicPage::OnNMReleasedcaptureSliderdpi(NMHDR* pNMHDR, LRESULT* pResult) // TODO: 在此添加控件通知处理程序代码 if(pResult!=nullptr) *pResult = 0; + if (m_Slider_Dpi.m_iPosition >= 500) { + if (m_hdVersion.size() > 9 && m_hdVersion.substr(2, 2) == "39") + { + if ((m_hdVersion[5] == 'B' && atoi(m_hdVersion.substr(6, 4).c_str()) > 429) || (m_hdVersion[5] > 'B')) { + int tmp_paperindex = m_cmBoxSS->GetCurSel(); +#ifndef G300 + if (!(tmp_paperindex == 19 || tmp_paperindex == 20 || tmp_paperindex == 21 || tmp_paperindex == 22 || tmp_paperindex == 1 || tmp_paperindex == 4 || tmp_paperindex == 5)) { +#else + if (!(tmp_paperindex == 8 || tmp_paperindex == 1 || tmp_paperindex == 9 || tmp_paperindex == 10)) { +#endif // G200 + ((CButton*)GetDlgItem(IDC_CKBSIZEDETECT))->EnableWindow(TRUE); + } + } + else + { + ((CButton*)GetDlgItem(IDC_CKBSIZEDETECT))->EnableWindow(FALSE); + ((CButton*)GetDlgItem(IDC_CKBSIZEDETECT))->SetCheck(FALSE); + } + } + } + else + { + int tmp_paperindex = m_cmBoxSS->GetCurSel(); +#ifndef G300 + if (!(tmp_paperindex == 19 || tmp_paperindex == 20 || tmp_paperindex == 21 || tmp_paperindex == 22 || tmp_paperindex == 1 || tmp_paperindex == 4 || tmp_paperindex == 5)) { +#else + if (!(tmp_paperindex == 8 || tmp_paperindex == 1 || tmp_paperindex == 9 || tmp_paperindex == 10)) { +#endif // G200 + ((CButton*)GetDlgItem(IDC_CKBSIZEDETECT))->EnableWindow(TRUE); + } + } + + if (m_Slider_Dpi.m_iPosition >= 500) { ((CButton*)GetDlgItem(IDC_RDQUALITYPRIORITY))->EnableWindow(FALSE); ((CButton*)GetDlgItem(IDC_RDSPEEDPRIORITY))->EnableWindow(FALSE); @@ -348,8 +392,8 @@ void CBasicPage::OnNMReleasedcaptureSliderdpi(NMHDR* pNMHDR, LRESULT* pResult) ((CButton*)GetDlgItem(IDC_RDSPEEDPRIORITY))->EnableWindow(TRUE); } - if (((m_Slider_Dpi.m_iPosition >= 300 && ((CButton*)GetDlgItem(IDC_RDQUALITYPRIORITY))->GetCheck()) || - (m_Slider_Dpi.m_iPosition >= 500 && ((CButton*)GetDlgItem(IDC_RDSPEEDPRIORITY))->GetCheck())) && + 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) { @@ -367,8 +411,8 @@ void CBasicPage::OnNMReleasedcaptureSliderdpi(NMHDR* pNMHDR, LRESULT* pResult) m_cmBoxSS->DeleteString(20); #endif // G300 } - else if (((m_Slider_Dpi.m_iPosition < 300 && ((CButton*)GetDlgItem(IDC_RDQUALITYPRIORITY))->GetCheck()) || - (m_Slider_Dpi.m_iPosition < 500 && ((CButton*)GetDlgItem(IDC_RDSPEEDPRIORITY))->GetCheck())) && + 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) { diff --git a/huagao/CImageProcPage.cpp b/huagao/CImageProcPage.cpp index 8b6195df..487e96d7 100644 --- a/huagao/CImageProcPage.cpp +++ b/huagao/CImageProcPage.cpp @@ -57,8 +57,9 @@ CImageProcPage::~CImageProcPage() { } -void CImageProcPage::ImageProcPageUpdate(int val,int twss, int cmduplexsel,bool is_Crop) +void CImageProcPage::ImageProcPageUpdate(int val,int twss, int cmduplexsel,bool is_Crop,int dpi) { + this->dpi = dpi; this->twss = twss; this->cmduplexsel = cmduplexsel; CComboBox* m_temp = (CComboBox*)(GetDlgItem(IDC_CMBFILTER)); @@ -76,8 +77,17 @@ 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()); + if (dpi >= 500) { + GetDlgItem(IDC_CHMULTIPUT)->EnableWindow(FALSE); + ((CButton*)GetDlgItem(IDC_CHMULTIPUT))->SetCheck(FALSE); + GetDlgItem(IDC_CMBMULTIOUT)->EnableWindow(FALSE); + ((CButton*)GetDlgItem(IDC_CMBMULTIOUT))->SetCheck(FALSE); + } + else + { + GetDlgItem(IDC_CHMULTIPUT)->EnableWindow(TRUE); + GetDlgItem(IDC_CMBMULTIOUT)->EnableWindow(((CButton*)GetDlgItem(IDC_CHMULTIPUT))->GetCheck()); + } } else { GetDlgItem(IDC_CKHSVCORRECT)->EnableWindow(FALSE); @@ -356,7 +366,9 @@ void CImageProcPage::OnBnClickedCkmultioutput() } else { - GetDlgItem(IDC_CMBMULTIOUT)->EnableWindow(FALSE); - GetDlgItem(IDC_CHMULTIPUT)->EnableWindow(TRUE); + if (dpi < 500) { + GetDlgItem(IDC_CMBMULTIOUT)->EnableWindow(FALSE); + GetDlgItem(IDC_CHMULTIPUT)->EnableWindow(TRUE); + } } } diff --git a/huagao/CImageProcPage.h b/huagao/CImageProcPage.h index 0153e5b7..3c216689 100644 --- a/huagao/CImageProcPage.h +++ b/huagao/CImageProcPage.h @@ -30,7 +30,7 @@ public: BOOL m_ckbRemoveHole; BOOL m_ckbHSVCorrect; BOOL m_ckbDetachNoise; - void ImageProcPageUpdate(int val,int twss,int cmduplexsel, bool is_Crop); + void ImageProcPageUpdate(int val,int twss,int cmduplexsel, bool is_Crop,int dpi); void ImageAutoDescrewUpdate(int val); void EnableOutHoleCheckChanged(BOOL enable); void SetOutHoleValue(int value); @@ -41,6 +41,7 @@ public: int threshold; int twss; int cmduplexsel; + int dpi; bool is_convex; bool is_crop; bool is_bw; diff --git a/huagao/CTwainUI.cpp b/huagao/CTwainUI.cpp index 9e162a10..f06641d1 100644 --- a/huagao/CTwainUI.cpp +++ b/huagao/CTwainUI.cpp @@ -54,13 +54,15 @@ BOOL CTwainUI::OnInitDialog() this->SetWindowText(TWAIN_NAME); auto dataChangeFunction = [this]() { - m_pageImageProc->ImageProcPageUpdate(m_pageBasic->m_cmBoxColorMode->GetCurSel(),m_pageBasic->m_cmBoxSS->GetCurSel(),m_pageBasic->m_cmBoxDuplex->GetCurSel(), - (getcombox_ss(m_pageBasic->m_cmBoxSS->GetCurSel())== TwSS::USStatement)||(getcombox_ss(m_pageBasic->m_cmBoxSS->GetCurSel()) == TwSS::None)); - m_pageFeedPaper->FeedPaperPageUpdate(m_pageBasic->m_cmBoxDuplex->GetCurSel()); - m_pageImageProc->ImageAutoDescrewUpdate(m_pageBasic->m_cmBoxSS->GetCurSel()); - //m_pageFeedPaper->FeedAutoDescrewUpdate(m_pageBasic->m_cmBoxSS->GetCurSel()); - UpdateUi(); - m_pageBasic->OnNMReleasedcaptureSliderdpi(nullptr, nullptr); + if (m_pageBasic.get() && m_pageImageProc.get() && m_pageBrightness.get() && m_pageFeedPaper.get()) { + m_pageImageProc->ImageProcPageUpdate(m_pageBasic->m_cmBoxColorMode->GetCurSel(), m_pageBasic->m_cmBoxSS->GetCurSel(), m_pageBasic->m_cmBoxDuplex->GetCurSel(), + (getcombox_ss(m_pageBasic->m_cmBoxSS->GetCurSel()) == TwSS::USStatement) || (getcombox_ss(m_pageBasic->m_cmBoxSS->GetCurSel()) == TwSS::None), m_pageBasic->m_Slider_Dpi.m_iPosition); + m_pageFeedPaper->FeedPaperPageUpdate(m_pageBasic->m_cmBoxDuplex->GetCurSel()); + m_pageImageProc->ImageAutoDescrewUpdate(m_pageBasic->m_cmBoxSS->GetCurSel()); + //m_pageFeedPaper->FeedAutoDescrewUpdate(m_pageBasic->m_cmBoxSS->GetCurSel()); + UpdateUi(); + m_pageBasic->OnNMReleasedcaptureSliderdpi(nullptr, nullptr); + } }; int nPageID = 0; @@ -77,10 +79,6 @@ BOOL CTwainUI::OnInitDialog() m_tabCtrl->AddSSLPage(_T("送纸"), nPageID++, m_pageFeedPaper.get()); CString title(m_confirmtitle.c_str()); this->GetDlgItem(IDC_CONFIRM)->SetWindowText(title); - UpdateUI(); - UpdateListConfig(); - dataChangeFunction(); - setvisable_sleepmode(false); #ifdef G200 if (m_hardwareVersion.size() > 9 && m_hardwareVersion.substr(2,2) == "39") { @@ -99,12 +97,17 @@ BOOL CTwainUI::OnInitDialog() setvisable_fixedpaper(false); setvisable_dogear(true); setvisable_size(true); + if ((m_hardwareVersion[5] == 'B' && atoi(m_hardwareVersion.substr(6, 4).c_str()) >= 430) || (m_hardwareVersion[5] > 'B')) + m_pageBasic->m_Edit_Dpi.SetParams(100, 600, 10); } else { setvisable_dogear(false); setvisable_size(false); setvisable_autopaper(false); setvisable_fixedpaper(false); + + ((CButton*)m_pageBasic->GetDlgItem(IDC_RDQUALITYPRIORITY))->ShowWindow(SW_HIDE); + ((CButton*)m_pageBasic->GetDlgItem(IDC_RDSPEEDPRIORITY))->ShowWindow(SW_HIDE); } #else #ifndef ANDROIDSERIAL @@ -119,15 +122,30 @@ BOOL CTwainUI::OnInitDialog() } setvisable_dogear(true); setvisable_size(true); - setvisable_fixedpaper(true); + setvisable_fixedpaper(false); + m_pageBasic->m_Edit_Dpi.SetParams(100, 600, 10); } 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))) + + if (atoi(m_hardwareVersion.substr(4, 6).c_str()) >= 220401) + { setvisable_size(true); + } else + { setvisable_size(false); + } + ((CButton*)m_pageBasic->GetDlgItem(IDC_RDQUALITYPRIORITY))->ShowWindow(SW_HIDE); + ((CButton*)m_pageBasic->GetDlgItem(IDC_RDSPEEDPRIORITY))->ShowWindow(SW_HIDE); +#ifdef G400 + if (atoi(m_hardwareVersion.substr(4, 6).c_str()) >= 220117) + { + ((CButton*)m_pageBasic->GetDlgItem(IDC_RDQUALITYPRIORITY))->ShowWindow(SW_SHOW); + ((CButton*)m_pageBasic->GetDlgItem(IDC_RDSPEEDPRIORITY))->ShowWindow(SW_SHOW); + } +#endif // G400 + setvisable_dogear(false); setvisable_autopaper(false); setvisable_fixedpaper(false); } @@ -136,9 +154,17 @@ BOOL CTwainUI::OnInitDialog() setvisable_size(false); setvisable_autopaper(false); setvisable_fixedpaper(false); + ((CButton*)m_pageBasic->GetDlgItem(IDC_RDQUALITYPRIORITY))->ShowWindow(SW_HIDE); + ((CButton*)m_pageBasic->GetDlgItem(IDC_RDSPEEDPRIORITY))->ShowWindow(SW_HIDE); #endif #endif // G200 //setvisable_fixedpaper(false); + + + UpdateUI(); + UpdateListConfig(); + dataChangeFunction(); + setvisable_sleepmode(false); return true; } @@ -154,12 +180,14 @@ BEGIN_MESSAGE_MAP(CTwainUI, CDialogEx) ON_BN_CLICKED(IDC_BTNRECOVERYCONFIG, &CTwainUI::OnBnClickedBtnrecoveryconfig) ON_LBN_SELCHANGE(IDC_LSTCONFIG, &CTwainUI::OnLbnSelchangeLstconfig) ON_WM_CLOSE() + ON_NOTIFY(NM_CLICK, IDC_TAB, &CTwainUI::OnNMClickTab) END_MESSAGE_MAP() void CTwainUI::OnBnClickedConfirm() { // TODO: 在此添加控件通知处理程序代码 + OnNMClickTab(nullptr, nullptr); CONFIGPARAMS cfg = { 0 }; UpDateScanParam(&cfg); m_glue.m_scan(*settings); @@ -323,7 +351,7 @@ void CTwainUI::UpdateUI() m_pageFeedPaper->UpdateData(FALSE); m_pageBasic->updateCmbDuplex(TRUE); m_pageImageProc->ImageProcPageUpdate(m_pageBasic->m_cmBoxColorMode->GetCurSel(), m_pageBasic->m_cmBoxSS->GetCurSel(), m_pageBasic->m_cmBoxDuplex->GetCurSel(), - (getcombox_ss(m_pageBasic->m_cmBoxSS->GetCurSel()) == TwSS::USStatement) || (getcombox_ss(m_pageBasic->m_cmBoxSS->GetCurSel()) == TwSS::None)); + (getcombox_ss(m_pageBasic->m_cmBoxSS->GetCurSel()) == TwSS::USStatement) || (getcombox_ss(m_pageBasic->m_cmBoxSS->GetCurSel()) == TwSS::None),m_pageBasic->m_Slider_Dpi.m_iPosition); } void CTwainUI::UpdateFilterCmbx() @@ -877,3 +905,15 @@ LRESULT CTwainUI::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) return CDialogEx::WindowProc(message, wParam, lParam); } + + + +void CTwainUI::OnNMClickTab(NMHDR* pNMHDR, LRESULT* pResult) +{ + // TODO: 在此添加控件通知处理程序代码 + //*pResult = 0; + m_pageImageProc->ImageProcPageUpdate(m_pageBasic->m_cmBoxColorMode->GetCurSel(), m_pageBasic->m_cmBoxSS->GetCurSel(), m_pageBasic->m_cmBoxDuplex->GetCurSel(), + (getcombox_ss(m_pageBasic->m_cmBoxSS->GetCurSel()) == TwSS::USStatement) || (getcombox_ss(m_pageBasic->m_cmBoxSS->GetCurSel()) == TwSS::None), + m_pageBasic->m_Slider_Dpi.m_iPosition); + +} diff --git a/huagao/CTwainUI.h b/huagao/CTwainUI.h index 027083fb..da171909 100644 --- a/huagao/CTwainUI.h +++ b/huagao/CTwainUI.h @@ -230,4 +230,6 @@ private: std::string m_confirmtitle; virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); +public: + afx_msg void OnNMClickTab(NMHDR* pNMHDR, LRESULT* pResult); }; diff --git a/huagao/Device/GScan.h b/huagao/Device/GScan.h index bca92d0d..ee46a078 100644 --- a/huagao/Device/GScan.h +++ b/huagao/Device/GScan.h @@ -124,7 +124,11 @@ static map msgs = { {UsbSupported::USB_BULK_ERROR,"USBݶȡ"}, {UsbSupported::V4L2_AQULRE_ERROR,"ɨȡͼʧܣ"}, {UsbSupported::V4L2_IMAGE_EMPTY,"ɨͼ쳣"}, - {UsbSupported::SLEEPING,"豸ģʽ밴Դرߣ"}, +#ifdef G200 + {UsbSupported::SLEEPING,"豸ģʽֶ豸"}, +#else + {UsbSupported::SLEEPING,"豸ģʽΪ豸"}, +#endif // G200 {UsbSupported::HAVE_DOGEAR,"⵽۽ǣֹͣɨ裡"}, {UsbSupported::MLTOP_TIMEOUT,"̨̧δָλã"}, {UsbSupported::PAPER_HOLE,"ֽпףʹôģʽɨ裡"}, diff --git a/huagao/Device/GScanO1003399.cpp b/huagao/Device/GScanO1003399.cpp index 09025aad..2ce64a70 100644 --- a/huagao/Device/GScanO1003399.cpp +++ b/huagao/Device/GScanO1003399.cpp @@ -231,6 +231,7 @@ std::uint32_t GScanO1003399::GetMotorFPGA() fw.resize(scanner_read_reg(m_usb, SR_GET_MBVERSION_LENGHT)); scanner_write_reg(m_usb, SR_GET_MBVERSION,0); m_usb->read_bulk(&fw[0], fw.size()); + //read_data(&fw[0], fw.length(), 200); } return atoi(fw.c_str()); } @@ -295,7 +296,14 @@ void GScanO1003399::config_params(GScanCap& param) //cfg.g200params.is_fixedpaper = param.en_fixedpaper; cfg.g200params.is_fixedpaper = true; //220513 重影问题默认固定幅面采集 cfg.g200params.en_anlogic_key = true; - + +#ifdef G200 + if ((fwversion[5] == 'A' && (atoi(fwversion.substr(6, 4).c_str()) > 1220)) || (fwversion[5] == 'B' && (atoi(fwversion.substr(6, 4).c_str()) <= 430))) + { + if (param.resolution_dst == 500) + param.resolution_dst = 501; + } +#endif // G200 config_scanparam(cfg); config_imgprocparam({sizeof(GScanCap_3399)}); GScanCap_3399 param39{ 0 }; @@ -336,6 +344,10 @@ void GScanO1003399::config_params(GScanCap& param) 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.is_high_imagequality? param.resolution_native : (param.resolution_dst >= 500.0f ? 300.0f : 200.0f); + if (param39.resolution_dst >= 300 && param39.resolution_dst < 500) + param39.noise = param39.noise * 1.5; + else if(param39.resolution_dst>=500) + param39.noise = param39.noise * 3; param39.scannum = param.scannum; param39.sharpen = param.sharpen; param39.threshold = param.threshold; @@ -773,6 +785,8 @@ void GScanO1003399::imgproce(std::shared_ptr>& buff) _tcscat(szIniFile, _T("\\twain_32\\HanvonScan\\tessdata\\osd.traineddata")); #elif defined MAKERIGHTWAY _tcscat(szIniFile, _T("\\twain_32\\RIGHTWAYSCAN\\tessdata\\osd.traineddata")); +#elif defined CUMTENN + _tcscat(szIniFile, _T("\\twain_32\\CumTennScan\\tessdata\\osd.traineddata")); #elif defined NOLOGO _tcscat(szIniFile, _T("\\twain_32\\Scan\\tessdata\\osd.traineddata")); #else @@ -1045,8 +1059,8 @@ void GScanO1003399::proc(bool bcachemode) } buffer = imgs.Take(); } - //if (m_param.resolution_dst > 500) - // std::this_thread::sleep_for(std::chrono::milliseconds(4399)); + if (m_param.resolution_dst > 500) + std::this_thread::sleep_for(std::chrono::milliseconds(4399)); imgproce(buffer); } } diff --git a/huagao/Device/GScanO200.cpp b/huagao/Device/GScanO200.cpp index c1cf5b40..a1db8cd6 100644 --- a/huagao/Device/GScanO200.cpp +++ b/huagao/Device/GScanO200.cpp @@ -210,7 +210,7 @@ int GScanO200::aquire_bmpdata(std::vector& bmpdata) if (m_pImages->empty()) { DoEvents(); std::this_thread::sleep_for(std::chrono::milliseconds(10)); - if (sw.elapsed_s() > 30.00) + if (sw.elapsed_s() > 60.00) { if (m_threadUsb && m_threadUsb->joinable()) { devState = DEV_STOP; @@ -607,7 +607,7 @@ void GScanO200::usbmain() break; } - if (sw.elapsed_ms() > 30000) + if (sw.elapsed_ms() > 60000) { m_pImages->setscanflags(false); //devState = haveError ? DevState::DEV_WRONG : DevState::DEV_STOP; diff --git a/huagao/Device/GScanO400.cpp b/huagao/Device/GScanO400.cpp index 1ce20107..c7e2685f 100644 --- a/huagao/Device/GScanO400.cpp +++ b/huagao/Device/GScanO400.cpp @@ -12,135 +12,135 @@ //u32_CMD typedef enum tagUsbKeyWords : UINT32 { - //无命令 + // NO_COMMAND = 0, - //获取dsp 状态 + //ȡdsp ״̬ GET_DSP_STATUS = 1, - //取图 + //ȡͼ GET_IMAGE = 2, - //销毁DSP中驻存的图 + //DSPפͼ POP_IMAGE = 3, - //开始扫描命令 + //ʼɨ START_COMMAND = 4, - //停止扫描命令 + //ֹͣɨ STOP = 5, - //获取扫描仪扫描模式 + //ȡɨɨģʽ GET_SCAN_MODE = 6, - //获取固件版本号 + //ȡ̼汾 GET_FW_VERSION = 7, - //返回PC端的状态 + //PC˵״̬ SEND_STATUS_PC = 8, - //下发扫描配置参数 + //·ɨò CONFIGURED_DATA = 9, - //下发固件信息 + //·̼Ϣ SEND_FW = 10, - //获取扫描参数 + //ȡɨ GET_CONFIG_DATA = 11, - //获取扫描总张数 + //ȡɨ GET_SCANN_NUM = 12, - //获取有无纸的状态 + //ȡֽ״̬ GET_PAPERFEEDER_STATUS = 13, - //DSP初始化 + //DSPʼ INIT_HARDWARE_SYS = 14, - //获取有无纸的状态 + //ȡֽ״̬ GET_PAPER_STATUS = 0x0d, - //下发元器件配置参数(灰度,LED R曝光时间) + //·ԪòҶȣLED Rعʱ䣩 SEND_COMPONENTS_GR = 15, - //下发元器件配置参数(LED G/B曝光时间) + //·ԪòLED G/Bعʱ䣩 SEND_COMPONENTS_GB = 16, - //下发扫描模式 + //·ɨģʽ SEND_SCAN_MODE = 17, - //开始进行平场矫正 + //ʼƽ START_FLAT = 18, - //停止平场矫正 + //ֹͣƽ STOP_FLAT = 19, - //下发200dpi彩色平场矫正参数 + //·200dpiɫƽ SEND_200_COLOR_FLAT_DATA = 20, - //下发300dpi彩色平场矫正参数 + //·300dpiɫƽ SEND_300_COLOR_FLAT_DATA = 21, - //获取200dpi彩色平场矫正参数 + //ȡ200dpiɫƽ GET_200_COLOR_FLAT_DATA = 22, - //获取300dpi彩色平场矫正参数 + //ȡ300dpiɫƽ GET_300_COLOR_FLAT_DATA = 23, - //下发200dpi灰度平场校正参数 + //·200dpiҶƽУ SEND_200_GRAY_FLAT_DATA = 24, - //下发300dpi灰度平场校正参数 + //·300dpiҶƽУ SEND_300_GRAY_FLAT_DATA = 25, - //获取200DPI灰度平场校正参数 + //ȡ200DPIҶƽУ GET_200_GRAY_FLAT_DATA = 26, - //获取300DPI灰度平场校正参数 + //ȡ300DPIҶƽУ GET_300_GRAY_FLAT_DATA = 27, - //下发序列号命令 + //·к SEND_SERIAL = 28, - //获取序列号命令 + //ȡк GET_SERIAL = 29, - //获取滚轴数 + //ȡ GET_ROLLER_NUM = 0x1e, - //清零滚轴数 + // CLR_ROLLER_NUM = 0x1f, - //清除扫描总张数 + //ɨ CLR_SCAN_NUM = 0x20, - //准备更新固件 + //׼¹̼ PRE_UPGRADE = 0X21, - //开始更新固件 + //ʼ¹̼ START_UPGRADE = 0x22, - //彩色的AD参数 + //ɫAD RGB_ADI_PARA = 0x23, - //灰度的AD参数 + //ҶȵAD ADI_PARA = 0x24, - //获取CIS参数(曝光时间,ad参数) + //ȡCISعʱ䣬ad) GET_CIS_PARA = 0x25, - //扫描张数 + //ɨ START_COMMAND_COUNT = 0x26, - //下发休眠时间 + //·ʱ SET_SLEEP_TIME = 0x27, - //获取休眠时间 + //ȡʱ GET_SLEEP_TIME = 0x28, - //清除缓存 + // CLR_CACHE = 0x29, - //下发速度模式 + //·ٶģʽ SET_SPEED_MODE = 0x2a, - //获取扫描速度模式 + //ȡɨٶģʽ GET_SPEED_MODE = 0X2b, - //设置固件版本一共8个字节 + //ù̼汾һ8ֽ SET_FW_VERSION = 0X2c, - //获取DSP版本 + //ȡDSP汾 GET_DSP_VERSION = 0X2d, - //采集板FPGA固件版本 + //ɼFPGA̼汾 GET_SCANFPGA_VERSION = 0x2e, - //电机板FPGA固件版本 + //FPGA̼汾 GET_MOTORFPGA_VERSION = 0X2f, - //设置制造商信息 + //Ϣ SET_USB_INFOR_MANUFACTURE = 0X30, - //获取制造商信息 + //ȡϢ GET_USB_INFOR_MANUFACTURE = 0X31, - //设置产品型号信息 + //òƷͺϢ SET_USB_INFOR_MODEL_NAME = 0X32, - //获取产品型号信息 + //ȡƷͺϢ GET_USB_INFOR_MODEL_NAME = 0X33, - //设置USB PID / VID信息 + //USB PID / VIDϢ SET_USB_INFOR_VIDPID = 0X34, GET_USB_INFOR_VIDPID = 0X35, - //设置卡纸急停检测灵敏度 + //ÿֽͣ SET_JAM_DETECT_SENSITIVE = 0X36, - //获取卡纸急停检测灵敏度 + //ȡֽͣ GET_JAM_DETECT_SENSITIVE = 0X37, - //设置横向畸变系数 + //úϵ SET_JUST_COF_H = 0x38, - //读取横向畸变系数 + //ȡϵ GET_JUST_COF_H = 0x39, - CLEAR_HWERROR = 0x40,//G400 清除硬件异常 - //设置纵向畸变系数 + CLEAR_HWERROR = 0x40,//G400 Ӳ쳣 + //ϵ SET_JUST_COF_V = 0x41, - //读取纵向畸变系数 + //ȡϵ GET_JUST_COF_V = 0x42, - //设置扫描仪编码 + //ɨDZ GET_CODE_G400 = 0x59, - //读取扫描仪编码 + //ȡɨDZ SET_CODE_G400 = 0x60, - //设置扫描仪编码 + //ɨDZ SET_CODE_G200 = 0x63, - //读取扫描仪编码 + //ȡɨDZ GET_CODE_G200 = 0x64, } UsbKeyWords, * PUsbKeyWords; @@ -184,6 +184,11 @@ void GScanO400::open(int vid, int pid) m_usb = *usbs.begin(); m_usb->set_usbhotplug_callback(usbhotplug_callback, this); bool ret = m_usb->open(); + if (notifyscan() < 1) + { + Set_ErrorCode(SLEEPING); + return; + } USBCB status = { GET_DSP_STATUS ,0,0 }; if (m_usb.get() && m_usb->is_connected()) { @@ -206,7 +211,7 @@ int GScanO400::aquire_bmpdata(std::vector& bmpdata) if (m_pImages->empty()) { DoEvents(); this_thread::sleep_for(chrono::milliseconds(1)); - if (sw.elapsed_s() > 30.00) + if (sw.elapsed_s() > 60.00) { int roller_num_new = Get_Roller_num(); if (m_threadUsb && m_threadUsb->joinable()) { @@ -215,7 +220,7 @@ int GScanO400::aquire_bmpdata(std::vector& bmpdata) m_threadUsb.reset(); FileTools::writelog(log_ERROR, "aquire_bmpdata m_threadUsb.reset()"); } - Stop_scan();//停止扫描 + Stop_scan();//ֹͣɨ ResetScanner(); set_scannum(abs(roller_num_new - roller_num)); return HARDWARE_ERROR; @@ -371,6 +376,7 @@ void GScanO400::config_params(GScanCap& params) if (params.papertype == 52 || params.papertype == 54 || params.papertype == 131 || params.papertype == 0) cfgdata = (cfgdata & 0xffffffe0) + 18; } +#ifdef G400 if (atoi(fw.substr(4, 6).c_str()) >= 220117) { int dpi = 1; @@ -406,6 +412,7 @@ void GScanO400::config_params(GScanCap& params) } } else +#endif // G400 params.resolution_native = 200.0f; gcap = params; USBCB usbcb = { CONFIGURED_DATA,cfgdata,0 }; @@ -493,7 +500,8 @@ int GScanO400::notifyscan() m_usb->read_bulk(¬ify, sizeof(notify)); if ((notify.u32_Data != 0x10 && GetFWVersion().length() < 10) || notify.u32_Data == 0x100) { - ShellExecute(NULL, TEXT("open"), GetHidedlgPath(), CString("扫描仪处于休眠状态,请按电源键唤醒! 提示 "), NULL, SW_HIDE); + std::string text = msgs[UsbSupported::SLEEPING]; + ShellExecute(NULL, TEXT("open"), GetHidedlgPath(), CString((text).c_str()), NULL, SW_HIDE); return -1; } return 1; @@ -587,6 +595,7 @@ std::string GScanO400::get_scannercode() { if (!(m_usb.get() && m_usb->is_connected())) return NULL; + //return "12345678901234567890123456789012"; USBCB usb{ GET_CODE_G400,0,32 }; m_usb->write_bulk(&usb, sizeof(USBCB)); std::this_thread::sleep_for(std::chrono::milliseconds(20)); @@ -653,7 +662,7 @@ void GScanO400::usbmain() this_thread::sleep_for(chrono::milliseconds(200)); break; } - if (sw.elapsed_ms() > 30000) + if (sw.elapsed_ms() > 60000) { m_pImages->setscanflags(false); Set_ErrorCode(AQUIRE_IMAGE_TIMEOUT); @@ -702,7 +711,7 @@ void GScanO400::usbmain() UpdateScanInfo(countNReaded(), get_imgTransfered()); #endif Pop_Image(); - FileTools::writelog(log_INFO, "从扫描仪接收" + to_string(get_imgnReaded()) + "份文件。耗时 " + to_string(sw.elapsed_ms())); + FileTools::writelog(log_INFO, "ɨǽ" + to_string(get_imgnReaded()) + "ļʱ " + to_string(sw.elapsed_ms())); sw.reset(); break; } @@ -779,8 +788,9 @@ std::shared_ptr> GScanO400::Get_Img_Data(int bufferSize) std::this_thread::sleep_for(std::chrono::microseconds(20)); while (startindex < bufferSize) { - startindex += m_usb->read_bulk(imData->data() + startindex, (bufferSize - startindex) < totalength ? (bufferSize - startindex) : totalength); //数据接收量必须小于等于管道内数据量,否则会接收失败 + startindex += m_usb->read_bulk(imData->data() + startindex, (bufferSize - startindex) < totalength ? (bufferSize - startindex) : totalength); //ݽСڵڹܵʧ std::this_thread::sleep_for(std::chrono::microseconds(10)); + FileTools::writelog(log_ERROR, "usb read buffer "+to_string(startindex)); } if (sw.elapsed_ms() > 5000) { diff --git a/huagao/Device/ImageMatQueue.cpp b/huagao/Device/ImageMatQueue.cpp index 5e448d1a..96eadb4d 100644 --- a/huagao/Device/ImageMatQueue.cpp +++ b/huagao/Device/ImageMatQueue.cpp @@ -7,6 +7,7 @@ #include #include "StopWatch.h" #include "ImageProcess/ImageMulti.h" +#include using namespace cv; @@ -164,7 +165,7 @@ void ImageMatQueue::setparam(const GScanCap& param) m_iaList.clear(); - if (scanParam.fillhole.is_fillhole) { + if (scanParam.fillhole.is_fillhole && scanParam.resolution_dst < 500) { float ratio = scanParam.fillhole.fillholeratio / 100.0; m_iaList.push_back(shared_ptr(new CImageApplyOutHole(200, ratio, 50))); } //确保能够获取正反两面图 @@ -335,6 +336,8 @@ void ImageMatQueue::setparam(const GScanCap& param) _tcscat(szIniFile, _T("\\twain_32\\RIGHTWAYSCAN\\tessdata\\osd.traineddata")); #elif defined NOLOGO _tcscat(szIniFile, _T("\\twain_32\\Scan\\tessdata\\osd.traineddata")); +#elif defined CUMTENN + _tcscat(szIniFile, _T("\\twain_32\\CumTennScan\\tessdata\\osd.traineddata")); #else _tcscat(szIniFile, _T("\\twain_32\\HuaGoScan\\tessdata\\osd.traineddata")); #endif // @@ -396,6 +399,7 @@ void ImageMatQueue::cache_run() auto buffs = m_rawBuffs.Take()->getImageBuffs(); buffs.size() == 2 ? info.scannerType = ScannerSerial::G200Serial : info.scannerType = ScannerSerial::G400Serial; + for (auto& buf : buffs) { StopWatch sw; @@ -530,222 +534,93 @@ void ImageMatQueue::proc() FileTools::writelog(log_ERROR, msg); continue; } - - ImreadModes rmc; - if (scanParam.filter != 3 || scanParam.enhance_color || scanParam.hsvcorrect) - rmc = IMREAD_COLOR; - else - rmc = scanParam.pixtype == 2 ? IMREAD_COLOR : IMREAD_GRAYSCALE; - - std::vector mats; - std::vector uvmats; - StopWatch sw; - if (info.scannerType == ScannerSerial::G200Serial) - { - auto back = m_imgCacheinfo.Take(); - if (!isFileExist(back.path)) - { - msg = "error while reading g200 back image " + back.path + " ,file not exist"; - FileTools::writelog(log_ERROR, msg); - } - sw.reset(); - cv::Mat imgfront = imread(info.path, rmc); - msg = "reading image front time elapsed_ms:" + std::to_string(sw.elapsed_ms()); - FileTools::writelog(log_DEBUG, msg); - sw.reset(); - cv::Mat imgback = imread(back.path, rmc); - msg = "reading image back time elapsed_ms:" + std::to_string(sw.elapsed_ms()); - FileTools::writelog(log_DEBUG, msg); - sw.reset(); - if (!imgfront.empty() && !imgback.empty()) - { - if (scanParam.imageRotateDegree != 0.0 && scanParam.imageRotateDegree != 180.0) { - cv::flip(imgback, imgback, 0); - cv::flip(imgback, imgback, 1); - } - mats.push_back(scanParam.is_switchfrontback ? imgback : imgfront); - mats.push_back(scanParam.is_switchfrontback ? imgfront : imgback); - remove(info.path.c_str()); - remove(back.path.c_str()); - } - else - { - msg = "get empty mat! empty "; - msg += (imgfront.empty() ? " front image" : " back image"); - FileTools::writelog(log_ERROR, msg); - } - - for (size_t i = 0; i < mats.size(); i++) - { - if (!mats[i].empty()) - cv::resize(mats[i], mats[i], cv::Size(), fx, fy);//用于修正与佳能机器幅面大小不匹配问题 此系数请勿轻易动 - } - - //if (scanParam.en_fold != 0) { //对折前旋转屏蔽 20211214 奥鸽要求 - // cv::flip(mats[0], mats[0], 1); - // cv::flip(mats[0], mats[0], 0); - //} - } - else - { - auto mat = imread(info.path, rmc); - //cv::imwrite("D:\\img"+to_string(indeximg++)+".jpg", mat); - //auto mat = imread(info.path, IMREAD_COLOR); - //if (rmc == IMREAD_GRAYSCALE) - // cvtColor(mat, mat, CV_RGB2GRAY); - if (!mat.empty()) - { - Mat front = mat(Rect(0, 0, mat.cols / 2, mat.rows-10));//避免图像尾部出现无效数据丢弃10行数据 - Mat back = mat(Rect(mat.cols / 2, 0, mat.cols / 2, mat.rows-10));//避免图像尾部出现无效数据丢弃10行数据 - if (scanParam.imageRotateDegree != 0.0 && scanParam.imageRotateDegree != 180.0) { - cv::flip(front, front, 0); - cv::flip(front, front, 1); - } -#ifdef UV - mats.push_back(scanParam.is_switchfrontback ? front : back); - mats.push_back(scanParam.is_switchfrontback ? back : front); -#else - - - mats.push_back(scanParam.is_switchfrontback ? front : back); - mats.push_back(scanParam.is_switchfrontback ? back : front); -#endif - front.release(); - back.release(); - remove(info.path.c_str()); - } - else - { - msg = "g400 get empty mat! empty "; - FileTools::writelog(log_ERROR, msg); - } -#ifdef UV - if (scanParam.hardwarecaps.en_uv)//EN UV - { - auto uvinfo = m_imgCacheinfo.Take(); - auto matuv = imread(uvinfo.path, IMREAD_COLOR); - if (!matuv.empty()) - { - Mat front = matuv(Rect(0, 0, mat.cols / 2, mat.rows)); - Mat back = matuv(Rect(mat.cols / 2, 0, mat.cols / 2, mat.rows)); - if (scanParam.imageRotateDegree != 0.0 && scanParam.imageRotateDegree != 180.0) { - cv::flip(front, front, 0); - cv::flip(front, front, 1); - } - uvmats.push_back(scanParam.is_switchfrontback ? front : back); - uvmats.push_back(scanParam.is_switchfrontback ? back : front); - front.release(); - back.release(); - remove(uvinfo.path.c_str()); - } - } -#endif - }//g400 serials - FileTools::writelog(log_DEBUG, " start image process "); - std::vector rects; - std::vector angleResults; - bool isDesaskew = false; - sw.reset(); - for (int j = 0; j < m_iaList.size(); j++) { - m_iaList[j]->apply(mats, scanParam.is_duplex); - CImageApply* ptr = m_iaList[j].get(); - if (typeid(*ptr) == typeid(CImageApplyAutoCrop)) - { - rects = dynamic_cast(ptr)->rotatedROIs(); - isDesaskew = dynamic_cast(ptr)->isDesaskew(); - } - else if (typeid(*ptr) == typeid(CImageApplyRotation)) - angleResults = dynamic_cast(ptr)->angleResults(); - } - -#ifdef UV - if (!uvmats.empty()) - { - //拼接原图和UV图 - for (int j = 0; j < mats.size(); j++) - { - if (!scanParam.is_duplex && j == 1) { - mats[j].release(); - break; - } - if (!mats[j].empty()) - { - cv::Mat mergeOrgin_UV = ImageApplyUV::Apply(mats[j], uvmats[j], rects[j], isDesaskew, angleResults.size() > 0 ? angleResults[j] : 0, scanParam.pixtype); - if (!mergeOrgin_UV.empty()) - mats[j] = mergeOrgin_UV; - } - } - rects.clear(); - uvmats.clear(); - } -#endif - FileTools::writelog(log_DEBUG, " image process finish"); - if (!scanParam.is_duplex && mats.size()>1) { - mats.pop_back(); - } - if (scanParam.is_split) - { - splitimg(mats); - } - for (int i = 0; i < mats.size(); i++) { - if (!mats[i].empty()) { - IMat2Bmp idata; -#ifdef UV - if (scanParam.pixtype == 1 && mats[i].channels() == 3)//gray - cv::cvtColor(mats[i], mats[i], COLOR_BGR2GRAY); -#else - if (scanParam.pixtype == 1 && scanParam.hsvcorrect) - if (mats[i].channels() == 3) - cvtColor(mats[i], mats[i], cv::COLOR_BGR2GRAY); -#endif - 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 - { - FileTools::writelog(log_ERROR, "enqueue image is empty " + std::to_string(index++)); - } - } - - if (scanParam.multi_output_red) { - for (int i = 0; i < mats.size(); i++) { - if (!mats[i].empty()) { - ImageMultiOutput m_mlt; - Mat ret = m_mlt.GetMultiFilterMat(mats[i], 2); - mats[i].release(); - if (!ret.empty()) { - if (!scanParam.is_duplex && i == 1) { - ret.release(); - break; - } - Mat2Bmp mb(ret, scanParam.resolution_dst); - auto data = mb.getBmpDataBuffer(); - ret.release(); - EnqueueBmpBuffer(data); - data.reset(); - } - } - } - } - - mats.clear(); -#ifdef UV - PaniusCount(scanParam.hardwarecaps.en_uv ? 2 : 1); -#else - PaniusCount(); -#endif + //if(scanParam.resolution_dst < 500) + duplex_process(info); + //else { + // ImreadModes rmc; + // if (scanParam.filter != 3 || scanParam.enhance_color || scanParam.hsvcorrect) + // rmc = IMREAD_COLOR; + // else + // rmc = scanParam.pixtype == 2 ? IMREAD_COLOR : IMREAD_GRAYSCALE; + // StopWatch sw; + // cv::Mat imgfront; + // cv::Mat imgback; + // if (info.scannerType == G200Serial) + // { + // auto back = m_imgCacheinfo.Take(); + // if (!isFileExist(back.path)) + // { + // msg = "error while reading g200 back image " + back.path + " ,file not exist"; + // FileTools::writelog(log_ERROR, msg); + // } + // imgfront = imread(info.path, rmc); + // msg = "reading image front time elapsed_ms:" + std::to_string(sw.elapsed_ms()); + // FileTools::writelog(log_DEBUG, msg); + // sw.reset(); + // imgback = imread(back.path, rmc); + // msg = "reading image back time elapsed_ms:" + std::to_string(sw.elapsed_ms()); + // FileTools::writelog(log_DEBUG, msg); + // sw.reset(); + // if (!imgfront.empty() && !imgback.empty()) + // { + // if (scanParam.imageRotateDegree != 0.0 && scanParam.imageRotateDegree != 180.0) { + // cv::flip(imgback, imgback, 0); + // cv::flip(imgback, imgback, 1); + // } + // cv::resize(imgback, imgback, cv::Size(), fx, fy);//用于修正与佳能机器幅面大小不匹配问题 此系数请勿轻易动 + // cv::resize(imgfront, imgfront, cv::Size(), fx, fy); + // remove(info.path.c_str()); + // remove(back.path.c_str()); + // } + // else + // { + // msg = "get empty mat! empty "; + // msg += (imgfront.empty() ? " front image" : " back image"); + // FileTools::writelog(log_ERROR, msg); + // } + // } + // else + // { + // auto mat = imread(info.path, rmc); + // if (!mat.empty()) + // { + // imgfront = mat(Rect(0, 0, mat.cols / 2, mat.rows - 10));//避免图像尾部出现无效数据丢弃10行数据 + // imgback = mat(Rect(mat.cols / 2, 0, mat.cols / 2, mat.rows - 10));//避免图像尾部出现无效数据丢弃10行数据 + // if (scanParam.imageRotateDegree != 0.0 && scanParam.imageRotateDegree != 180.0) { + // cv::flip(imgfront, imgfront, 0); + // cv::flip(imgfront, imgfront, 1); + // } + // mat.release(); + // remove(info.path.c_str()); + // } + // else + // { + // msg = "g400 get empty mat! empty "; + // FileTools::writelog(log_ERROR, msg); + // } + // } + // if (!imgfront.empty() && !imgback.empty()) { + // if (scanParam.is_duplex) + // { + // single_process(scanParam.is_switchfrontback ? imgback : imgfront); + // imgfront.release(); + // std::this_thread::sleep_for(std::chrono::milliseconds(4399)); + // //::SetProcessWorkingSetSize(GetCurrentProcess(), -1, -1); + // //::EmptyWorkingSet(GetCurrentProcess()); + // single_process(scanParam.is_switchfrontback ? imgfront : imgback); + // std::this_thread::sleep_for(std::chrono::milliseconds(4399)); + // imgback.release(); + // } + // else + // { + // imgback.release(); + // single_process(imgfront); + // std::this_thread::sleep_for(std::chrono::milliseconds(4399)); + // imgfront.release(); + // } + // } + // PaniusCount(); + //} } } @@ -768,6 +643,286 @@ void ImageMatQueue::splitimg(std::vector& mats) { mats.swap(tmp); } +void ImageMatQueue::duplex_process(CacheInfo info) +{ + std::string msg; + ImreadModes rmc; + if (scanParam.filter != 3 || scanParam.enhance_color || scanParam.hsvcorrect) + rmc = IMREAD_COLOR; + else + rmc = scanParam.pixtype == 2 ? IMREAD_COLOR : IMREAD_GRAYSCALE; + + std::vector mats; + std::vector uvmats; + StopWatch sw; + if (info.scannerType == ScannerSerial::G200Serial) + { + auto back = m_imgCacheinfo.Take(); + if (!isFileExist(back.path)) + { + msg = "error while reading g200 back image " + back.path + " ,file not exist"; + FileTools::writelog(log_ERROR, msg); + } + sw.reset(); + cv::Mat imgfront = imread(info.path, rmc); + msg = "reading image front time elapsed_ms:" + std::to_string(sw.elapsed_ms()); + FileTools::writelog(log_DEBUG, msg); + sw.reset(); + cv::Mat imgback = imread(back.path, rmc); + msg = "reading image back time elapsed_ms:" + std::to_string(sw.elapsed_ms()); + FileTools::writelog(log_DEBUG, msg); + sw.reset(); + if (!imgfront.empty() && !imgback.empty()) + { + if (scanParam.imageRotateDegree != 0.0 && scanParam.imageRotateDegree != 180.0) { + cv::flip(imgback, imgback, 0); + cv::flip(imgback, imgback, 1); + } + mats.push_back(scanParam.is_switchfrontback ? imgback : imgfront); + mats.push_back(scanParam.is_switchfrontback ? imgfront : imgback); + remove(info.path.c_str()); + remove(back.path.c_str()); + } + else + { + msg = "get empty mat! empty "; + msg += (imgfront.empty() ? " front image" : " back image"); + FileTools::writelog(log_ERROR, msg); + } + + for (size_t i = 0; i < mats.size(); i++) + { + if (!mats[i].empty()) + cv::resize(mats[i], mats[i], cv::Size(), fx, fy);//用于修正与佳能机器幅面大小不匹配问题 此系数请勿轻易动 + } + + //if (scanParam.en_fold != 0) { //对折前旋转屏蔽 20211214 奥鸽要求 + // cv::flip(mats[0], mats[0], 1); + // cv::flip(mats[0], mats[0], 0); + //} + } + else + { + auto mat = imread(info.path, rmc); + if (!mat.empty()) + { + Mat front = mat(Rect(0, 0, mat.cols / 2, mat.rows - 10));//避免图像尾部出现无效数据丢弃10行数据 + Mat back = mat(Rect(mat.cols / 2, 0, mat.cols / 2, mat.rows - 10));//避免图像尾部出现无效数据丢弃10行数据 + if (scanParam.imageRotateDegree != 0.0 && scanParam.imageRotateDegree != 180.0) { + cv::flip(front, front, 0); + cv::flip(front, front, 1); + } +#ifdef UV + mats.push_back(scanParam.is_switchfrontback ? front : back); + mats.push_back(scanParam.is_switchfrontback ? back : front); +#else + + + mats.push_back(scanParam.is_switchfrontback ? front : back); + mats.push_back(scanParam.is_switchfrontback ? back : front); +#endif + front.release(); + back.release(); + remove(info.path.c_str()); + } + else + { + msg = "g400 get empty mat! empty "; + FileTools::writelog(log_ERROR, msg); + } +#ifdef UV + if (scanParam.hardwarecaps.en_uv)//EN UV + { + auto uvinfo = m_imgCacheinfo.Take(); + auto matuv = imread(uvinfo.path, IMREAD_COLOR); + if (!matuv.empty()) + { + Mat front = matuv(Rect(0, 0, mat.cols / 2, mat.rows)); + Mat back = matuv(Rect(mat.cols / 2, 0, mat.cols / 2, mat.rows)); + if (scanParam.imageRotateDegree != 0.0 && scanParam.imageRotateDegree != 180.0) { + cv::flip(front, front, 0); + cv::flip(front, front, 1); + } + uvmats.push_back(scanParam.is_switchfrontback ? front : back); + uvmats.push_back(scanParam.is_switchfrontback ? back : front); + front.release(); + back.release(); + remove(uvinfo.path.c_str()); + } + } +#endif + }//g400 serials + FileTools::writelog(log_DEBUG, " start image process "); + std::vector rects; + std::vector angleResults; + bool isDesaskew = false; + sw.reset(); + for (int j = 0; j < m_iaList.size(); j++) { + m_iaList[j]->apply(mats, scanParam.is_duplex); + CImageApply* ptr = m_iaList[j].get(); + if (typeid(*ptr) == typeid(CImageApplyAutoCrop)) + { + rects = dynamic_cast(ptr)->rotatedROIs(); + isDesaskew = dynamic_cast(ptr)->isDesaskew(); + } + else if (typeid(*ptr) == typeid(CImageApplyRotation)) + angleResults = dynamic_cast(ptr)->angleResults(); + } + +#ifdef UV + if (!uvmats.empty()) + { + //拼接原图和UV图 + for (int j = 0; j < mats.size(); j++) + { + if (!scanParam.is_duplex && j == 1) { + mats[j].release(); + break; + } + if (!mats[j].empty()) + { + cv::Mat mergeOrgin_UV = ImageApplyUV::Apply(mats[j], uvmats[j], rects[j], isDesaskew, angleResults.size() > 0 ? angleResults[j] : 0, scanParam.pixtype); + if (!mergeOrgin_UV.empty()) + mats[j] = mergeOrgin_UV; + } + } + rects.clear(); + uvmats.clear(); + } +#endif + FileTools::writelog(log_DEBUG, " image process finish"); + if (!scanParam.is_duplex && mats.size() > 1) { + mats.pop_back(); + } + if (scanParam.is_split) + { + splitimg(mats); + } + for (int i = 0; i < mats.size(); i++) { + if (!mats[i].empty()) { + IMat2Bmp idata; +#ifdef UV + if (scanParam.pixtype == 1 && mats[i].channels() == 3)//gray + cv::cvtColor(mats[i], mats[i], COLOR_BGR2GRAY); +#else + if (scanParam.pixtype == 1 && scanParam.hsvcorrect) + if (mats[i].channels() == 3) + cvtColor(mats[i], mats[i], cv::COLOR_BGR2GRAY); +#endif + 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 + { + FileTools::writelog(log_ERROR, "enqueue image is empty " + std::to_string(index++)); + } + } + + if (scanParam.multi_output_red) { + for (int i = 0; i < mats.size(); i++) { + if (!mats[i].empty()) { + ImageMultiOutput m_mlt; + Mat ret = m_mlt.GetMultiFilterMat(mats[i], 2); + mats[i].release(); + if (!ret.empty()) { + if (!scanParam.is_duplex && i == 1) { + ret.release(); + break; + } + Mat2Bmp mb(ret, scanParam.resolution_dst); + auto data = mb.getBmpDataBuffer(); + ret.release(); + EnqueueBmpBuffer(data); + data.reset(); + } + } + } + } + + mats.clear(); +#ifdef UV + PaniusCount(scanParam.hardwarecaps.en_uv ? 2 : 1); +#else + PaniusCount(); +#endif +} + +void ImageMatQueue::single_process(cv::Mat& mat) +{ + FileTools::writelog(log_DEBUG, " start image process "); + StopWatch sw; + for (int j = 0; j < m_iaList.size(); j++) { + m_iaList[j]->apply(mat, false); + } + FileTools::writelog(log_DEBUG, " image process finish"); + std::vector mats; + mats.push_back(mat); + if (scanParam.is_split) + { + splitimg(mats); + } + for (int i = 0; i < mats.size(); i++) { + if (!mats[i].empty()) { + IMat2Bmp idata; + if (scanParam.pixtype == 1 && scanParam.hsvcorrect) + if (mats[i].channels() == 3) + cvtColor(mats[i], mats[i], cv::COLOR_BGR2GRAY); + 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 + { + FileTools::writelog(log_ERROR, "enqueue image is empty " + std::to_string(index++)); + } + } + + if (scanParam.multi_output_red) { + for (int i = 0; i < mats.size(); i++) { + if (!mats[i].empty()) { + ImageMultiOutput m_mlt; + Mat ret = m_mlt.GetMultiFilterMat(mats[i], 2); + mats[i].release(); + if (!ret.empty()) { + if (!scanParam.is_duplex && i == 1) { + ret.release(); + break; + } + Mat2Bmp mb(ret, scanParam.resolution_dst); + auto data = mb.getBmpDataBuffer(); + ret.release(); + EnqueueBmpBuffer(data); + data.reset(); + } + } + } + } + mats.clear(); +} + G400Decode::G400Decode(std::shared_ptr> buff) { m_buffs.push_back(buff); diff --git a/huagao/Device/ImageMatQueue.h b/huagao/Device/ImageMatQueue.h index bbed177d..b402b838 100644 --- a/huagao/Device/ImageMatQueue.h +++ b/huagao/Device/ImageMatQueue.h @@ -227,6 +227,8 @@ private: void PaniusCount(int count = 1); void init_cachethread(); void splitimg(std::vector& mats); + void duplex_process(CacheInfo info); + void single_process(cv::Mat& mat); void cache_run(); void MultiOut(cv::Mat & pDid); //清除缓存文件 diff --git a/huagao/Device/PublicFunc.cpp b/huagao/Device/PublicFunc.cpp index 65567415..fb7b5e67 100644 --- a/huagao/Device/PublicFunc.cpp +++ b/huagao/Device/PublicFunc.cpp @@ -467,6 +467,8 @@ CString GetHidedlgPath() _tcscat(szIniFile, _T("\\twain_32\\HanvonScan\\hidedlg.exe")); #elif defined LANXUM _tcscat(szIniFile, _T("\\twain_32\\LANXUMSCAN\\hidedlg.exe")); +#elif defined CUMTENN + _tcscat(szIniFile, _T("\\twain_32\\CumTennScan\\hidedlg.exe")); #elif defined MAKERIGHTWAY _tcscat(szIniFile, _T("\\twain_32\\RIGHTWAYSCAN\\hidedlg.exe")); #elif defined NOLOGO diff --git a/huagao/ImageProcess/ImageApplyDispersion.cpp b/huagao/ImageProcess/ImageApplyDispersion.cpp new file mode 100644 index 00000000..1e334244 --- /dev/null +++ b/huagao/ImageProcess/ImageApplyDispersion.cpp @@ -0,0 +1,43 @@ +#include "ImageApplyDispersion.h" + +CImageApplyDispersion::CImageApplyDispersion(): + m_kernal_b(3, 1, CV_32FC1) + , m_kernal_g(3, 1, CV_32FC1) + , m_kernal_r(3, 1, CV_32FC1) +{ + m_kernal_b.at(0, 0) = 0.15f; + m_kernal_b.at(1, 0) = 1.15f; + m_kernal_b.at(2, 0) = -0.3f; + + m_kernal_g.at(0, 0) = 0.806f; + m_kernal_g.at(1, 0) = 0.484f; + m_kernal_g.at(2, 0) = -0.3f; + + m_kernal_r.at(0, 0) = 0.484f; + m_kernal_r.at(1, 0) = 0.806f; + m_kernal_r.at(2, 0) = -0.3f; +} + +CImageApplyDispersion::~CImageApplyDispersion() +{ +} + +void CImageApplyDispersion::apply(cv::Mat& pDib, int side) +{ + (void)side; + + if (pDib.channels() != 3) return; + + cv::Mat bgr[3]; + cv::split(pDib, bgr); + + cv::filter2D(bgr[0], bgr[0], bgr[0].depth(), m_kernal_b); + cv::filter2D(bgr[1], bgr[1], bgr[1].depth(), m_kernal_g); + cv::filter2D(bgr[2], bgr[2], bgr[2].depth(), m_kernal_r); + + cv::merge(bgr, 3, pDib); +} + +void CImageApplyDispersion::apply(std::vector& mats, bool isTwoSide) +{ +} diff --git a/huagao/ImageProcess/ImageApplyDispersion.h b/huagao/ImageProcess/ImageApplyDispersion.h new file mode 100644 index 00000000..6c52bebb --- /dev/null +++ b/huagao/ImageProcess/ImageApplyDispersion.h @@ -0,0 +1,35 @@ +/* + * ==================================================== + + * ܣɫɢ + * ߣά + * ʱ䣺2021/09/24 + * ޸ʱ䣺2021/11/12 v1.1.0 ع㷨 + * 2022/04/21 v1.2.0 ع㷨 + * 汾ţv1.2.0 + + * ==================================================== + */ + +#ifndef IMAGE_APPLY_DISPERSION_COLOR_H +#define IMAGE_APPLY_DISPERSION_COLOR_H + +#include "ImageApply.h" + +class CImageApplyDispersion : public CImageApply +{ +public: + CImageApplyDispersion(); + + virtual ~CImageApplyDispersion(); + + virtual void apply(cv::Mat& pDib, int side); + + virtual void apply(std::vector& mats, bool isTwoSide); + +private: + cv::Mat m_kernal_b; + cv::Mat m_kernal_g; + cv::Mat m_kernal_r; +}; +#endif diff --git a/huagao/ImageProcess/ImageMulti.cpp b/huagao/ImageProcess/ImageMulti.cpp new file mode 100644 index 00000000..99cc37ef --- /dev/null +++ b/huagao/ImageProcess/ImageMulti.cpp @@ -0,0 +1,98 @@ +#include "ImageMulti.h" +#include "ImageApplyHeaders.h" + +IMageMulti::IMageMulti(int multiType,int thre) +{ + m_multiType = multiType; + m_thre = thre; +} + +IMageMulti::~IMageMulti(void) +{ +} + +std::vector IMageMulti::apply(cv::Mat& pDib) +{ + std::vector retMats; + if (pDib.empty()) + return retMats; + retMats.push_back(pDib); + switch (m_multiType) + { + case ALL: + { + if (pDib.channels() == 3){ + cv::Mat dst; + cv::cvtColor(pDib, dst,cv::COLOR_BGR2GRAY); + retMats.push_back(dst); + } + cv::Mat dstThre; + cv::cvtColor(pDib, dstThre,cv::COLOR_BGR2GRAY); + //cv::threshold(dstThre, dstThre, m_thre, 255, cv::THRESH_BINARY); + CImageApplyBWBinaray bw(CImageApplyBWBinaray::ThresholdType::THRESH_BINARY); + bw.apply(dstThre, 0); + //cv::adaptiveThreshold(dstThre,dstThre,255,cv::ADAPTIVE_THRESH_GAUSSIAN_C,cv::THRESH_BINARY,25,5); + if (!dstThre.empty()) + { + retMats.push_back(dstThre); + } + } + break; + case COLORGRAY: + { + if (pDib.channels() == 3) { + cv::Mat dstGray; + cv::cvtColor(pDib, dstGray, cv::COLOR_BGR2GRAY); + retMats.push_back(dstGray); + } + } + break; + case COLORBW: + { + if (pDib.channels() == 3) { + cv::Mat dstGray; + cv::cvtColor(pDib, dstGray, cv::COLOR_BGR2GRAY); + CImageApplyBWBinaray bw(CImageApplyBWBinaray::ThresholdType::THRESH_BINARY); + bw.apply(dstGray, 0); +// cv::Mat dstBW; +// cv::adaptiveThreshold(dstGray,dstBW,255,cv::ADAPTIVE_THRESH_GAUSSIAN_C,cv::THRESH_BINARY,25,5); + retMats.push_back(dstGray); + } + } + break; + case GRAYBW://pDib should be GreyImage(channels() == 1) + { + cv::Mat dst = pDib.clone(); + CImageApplyBWBinaray bw(CImageApplyBWBinaray::ThresholdType::THRESH_BINARY); + bw.apply(dst, 0); +// cv::Mat dstBW; +// cv::adaptiveThreshold(pDib,dstBW,255,cv::ADAPTIVE_THRESH_GAUSSIAN_C,cv::THRESH_BINARY,25,5); + if (!dst.empty()) + { + retMats.push_back(dst); + } + } + break; + default: + break; + } + return retMats; +} + +std::vector IMageMulti::apply(cv::Mat& pDib, int multitype) +{ + m_multiType = multitype; + return apply(pDib); +} + +std::vector IMageMulti::apply(std::vector& pDib, int multitype) +{ + std::vector m_rets; + m_multiType = multitype; + for (auto& node : pDib) + { + auto nodes = apply(node); + m_rets.insert(m_rets.end(), nodes.begin(), nodes.end()); + } + return m_rets; +} diff --git a/huagao/ImageProcess/ImageMulti.h b/huagao/ImageProcess/ImageMulti.h new file mode 100644 index 00000000..e4df724b --- /dev/null +++ b/huagao/ImageProcess/ImageMulti.h @@ -0,0 +1,27 @@ +#ifndef IMAGE_MULTI_H +#define IMAGE_MULTI_H +#include +#include +class IMageMulti +{ +public: + enum MultiOutput + { + NONE=-1, + ALL, + COLORGRAY, + COLORBW, + GRAYBW + }; +public: + IMageMulti(int multiType = 0,int thre = 128); + ~IMageMulti(); + std::vector apply(cv::Mat& pDib); + std::vector apply(cv::Mat& pDib, int multitype); + std::vector apply(std::vector& pDib, int multitype); +private: + int m_multiType; + int m_thre; +}; + +#endif // !IMAGE_MULTI_H \ No newline at end of file diff --git a/huagao/cumtenn.bmp b/huagao/cumtenn.bmp new file mode 100644 index 00000000..09d04b2f Binary files /dev/null and b/huagao/cumtenn.bmp differ diff --git a/huagao/huagaods.cpp b/huagao/huagaods.cpp index 24a1c085..58e120bb 100644 --- a/huagao/huagaods.cpp +++ b/huagao/huagaods.cpp @@ -108,6 +108,8 @@ static constexpr const Identity srcIdent( "AUGE", #elif defined LANXUM "LANXUM", +#elif defined CUMTENN + "CUMTENN", #elif defined MAKERIGHTWAY "RIGHTWAY", #elif defined NOLOGO @@ -130,6 +132,8 @@ static constexpr const Identity srcIdent( "G73S Series", #elif defined HANVON "HW-9000", + #elif defined CUMTENN + "CTS A3", #else // ISG100 "G200 Series", #endif @@ -137,6 +141,8 @@ static constexpr const Identity srcIdent( #elif defined(G300) // G200 #ifdef LANXUM "G42S Series", + #elif defined CUMTENN + "CTS A4", #elif defined HANVON #ifdef ANDROIDSERIAL "HW-1000", @@ -182,6 +188,8 @@ static constexpr const Identity srcIdent( "HUAGOSCAN G200 TWAIN" #elif defined NOLOGO "Scan G200 TWAIN" + #elif defined CUMTENN + "CUMTENN CTS A3 TWAIN" #elif defined HANVON "Hanvon HW-9000 TAWIN" #elif defined LANXUM //!LANXUM @@ -207,6 +215,8 @@ static constexpr const Identity srcIdent( #endif // ANDROIDSERIES #elif defined NOLOGO "Scan G300 TWAIN" +#elif defined CUMTENN + "CUMTENN CTS A4 TWAIN" #elif defined LANXUM //!LANXUM "LANXUMSCAN G42S TWAIN" #else // !MAKEHUAGAO @@ -325,7 +335,7 @@ static std::vector DeviceID{ {0x31c9,0x8420}, #elif defined G400 {0x31c9,0x8520}, - + {0x31c9,0x8529}, #endif // ISG100 }; @@ -344,11 +354,35 @@ static std::vector DeviceID{ #endif // ISG100 #elif defined G400 {0x2903,0x7000}, + #ifdef ANDROIDSERIAL + {0x2903,0x7002}, + #else + {0x2903,0x7039}, + #endif // ANDROIDSERIAL #elif defined G300 {0x2903,0x1000}, + #ifdef ANDROIDSERIAL + {0x2903,0x1002}, + #endif // ANDROIDSERIAL + #endif // G200 }; +#elif defined CUMTENN +static std::vector DeviceID{ +#ifdef G200 +#ifdef ISG100 + {0x3072,0x138}, +#else + {0x3072,0x238}, +#endif // ISG100 +#elif defined G300 + {0x3072,0x0303}, +#elif defined G400 + {0x3072,0x0403}, +#endif +}; + #else static std::vector DeviceID{ {0x64B,0x7823}, @@ -396,6 +430,11 @@ static std::unique_ptr scanner(new GScanVirtual()); long __stdcall callback(EXCEPTION_POINTERS* ex) { + if (scanner.get()) + { + if (scanner->IsConnected()) + scanner->Stop_scan(); + } 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; @@ -937,12 +976,14 @@ Result HuagaoDs::identityOpenDs(const Identity&) { pid = usb.pid; if (!scanner.get()) { #ifdef G200 - if (pid == 0x139 || pid == 0x239 || pid == 0x8739 || pid == 0x8629 || pid == 0x130 ||pid == 0x8000 || pid == 0x9000) + if (pid == 0x139 || pid == 0x239 || pid == 0x8739 || pid == 0x8629 || pid == 0x130 ||pid == 0x8000 || pid == 0x9000 || + pid == 0x138 || pid == 0x238) scanner.reset(new GScanO1003399()); else scanner.reset(new GScanO200()); #else - if (pid == 0x339 || pid == 0x439) + + if (pid == 0x339 || pid == 0x439 || pid == 0x7039 || pid == 0x8529) scanner.reset(new GScanO1003399()); else #ifdef ANDROIDSERIAL @@ -976,7 +1017,6 @@ Result HuagaoDs::identityOpenDs(const Identity&) { CloseHandle(hMutex); hMutex = NULL; } - showmsg("ʾ", msgs[(UsbSupported)81]); return seqError(); } if (!scanner->IsConnected()) { @@ -2302,8 +2342,10 @@ Result HuagaoDs::pendingXfersEnd(const Identity&, PendingXfers& data) { int index = scanner->geterrorindex(); if (ret == 82 && ((typeid(*scanner.get()) == typeid(GScanO1003399)))) showmsg("ʾ", "ڵ" + to_string(index) + "ҳ⵽۽ǣֹͣɨ裡", ret); - else if(ret==75 && ((typeid(*scanner.get()) == typeid(GScanO1003399)))) + else if (ret == 75 && ((typeid(*scanner.get()) == typeid(GScanO1003399)))) showmsg("ʾ", "ڵ" + to_string(index) + "ҳ⵽ߴ粻ֹͣɨ裡", ret); + else if (ret == 81 && ((typeid(*scanner.get()) == typeid(GScanO1003399)))) + showmsg("ʾ", "豸ģʽֶ豸", ret); else showmsg("ʾ", msgs[(UsbSupported)ret], ret); FileTools::writelog(log_ERROR, msgs[(UsbSupported)ret]); @@ -2385,13 +2427,7 @@ 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 + if (!scanner->IsConnected()) scanner->open(vid, pid); @@ -2400,6 +2436,15 @@ Result HuagaoDs::userInterfaceEnable(const Identity&, UserInterface& ui) { MessageBox(NULL, L"USB쳣,USB´ɨ", L"ʾ", MB_OK | MB_SYSTEMMODAL); return seqError(); } +#ifndef G200 + if (typeid(*scanner.get()) != typeid(GScanO1003399)) { + while (!scanner->Get_Scanner_PaperOn()) + { + if (MessageBox(NULL, L"⵽ֽֽ", L"ʾ", MB_YESNO | MB_SYSTEMMODAL) == IDNO) + return seqError(); + } + } +#endif // !G200 this_thread::sleep_for(chrono::milliseconds(100)); //ɨǰӳ ֹusbеϢδȡ ɨ auto ret = startScan(); //if (ret.status().condition() == Twpp::CC::NoMedia) @@ -2573,7 +2618,7 @@ Result HuagaoDs::imageNativeXferGet(const Identity& id, ImageNativeXfer& data) { // it does not get easier than that if we already have BMP data = ImageNativeXfer(bmpSize()); std::copy(bmpBegin(), bmpEnd(), data.data().data()); - bmpData.reset(new std::vector); + //bmpData.reset(new std::vector); //FileTools::write_log("ϴͼƬ ===> Twain transfered num of " + to_string(++xtfer) + " images"); FileTools::writelog(log_INFO, "ϴͼƬ ===> Twain transfered num of " + to_string(++xtfer) + " images"); return { ReturnCode::XferDone, ConditionCode::Success }; @@ -2712,20 +2757,18 @@ 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 + if (typeid(*scanner.get()) != typeid(GScanO1003399)) { + while (!scanner->Get_Scanner_PaperOn()) + { + 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(); @@ -2871,12 +2914,14 @@ Twpp::Result HuagaoDs::startScan() scanner->ResetScanner(); scanner->reset(); FileTools::writelog(log_INFO, "start scan"); + #ifdef G200 + scanner->clear_hwerror(); +#else #ifndef ANDROIDSERIAL if (scanner->notifyscan() < 1) return seqError(); #endif // !ANDROIDSERIAL - scanner->clear_hwerror(); #endif // #ifdef G200 @@ -2988,6 +3033,8 @@ Twpp::Result HuagaoDs::startScan() showmsg("ʾ", "ڵ" + to_string(index) + "ҳ⵽۽ǣֹͣɨ裡", retCode); else if (retCode == 75 && ((typeid(*scanner.get()) == typeid(GScanO1003399)))) showmsg("ʾ", "ڵ" + to_string(index) + "ҳ⵽ߴ粻ֹͣɨ裡", retCode); + else if (retCode == 81 && ((typeid(*scanner.get()) == typeid(GScanO1003399)))) + showmsg("ʾ", "豸ģʽֶ豸", retCode); else showmsg("ʾ", msgs[(UsbSupported)retCode], retCode); FileTools::writelog(log_ERROR, msgs[(UsbSupported)retCode]); diff --git a/huagao/huagaotwds.rc b/huagao/huagaotwds.rc index 3ed68c79..e6504eaa 100644 Binary files a/huagao/huagaotwds.rc and b/huagao/huagaotwds.rc differ diff --git a/huagao/resource.h b/huagao/resource.h index 1cf6be13..071612b7 100644 Binary files a/huagao/resource.h and b/huagao/resource.h differ diff --git a/huagao/rtw_logo.bmp b/huagao/rtw_logo.bmp new file mode 100644 index 00000000..ab0cab9f Binary files /dev/null and b/huagao/rtw_logo.bmp differ diff --git a/huagao/stdafx.h b/huagao/stdafx.h index f56eca2d..35c0091d 100644 Binary files a/huagao/stdafx.h and b/huagao/stdafx.h differ