From 01081dcae26e02ab81fc29df4fcb089745860ea5 Mon Sep 17 00:00:00 2001 From: lovelyyoung <1002639516@qq.com> Date: Fri, 3 Apr 2020 09:28:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=92=88=E5=AF=B9=E4=B8=83?= =?UTF-8?q?=E5=A4=A9=E8=BD=AF=E4=BB=B6=E4=B8=8E=E4=BD=B3=E8=83=BD=E6=9C=BA?= =?UTF-8?q?=E5=99=A8=E6=A8=A1=E6=9D=BF=E6=97=A0=E6=B3=95=E5=8C=B9=E9=85=8D?= =?UTF-8?q?=E9=97=AE=E9=A2=98=EF=BC=8C=E5=AF=B9=E5=8E=9F=E5=9B=BE=E8=BF=9B?= =?UTF-8?q?=E8=A1=8C=E6=94=BE=E5=A4=A7=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- huagao/Device/ImageMatQueue.cpp | 37 ++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/huagao/Device/ImageMatQueue.cpp b/huagao/Device/ImageMatQueue.cpp index 98cb9bae..cb7fdfad 100644 --- a/huagao/Device/ImageMatQueue.cpp +++ b/huagao/Device/ImageMatQueue.cpp @@ -6,6 +6,8 @@ #include "jpeglib.h" #include "filetools.h" #include +#include "StopWatch.h" + using namespace cv; using namespace std; @@ -112,7 +114,13 @@ void ImageMatQueue::setparam(const GScanCap& param) bool islongcustomcrop = false; if (param.papertype == TwSS::USStatement) islongcustomcrop = true; - CSize fixedSize = papersize.GetPaperSize(param.papertype, 200.0f, param.paperAlign); + + 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); +#endif m_iaList.push_back(shared_ptr(new CImageApplyAutoCrop(islongcustomcrop ? islongcustomcrop : param.is_autocrop, param.autodescrew, param.fillbackground, cv::Size(fixedSize.cx, fixedSize.cy), true))); } @@ -147,14 +155,14 @@ void ImageMatQueue::setparam(const GScanCap& param) } - if (param.resolution_dst != 200.0) + if (param.resolution_dst != param.resolution_native) { CImageApplyResize* apply; bool islongcustomcrop = false; if (param.papertype == TwSS::USStatement) islongcustomcrop = true; if (param.is_autocrop|| islongcustomcrop) { - double ratio = param.resolution_dst / 200.0; + double ratio = param.resolution_dst / param.resolution_native; apply = new CImageApplyResize(CImageApplyResize::ResizeType::RATIO, cv::Size(0, 0), ratio, ratio); } else { @@ -223,6 +231,7 @@ void ImageMatQueue::proc() auto buffs = m_rawBuffs.Take()->getImageBuffs(); if (!m_rawBuffs.IsShutDown() && !buffs.empty()) { vector mats; + int k = 0; for (auto& buf : buffs) { ImreadModes rm; @@ -230,15 +239,19 @@ void ImageMatQueue::proc() rm = IMREAD_COLOR; else rm = scanParam.pixtype == 2 ? IMREAD_COLOR : IMREAD_GRAYSCALE; - - cv::Mat mat = cv::imdecode(*buf, rm); - if (mat.empty()) { - fstream fss; - fss.open("D:\\decodeerror.txt", std::ios::out); - fss << "decode image data error" << endl; - fss.close(); + try + { + cv::Mat mat = cv::imdecode(*buf, rm); + if (mat.empty()) { + writelog("decode image data error"); + } + resize(mat, mat, cv::Size(), 1.001, 1.0070);//用于修正与佳能机器幅面大小不匹配问题 此系数请勿轻易动 + mats.push_back(mat); } - mats.push_back(mat); + catch (const std::exception& e) + { + writelog(e.what()); + } } for (int j = 0; j < m_iaList.size(); j++) { @@ -259,7 +272,7 @@ void ImageMatQueue::proc() } else { - FileTools::write_log("emptyimage.txt", "enqueue image is empty " + std::to_string(index++)); + writelog("enqueue image is empty " + std::to_string(index++)); } }