From 359ee319ebad21ae455b9271b6861fd089a661bd Mon Sep 17 00:00:00 2001 From: masayume <1936714878@qq.com> Date: Sun, 20 Dec 2020 14:37:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9G100,G200=E4=B8=8D=E6=98=BE?= =?UTF-8?q?=E7=A4=BAUI=E6=97=B6=EF=BC=8C=E7=95=B8=E5=8F=98=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E4=B8=8D=E7=94=9F=E6=95=88=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- huagao/Device/GScanO200.cpp | 8 ++++++-- huagao/Device/ImageMatQueue.cpp | 4 ++-- huagao/ImageProcess/ImageApplyBWBinaray.cpp | 15 ++++++--------- huagao/huagaods.cpp | 19 ++++++++++++++++++- huagao/huagaods.hpp | 2 ++ huagao/stdafx.h | Bin 10774 -> 10774 bytes 6 files changed, 34 insertions(+), 14 deletions(-) diff --git a/huagao/Device/GScanO200.cpp b/huagao/Device/GScanO200.cpp index 06f96071..95009eb0 100644 --- a/huagao/Device/GScanO200.cpp +++ b/huagao/Device/GScanO200.cpp @@ -224,7 +224,12 @@ void GScanO200::open(int vid, int pid) m_usb->set_usbhotplug_callback(usbhotplug_callback, this); } } +#ifdef G200 + if (this->IsConnected()) + GetFWVersion(); +#endif // G200 } + void GScanO200::regist_deviceevent_callback(deviceevent_callback callback, void* usrdata) { huagods = usrdata; @@ -388,8 +393,7 @@ void GScanO200::Scanner_StartScan(UINT16 count) devState = DEV_STOP; m_threadUsb->join(); } - - USBCB status = { GET_DSP_STATUS ,0,0 }; + USBCB status = { GET_DSP_STATUS ,0,0 }; if (m_usb.get() && m_usb->is_connected()) m_usb->write_bulk(&status, sizeof(status)); if (m_usb.get() && m_usb->is_connected()) diff --git a/huagao/Device/ImageMatQueue.cpp b/huagao/Device/ImageMatQueue.cpp index 61afa943..531b5780 100644 --- a/huagao/Device/ImageMatQueue.cpp +++ b/huagao/Device/ImageMatQueue.cpp @@ -358,7 +358,7 @@ void ImageMatQueue::proc() writelog("decode image data error"); } #ifdef G200 - cv::resize(mat, mat, cv::Size(), fx, fy);//用于修正与佳能机器幅面大小不匹配问题 此系数请勿轻易动 + cv::resize(mat, mat, cv::Size(), fx,fy);//用于修正与佳能机器幅面大小不匹配问题 此系数请勿轻易动 mats.push_back(mat); mat.release(); #else // G200 @@ -370,10 +370,10 @@ void ImageMatQueue::proc() cv::flip(front, front, 0); cv::flip(front, front, 1); } + FileTools::write_log("scanParam.imageRotateDegree-" + to_string(scanParam.imageRotateDegree)); mats.push_back(back); mats.push_back(front); #endif - } catch (const std::exception& e) { diff --git a/huagao/ImageProcess/ImageApplyBWBinaray.cpp b/huagao/ImageProcess/ImageApplyBWBinaray.cpp index 4bd73cf2..3fee7dc7 100644 --- a/huagao/ImageProcess/ImageApplyBWBinaray.cpp +++ b/huagao/ImageProcess/ImageApplyBWBinaray.cpp @@ -1,5 +1,4 @@ #include "ImageApplyBWBinaray.h" -#include "ImageApplyDetachNoise.h" CImageApplyBWBinaray::CImageApplyBWBinaray(ThresholdType type, int threshold, int blockSize, int constant) : m_threshold(threshold) @@ -37,13 +36,12 @@ void CImageApplyBWBinaray::apply(cv::Mat& pDib, int side) cv::cvtColor(pDib, pDib, cv::COLOR_BGR2GRAY); cv::Mat integ; - int blockSize = 31;//邻域尺寸 - int threshold = 21; + int blockSize = 13;//邻域尺寸 + int threshold = 1; int low = 110; - int up = 220; + int up = 230; int halfSize = blockSize / 2; int square_blockSize = blockSize * blockSize; - CImageApplyDetachNoise noise(6); switch (m_type) { case ThresholdType::THRESH_BINARY: @@ -56,9 +54,9 @@ void CImageApplyBWBinaray::apply(cv::Mat& pDib, int side) int* idata2 = integ.ptr(j + halfSize + 1); for (int i = halfSize; i < integ.cols - halfSize - 1; i++) { - if (data[i] < low) + if (data[i] < low) data[i] = 0; - else if (data[i] > up) + else if (data[i] > up) data[i] = 255; else data[i] = data[i] < ((idata2[i + halfSize + 1] - idata2[i - halfSize] - idata1[i + halfSize + 1] + idata1[i - halfSize]) / square_blockSize - threshold) ? 0 : 255; @@ -69,7 +67,6 @@ void CImageApplyBWBinaray::apply(cv::Mat& pDib, int side) cv::threshold(pDib(cv::Rect(pDib.cols - halfSize, 0, halfSize, pDib.rows)), pDib(cv::Rect(pDib.cols - halfSize, 0, halfSize, pDib.rows)), m_threshold, 255, cv::THRESH_BINARY); cv::threshold(pDib(cv::Rect(0, 0, pDib.cols, halfSize)), pDib(cv::Rect(0, 0, pDib.cols, halfSize)), m_threshold, 255, cv::THRESH_BINARY); cv::threshold(pDib(cv::Rect(0, pDib.rows - halfSize, pDib.cols, halfSize)), pDib(cv::Rect(0, pDib.rows - halfSize, pDib.cols, halfSize)), m_threshold, 255, cv::THRESH_BINARY); - noise.apply(pDib, side); break; case ThresholdType::THRESH_OTSU: cv::threshold(pDib, pDib, m_threshold, 255, CV_THRESH_OTSU); @@ -165,4 +162,4 @@ void CImageApplyBWBinaray::errorDiffuse(cv::Mat& image) ptr[x] = m_table[ptr[x]]; delete[] pixels_dst; -} +} \ No newline at end of file diff --git a/huagao/huagaods.cpp b/huagao/huagaods.cpp index f1a19565..b8363655 100644 --- a/huagao/huagaods.cpp +++ b/huagao/huagaods.cpp @@ -653,7 +653,7 @@ Result HuagaoDs::identityOpenDs(const Identity&) { return success(); case Msg::Reset: - m_iBitdepth = 8; + m_iBitdepth = 24; data = Capability::createOneValue(UInt16(m_iBitdepth)); return success(); break; @@ -1146,6 +1146,7 @@ Result HuagaoDs::identityOpenDs(const Identity&) { case Msg::GetCurrent: case Msg::GetDefault: { + FileTools::write_log("D:\\1.txt", "getfwversion"); std::string ser = scanner->GetFWVersion(); Str255 str; str.setData(ser.c_str(), ser.size()); @@ -2416,6 +2417,12 @@ Result HuagaoDs::pendingXfersEnd(const Identity&, PendingXfers& data) { #endif // G200 } m_pendingXfers = 0; + if (m_modal) + { + ::EnableWindow(parent, true); + m_modal = false; + notifyCloseCancel(); + } if (guiTwain.get()) { ((CTwainUI*)(guiTwain.get()))->EnableID_OKorID_Cancel(true); } @@ -2796,6 +2803,12 @@ Twpp::Result HuagaoDs::showTwainUI(Twpp::UserInterface& ui, bool bUiOnly) // long appFlags = GetWindowLong(appWindow, GWL_STYLE); // SetWindowLong(appWindow, GWL_STYLE, appFlags | WS_DISABLED); //} + if (ui.modalUi()) + { + m_modal = true; + parent = appWindow; + ::EnableWindow(appWindow, false); + } } //!< show ui to scan button push @@ -2820,6 +2833,10 @@ Twpp::Result HuagaoDs::showTwainUI(Twpp::UserInterface& ui, bool bUiOnly) //!< cancel button push auto cancelFunction = [this]() { + if (m_modal) + { + ::EnableWindow(parent, true); + } notifyCloseCancel(); }; diff --git a/huagao/huagaods.hpp b/huagao/huagaods.hpp index ce4f9e14..a9c16e91 100644 --- a/huagao/huagaods.hpp +++ b/huagao/huagaods.hpp @@ -114,6 +114,8 @@ private://field bool m_bFeederEnabled = true; bool m_bAutoFeed = true; bool m_haveError = false; + bool m_modal = false; + HWND parent; UINT16 m_iBitdepth; Twpp::ImageFileFormat m_capImageFileFormat = Twpp::ImageFileFormat::Bmp; std::queue devEvent; diff --git a/huagao/stdafx.h b/huagao/stdafx.h index b7dc8cad2406fe0cb419247509c309cfea2dd34c..f29a214232e7d2a976de3e202b7a4a9065576d46 100644 GIT binary patch delta 22 ecmbOhGA(4oHV#%J1_K6z$&HMXo3C&