修复针对七天软件与佳能机器模板无法匹配问题,对原图进行放大。

This commit is contained in:
lovelyyoung 2020-04-03 09:28:55 +08:00
parent 1dc154a95b
commit 01081dcae2
1 changed files with 25 additions and 12 deletions

View File

@ -6,6 +6,8 @@
#include "jpeglib.h"
#include "filetools.h"
#include <math.h>
#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<CImageApply>(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<cv::Mat> mats;
int k = 0;
for (auto& buf : buffs) {
ImreadModes rm;
@ -230,16 +239,20 @@ void ImageMatQueue::proc()
rm = IMREAD_COLOR;
else
rm = scanParam.pixtype == 2 ? IMREAD_COLOR : IMREAD_GRAYSCALE;
try
{
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();
writelog("decode image data error");
}
resize(mat, mat, cv::Size(), 1.001, 1.0070);//用于修正与佳能机器幅面大小不匹配问题 此系数请勿轻易动
mats.push_back(mat);
}
catch (const std::exception& e)
{
writelog(e.what());
}
}
for (int j = 0; j < m_iaList.size(); j++) {
m_iaList[j]->apply(mats, scanParam.is_duplex);
@ -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++));
}
}