mirror of http://192.168.1.51:8099/lmh188/twain3.0
修复针对七天软件与佳能机器模板无法匹配问题,对原图进行放大。
This commit is contained in:
parent
1dc154a95b
commit
01081dcae2
|
@ -6,6 +6,8 @@
|
||||||
#include "jpeglib.h"
|
#include "jpeglib.h"
|
||||||
#include "filetools.h"
|
#include "filetools.h"
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include "StopWatch.h"
|
||||||
|
|
||||||
using namespace cv;
|
using namespace cv;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -112,7 +114,13 @@ void ImageMatQueue::setparam(const GScanCap& param)
|
||||||
bool islongcustomcrop = false;
|
bool islongcustomcrop = false;
|
||||||
if (param.papertype == TwSS::USStatement)
|
if (param.papertype == TwSS::USStatement)
|
||||||
islongcustomcrop = true;
|
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)));
|
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;
|
CImageApplyResize* apply;
|
||||||
bool islongcustomcrop = false;
|
bool islongcustomcrop = false;
|
||||||
if (param.papertype == TwSS::USStatement)
|
if (param.papertype == TwSS::USStatement)
|
||||||
islongcustomcrop = true;
|
islongcustomcrop = true;
|
||||||
if (param.is_autocrop|| islongcustomcrop) {
|
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);
|
apply = new CImageApplyResize(CImageApplyResize::ResizeType::RATIO, cv::Size(0, 0), ratio, ratio);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -223,6 +231,7 @@ void ImageMatQueue::proc()
|
||||||
auto buffs = m_rawBuffs.Take()->getImageBuffs();
|
auto buffs = m_rawBuffs.Take()->getImageBuffs();
|
||||||
if (!m_rawBuffs.IsShutDown() && !buffs.empty()) {
|
if (!m_rawBuffs.IsShutDown() && !buffs.empty()) {
|
||||||
vector<cv::Mat> mats;
|
vector<cv::Mat> mats;
|
||||||
|
int k = 0;
|
||||||
for (auto& buf : buffs) {
|
for (auto& buf : buffs) {
|
||||||
ImreadModes rm;
|
ImreadModes rm;
|
||||||
|
|
||||||
|
@ -230,16 +239,20 @@ void ImageMatQueue::proc()
|
||||||
rm = IMREAD_COLOR;
|
rm = IMREAD_COLOR;
|
||||||
else
|
else
|
||||||
rm = scanParam.pixtype == 2 ? IMREAD_COLOR : IMREAD_GRAYSCALE;
|
rm = scanParam.pixtype == 2 ? IMREAD_COLOR : IMREAD_GRAYSCALE;
|
||||||
|
try
|
||||||
|
{
|
||||||
cv::Mat mat = cv::imdecode(*buf, rm);
|
cv::Mat mat = cv::imdecode(*buf, rm);
|
||||||
if (mat.empty()) {
|
if (mat.empty()) {
|
||||||
fstream fss;
|
writelog("decode image data error");
|
||||||
fss.open("D:\\decodeerror.txt", std::ios::out);
|
|
||||||
fss << "decode image data error" << endl;
|
|
||||||
fss.close();
|
|
||||||
}
|
}
|
||||||
|
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++) {
|
for (int j = 0; j < m_iaList.size(); j++) {
|
||||||
m_iaList[j]->apply(mats, scanParam.is_duplex);
|
m_iaList[j]->apply(mats, scanParam.is_duplex);
|
||||||
|
@ -259,7 +272,7 @@ void ImageMatQueue::proc()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FileTools::write_log("emptyimage.txt", "enqueue image is empty " + std::to_string(index++));
|
writelog("enqueue image is empty " + std::to_string(index++));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue