1)修改二值化算法參數為17 20 110 235

2)修改顔色模式,增强顔色協議部分内容
This commit is contained in:
masayume 2020-12-30 17:02:05 +08:00
parent 3d939f21e2
commit cc7d224b81
8 changed files with 41 additions and 58 deletions

View File

@ -85,7 +85,7 @@ BOOL CTwainUI::OnInitDialog()
UpdateUI();
UpdateListConfig();
dataChangeFunction();
//dataChangeFunction();
return true;
}
@ -518,12 +518,14 @@ void CTwainUI::UpDateScanParam(PCONFIGPARAMS configItem, bool updateDs)
#else // REAL300DPI
settings->resolution_native = 200.0f;
#endif
//if (settings->pixtype == TWPT_BW)
//{
// settings->pixtype = TWPT_RGB;
// settings->enhance_color = Enchace_Color::Enhance_Red;
// settings->filter = 3;//none
//}
if (settings->pixtype == TWPT_BW)
{
if (settings->filter == 3 && settings->enhance_color <=1)
{
settings->enhance_color = Enchace_Color::Enhance_Red;
settings->filter = 3;//none
}
}
UpdateUi();
}

View File

@ -118,12 +118,6 @@ public:
void DoEvents() {
MSG msg;
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
//if (msg.message != WM_LBUTTONUP && bFilterMsg)
//{
// FileTools::write_log("C:\\Users\\666\\Desktop\\1.txt", to_string(msg.message));
// bFilterMsg = false;
// return;
//}
DispatchMessage(&msg);
TranslateMessage(&msg);
}

View File

@ -174,7 +174,6 @@ void GScanO200::Getimagenumber(bool isadd)
{
image_num--;
}
//FileTools::write_log("1.txt", "image num :" + std::to_string(image_num));
}
void GScanO200::DogEar_callback(std::function<void(int)> fun)
@ -526,9 +525,6 @@ void GScanO200::usbhotplug_callback(bool isconnect, void* userdata)
void GScanO200::usbhotplug(bool isleft)
{
if (isleft) {
//std::lock_guard<std::mutex> lck(m_Locker);
//FileTools::
//("D:\\1.txt", "usbhotplug left");
devState = DEV_WRONG;
Error_Code = USB_DISCONNECTED;
m_pImages->setscanflags(false);
@ -553,7 +549,6 @@ void GScanO200::updateHVRatio()
m_usb->write_bulk(&usbcb, sizeof(usbcb));
m_usb->read_bulk(&usbcb, sizeof(usbcb));
float vratio = *((float*)(&usbcb.u32_Data));
//writelog("fx: " + to_string(hratio) + " fy :" + to_string(vratio));
m_pImages->updatefixratio(hratio, vratio);
}
}
@ -563,17 +558,14 @@ void GScanO200::usbmain()
std::shared_ptr<std::vector<char>> imgData;
devState = DEV_ISRUNNING;
bool haveError = false;
////FileTools::write_log("D:\\1.txt", "thread usb start");
try
{
StopWatch sw;
while (devState == DEV_ISRUNNING) {
if ((m_usb.get() && !m_usb->is_connected())) {
this_thread::sleep_for(chrono::milliseconds(200));
//FileTools::write_log("D:\\1.txt", "thread usb loop disconnect");
break;
}
////FileTools::write_log("D:\\1.txt", "thread usb start1");
//if (gcap.resolution_dst == 300.0f && gcap.en_fold) {
// if (m_pImages->orginimgcount() > 1)
@ -613,12 +605,6 @@ void GScanO200::usbmain()
}
if(!m_pImages->get_isDogEar())
m_pImages->pushMat(std::shared_ptr<IDecode>(new G200Decode(imgData)));
//static int rawdataindex = 0;
//writelog("origin rawbuffer index " + std::to_string(++rawdataindex));
#ifdef LOG_NORMAL
static int rawdataindex = 0;
//FileTools::write_log("out.txt", "Enquque rawbuffer index " + std::to_string(++rawdataindex));
#endif // LOG
m_usb->set_timeout(200);
Pop_Image();
sw.reset();

View File

@ -370,7 +370,7 @@ void ImageMatQueue::proc()
cv::flip(front, front, 0);
cv::flip(front, front, 1);
}
FileTools::write_log("scanParam.imageRotateDegree-" + to_string(scanParam.imageRotateDegree));
//FileTools::write_log("scanParam.imageRotateDegree-" + to_string(scanParam.imageRotateDegree));
mats.push_back(back);
mats.push_back(front);
#endif

