修改G100,G200不显示UI时,畸变参数不生效问题

This commit is contained in:
masayume 2020-12-20 14:37:19 +08:00
parent 564d1d94a3
commit 359ee319eb
6 changed files with 34 additions and 14 deletions

View File

@ -224,7 +224,12 @@ void GScanO200::open(int vid, int pid)
m_usb->set_usbhotplug_callback(usbhotplug_callback, this); 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) void GScanO200::regist_deviceevent_callback(deviceevent_callback callback, void* usrdata)
{ {
huagods = usrdata; huagods = usrdata;
@ -388,8 +393,7 @@ void GScanO200::Scanner_StartScan(UINT16 count)
devState = DEV_STOP; devState = DEV_STOP;
m_threadUsb->join(); 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()) if (m_usb.get() && m_usb->is_connected())
m_usb->write_bulk(&status, sizeof(status)); m_usb->write_bulk(&status, sizeof(status));
if (m_usb.get() && m_usb->is_connected()) if (m_usb.get() && m_usb->is_connected())

View File

@ -358,7 +358,7 @@ void ImageMatQueue::proc()
writelog("decode image data error"); writelog("decode image data error");
} }
#ifdef G200 #ifdef G200
cv::resize(mat, mat, cv::Size(), fx, fy);//用于修正与佳能机器幅面大小不匹配问题 此系数请勿轻易动 cv::resize(mat, mat, cv::Size(), fx,fy);//用于修正与佳能机器幅面大小不匹配问题 此系数请勿轻易动
mats.push_back(mat); mats.push_back(mat);
mat.release(); mat.release();
#else // G200 #else // G200
@ -370,10 +370,10 @@ void ImageMatQueue::proc()
cv::flip(front, front, 0); cv::flip(front, front, 0);
cv::flip(front, front, 1); cv::flip(front, front, 1);
} }
FileTools::write_log("scanParam.imageRotateDegree-" + to_string(scanParam.imageRotateDegree));
mats.push_back(back); mats.push_back(back);
mats.push_back(front); mats.push_back(front);
#endif #endif
} }
catch (const std::exception& e) catch (const std::exception& e)
{ {

View File

@ -1,5 +1,4 @@
#include "ImageApplyBWBinaray.h" #include "ImageApplyBWBinaray.h"
#include "ImageApplyDetachNoise.h"
CImageApplyBWBinaray::CImageApplyBWBinaray(ThresholdType type, int threshold, int blockSize, int constant) CImageApplyBWBinaray::CImageApplyBWBinaray(ThresholdType type, int threshold, int blockSize, int constant)
: m_threshold(threshold) : m_threshold(threshold)
@ -37,13 +36,12 @@ void CImageApplyBWBinaray::apply(cv::Mat& pDib, int side)
cv::cvtColor(pDib, pDib, cv::COLOR_BGR2GRAY); cv::cvtColor(pDib, pDib, cv::COLOR_BGR2GRAY);
cv::Mat integ; cv::Mat integ;
int blockSize = 31;//ÁÚÓò³ß´ç int blockSize = 13;//ÁÚÓò³ß´ç
int threshold = 21; int threshold = 1;
int low = 110; int low = 110;
int up = 220; int up = 230;
int halfSize = blockSize / 2; int halfSize = blockSize / 2;
int square_blockSize = blockSize * blockSize; int square_blockSize = blockSize * blockSize;
CImageApplyDetachNoise noise(6);
switch (m_type) switch (m_type)
{ {
case ThresholdType::THRESH_BINARY: case ThresholdType::THRESH_BINARY:
@ -56,9 +54,9 @@ void CImageApplyBWBinaray::apply(cv::Mat& pDib, int side)
int* idata2 = integ.ptr<int>(j + halfSize + 1); int* idata2 = integ.ptr<int>(j + halfSize + 1);
for (int i = halfSize; i < integ.cols - halfSize - 1; i++) for (int i = halfSize; i < integ.cols - halfSize - 1; i++)
{ {
if (data[i] < low) if (data[i] < low)
data[i] = 0; data[i] = 0;
else if (data[i] > up) else if (data[i] > up)
data[i] = 255; data[i] = 255;
else else
data[i] = data[i] < ((idata2[i + halfSize + 1] - idata2[i - halfSize] - idata1[i + halfSize + 1] + idata1[i - halfSize]) / square_blockSize - threshold) ? 0 : 255; 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(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, 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); 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; break;
case ThresholdType::THRESH_OTSU: case ThresholdType::THRESH_OTSU:
cv::threshold(pDib, pDib, m_threshold, 255, CV_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]]; ptr[x] = m_table[ptr[x]];
delete[] pixels_dst; delete[] pixels_dst;
} }

View File

@ -653,7 +653,7 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
return success(); return success();
case Msg::Reset: case Msg::Reset:
m_iBitdepth = 8; m_iBitdepth = 24;
data = Capability::createOneValue<CapType::IBitDepth>(UInt16(m_iBitdepth)); data = Capability::createOneValue<CapType::IBitDepth>(UInt16(m_iBitdepth));
return success(); return success();
break; break;
@ -1146,6 +1146,7 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
case Msg::GetCurrent: case Msg::GetCurrent:
case Msg::GetDefault: case Msg::GetDefault:
{ {
FileTools::write_log("D:\\1.txt", "getfwversion");
std::string ser = scanner->GetFWVersion(); std::string ser = scanner->GetFWVersion();
Str255 str; Str255 str;
str.setData(ser.c_str(), ser.size()); str.setData(ser.c_str(), ser.size());
@ -2416,6 +2417,12 @@ Result HuagaoDs::pendingXfersEnd(const Identity&, PendingXfers& data) {
#endif // G200 #endif // G200
} }
m_pendingXfers = 0; m_pendingXfers = 0;
if (m_modal)
{
::EnableWindow(parent, true);
m_modal = false;
notifyCloseCancel();
}
if (guiTwain.get()) { if (guiTwain.get()) {
((CTwainUI*)(guiTwain.get()))->EnableID_OKorID_Cancel(true); ((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); // long appFlags = GetWindowLong(appWindow, GWL_STYLE);
// SetWindowLong(appWindow, GWL_STYLE, appFlags | WS_DISABLED); // SetWindowLong(appWindow, GWL_STYLE, appFlags | WS_DISABLED);
//} //}
if (ui.modalUi())
{
m_modal = true;
parent = appWindow;
::EnableWindow(appWindow, false);
}
} }
//!< show ui to scan button push //!< show ui to scan button push
@ -2820,6 +2833,10 @@ Twpp::Result HuagaoDs::showTwainUI(Twpp::UserInterface& ui, bool bUiOnly)
//!< cancel button push //!< cancel button push
auto cancelFunction = [this]() { auto cancelFunction = [this]() {
if (m_modal)
{
::EnableWindow(parent, true);
}
notifyCloseCancel(); notifyCloseCancel();
}; };

View File

@ -114,6 +114,8 @@ private://field
bool m_bFeederEnabled = true; bool m_bFeederEnabled = true;
bool m_bAutoFeed = true; bool m_bAutoFeed = true;
bool m_haveError = false; bool m_haveError = false;
bool m_modal = false;
HWND parent;
UINT16 m_iBitdepth; UINT16 m_iBitdepth;
Twpp::ImageFileFormat m_capImageFileFormat = Twpp::ImageFileFormat::Bmp; Twpp::ImageFileFormat m_capImageFileFormat = Twpp::ImageFileFormat::Bmp;
std::queue<Twpp::DeviceEvent> devEvent; std::queue<Twpp::DeviceEvent> devEvent;

Binary file not shown.