View File

@ -55,9 +55,6 @@ void CImageApplyAutoCrop::apply(cv::Mat& pDib, int side)
if (m_maxContour.size() == 0)
{
thre.release();
#ifdef LOG
FileTools::write_log("imgprc.txt", "exit CImageApplyAutoCrop apply");
#endif // LOG
return;
}
thre.release();
@ -146,9 +143,6 @@ void CImageApplyAutoCrop::apply(cv::Mat& pDib, int side)
p += roi.tl();
dst(roi).copyTo(pDib(rect));
}
#ifdef LOG
FileTools::write_log("imgprc.txt", "exit CImageApplyAutoCrop apply8");
#endif // LOG
}
void CImageApplyAutoCrop::apply(std::vector<cv::Mat>& mats, bool isTwoSide)

View File

@ -35,10 +35,13 @@ void CImageApplyBWBinaray::apply(cv::Mat& pDib, int side)
if (pDib.channels() == 3)
cv::cvtColor(pDib, pDib, cv::COLOR_BGR2GRAY);
//20.12.29 修改参数为51 10 30 235
//20.12.30 修改参数为51 20 30 235
// 修改参数为17 20 110 235
cv::Mat integ;
int blockSize = 51;//ÁÚÓò³ß´ç
int threshold = 10;
int low = 30;
int blockSize = 17;//邻域尺寸
int threshold = 20;
int low = 110;
int up = 235;
int halfSize = blockSize / 2;
int square_blockSize = blockSize * blockSize;
@ -83,10 +86,6 @@ void CImageApplyBWBinaray::apply(cv::Mat& pDib, int side)
default:
break;
}
#ifdef LOG
FileTools::write_log("imgprc.txt", "exit CImageApplyBWBinaray apply");
#endif // LOG
}
void CImageApplyBWBinaray::apply(std::vector<cv::Mat>& mats, bool isTwoSide)

View File

@ -70,7 +70,7 @@ using namespace std::placeholders;
TWPP_ENTRY_MFC(HuagaoDs)
static constexpr const Identity srcIdent(
Version(3, 3, Language::English, Country::China, "v3.3.4.1"),
Version(3, 3, Language::English, Country::China, "v3.3.4.2"),
DataGroup::Image,
#ifdef MAKEHUAGAO
"HUAGO",
@ -772,11 +772,14 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
//if (m_scanparam->pixtype == (int)PixelType::BlackWhite)
// m_scanparam->sharpen = SharpenBlur::Sharpen_None;
if (m_scanparam->pixtype == (int)PixelType::BlackWhite)
{
if (m_scanparam->filter == 3 && m_scanparam->enhance_color == 0)
{
m_scanparam->filter = (byte)Filter::None;
m_scanparam->enhance_color = (byte)Enchace_Color::Enhance_Red;
}
}
}
m_iBitdepth = mech == PixelType::Rgb ? 24 : (mech == PixelType::Gray ? 8 : 1);
return success();
}
@ -905,7 +908,7 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
,PaperSize::A3,PaperSize::UsLedger,PaperSize::IsoB4,
PaperSize::MaxSize,PaperSize::UsStatement
#elif defined G400
PaperSize::A3,,PaperSize::UsLedger,PaperSize::IsoB4
,PaperSize::A3,PaperSize::UsLedger,PaperSize::IsoB4
#endif
#endif //
},m_scanparam->papertype, PaperSize::A3,
@ -1375,8 +1378,13 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
m_scanparam->filter = (byte)Filter::None;
if (m_scanparam->pixtype == (int)PixelType::BlackWhite)
{
if (m_scanparam->filter == (byte)Filter::None && m_scanparam->enhance_color == (byte)Enchace_Color::Enhance_None)
{
m_scanparam->filter = (byte)Filter::None;
m_scanparam->enhance_color = (byte)Enchace_Color::Enhance_Red;
}
}
return success();
}
}
@ -2020,12 +2028,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);
}
//if (ui.modalUi())
//{
// m_modal = true;
// parent = appWindow;
// ::EnableWindow(appWindow, false);
//}
}
//!< show ui to scan button push
@ -2050,10 +2058,10 @@ Twpp::Result HuagaoDs::showTwainUI(Twpp::UserInterface& ui, bool bUiOnly)
//!< cancel button push
auto cancelFunction = [this]() {
if (m_modal)
{
::EnableWindow(parent, true);
}
//if (m_modal)
//{
// ::EnableWindow(parent, true);
//}
notifyCloseCancel();
};

Binary file not shown.