mirror of http://192.168.1.51:8099/lmh188/twain3.0
修复扫描丢图问题
This commit is contained in:
parent
e580e312a8
commit
6a8302a066
|
@ -42,7 +42,10 @@ GScanO1003399::GScanO1003399():
|
||||||
{
|
{
|
||||||
im_data.reset(new std::vector<char>());
|
im_data.reset(new std::vector<char>());
|
||||||
open(0, 0);
|
open(0, 0);
|
||||||
|
if (!m_usbthread.get()) {
|
||||||
|
b_usbthread = true;
|
||||||
|
m_usbthread.reset(new thread(&GScanO1003399::usb_run, this));
|
||||||
|
}
|
||||||
devState = DEV_STOP;
|
devState = DEV_STOP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,7 +116,6 @@ void GScanO1003399::DogEar_callback(std::function<void(int)> fun)
|
||||||
}
|
}
|
||||||
static int aquirenum = 0;
|
static int aquirenum = 0;
|
||||||
static int getimgnum = 0;
|
static int getimgnum = 0;
|
||||||
static StopWatch stopwatch;
|
|
||||||
int GScanO1003399::aquire_bmpdata(std::vector<unsigned char>& bmpdata)
|
int GScanO1003399::aquire_bmpdata(std::vector<unsigned char>& bmpdata)
|
||||||
{
|
{
|
||||||
StopWatch sw;
|
StopWatch sw;
|
||||||
|
@ -150,8 +152,6 @@ int GScanO1003399::aquire_bmpdata(std::vector<unsigned char>& bmpdata)
|
||||||
UpdateScanInfo(get_imgnReaded(), countNTransfered());
|
UpdateScanInfo(get_imgnReaded(), countNTransfered());
|
||||||
image--;
|
image--;
|
||||||
sw.reset();
|
sw.reset();
|
||||||
FileTools::writelog(log_DEBUG, "3399上层取图间隔 " + to_string(stopwatch.elapsed_ms()));
|
|
||||||
stopwatch.reset();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
DoEvents();
|
DoEvents();
|
||||||
|
@ -327,6 +327,7 @@ void GScanO1003399::Scanner_StartScan(UINT16 count)
|
||||||
{
|
{
|
||||||
devState = DEV_WRONG;
|
devState = DEV_WRONG;
|
||||||
Set_ErrorCode(COUNT_MODE);
|
Set_ErrorCode(COUNT_MODE);
|
||||||
|
scanflag = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//if (!Get_Scanner_PaperOn())
|
//if (!Get_Scanner_PaperOn())
|
||||||
|
@ -337,10 +338,6 @@ void GScanO1003399::Scanner_StartScan(UINT16 count)
|
||||||
//}
|
//}
|
||||||
|
|
||||||
start();
|
start();
|
||||||
if (!m_usbthread.get()) {
|
|
||||||
b_usbthread = true;
|
|
||||||
m_usbthread.reset(new thread(&GScanO1003399::usb_run, this));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GScanO1003399::Stop_scan()
|
void GScanO1003399::Stop_scan()
|
||||||
|
@ -533,14 +530,18 @@ bool GScanO1003399::is_dev_tx()
|
||||||
{
|
{
|
||||||
return scanner_read_reg(m_usb, SR_IM_TXING);
|
return scanner_read_reg(m_usb, SR_IM_TXING);
|
||||||
}
|
}
|
||||||
static StopWatch swatch;
|
|
||||||
void GScanO1003399::im_rx()
|
void GScanO1003399::im_rx()
|
||||||
{
|
{
|
||||||
if (!is_rx() && !is_dev_tx())
|
|
||||||
{
|
|
||||||
fu_rx = m_imgthread.enqueue([this] {
|
fu_rx = m_imgthread.enqueue([this] {
|
||||||
while (im_dev_count()){
|
while (im_dev_count()){
|
||||||
/* code */
|
/* code */
|
||||||
|
if (is_dev_tx())
|
||||||
|
{
|
||||||
|
this_thread::sleep_for(chrono::microseconds(20));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (keeplastimg)
|
if (keeplastimg)
|
||||||
{
|
{
|
||||||
this_thread::sleep_for(chrono::microseconds(10));
|
this_thread::sleep_for(chrono::microseconds(10));
|
||||||
|
@ -565,8 +566,6 @@ void GScanO1003399::im_rx()
|
||||||
else
|
else
|
||||||
image++;
|
image++;
|
||||||
UpdateScanInfo(countNReaded(), get_imgTransfered());
|
UpdateScanInfo(countNReaded(), get_imgTransfered());
|
||||||
FileTools::writelog(log_DEBUG, "3399usb取图间隔 " + to_string(swatch.elapsed_ms()));
|
|
||||||
swatch.reset();
|
|
||||||
imgs.Put(buffi);
|
imgs.Put(buffi);
|
||||||
fu_imgpro.push(m_imgprocthread.enqueue([this] {
|
fu_imgpro.push(m_imgprocthread.enqueue([this] {
|
||||||
imgproce(imgs.Take());
|
imgproce(imgs.Take());
|
||||||
|
@ -579,7 +578,6 @@ void GScanO1003399::im_rx()
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
int GScanO1003399::read_data(void* data, int length, int timeout)
|
int GScanO1003399::read_data(void* data, int length, int timeout)
|
||||||
{
|
{
|
||||||
|
@ -643,8 +641,38 @@ void GScanO1003399::imgproce(std::shared_ptr<std::vector<char>>& buff)
|
||||||
FileTools::writelog(log_ERROR, e.what());
|
FileTools::writelog(log_ERROR, e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FileTools::writelog(log_DEBUG, "3399图像解码耗时 " + to_string(sw.elapsed_ms()));
|
FileTools::writelog(log_DEBUG, "图像解码耗时 " + to_string(sw.elapsed_ms()));
|
||||||
|
sw.reset();
|
||||||
buffs.clear();
|
buffs.clear();
|
||||||
|
if (m_param.imageRotateDegree != 0.0 || m_param.is_backrotate180 || m_param.is_autotext)
|
||||||
|
{
|
||||||
|
CImageApplyRotation::RotationType type;
|
||||||
|
if (m_param.imageRotateDegree > 89.0f && m_param.imageRotateDegree < 91.0f)
|
||||||
|
type = CImageApplyRotation::RotationType::Rotate_90_clockwise;
|
||||||
|
else if (m_param.imageRotateDegree > 269.0f && m_param.imageRotateDegree < 271.0f)
|
||||||
|
type = CImageApplyRotation::RotationType::Rotate_90_anti_clockwise;
|
||||||
|
else if (m_param.imageRotateDegree > 179.0f && m_param.imageRotateDegree < 181.0f)
|
||||||
|
type = CImageApplyRotation::RotationType::Rotate_180;
|
||||||
|
else
|
||||||
|
type = CImageApplyRotation::RotationType::Invalid;
|
||||||
|
|
||||||
|
if (m_param.is_autotext)
|
||||||
|
type = CImageApplyRotation::RotationType::AutoTextOrientation;
|
||||||
|
|
||||||
|
TCHAR szIniFile[MAX_PATH] = { 0 };
|
||||||
|
SHGetSpecialFolderPath(NULL, szIniFile, CSIDL_WINDOWS, TRUE);
|
||||||
|
#ifdef LANXUM
|
||||||
|
_tcscat(szIniFile, _T("\\twain_32\\LANXUMSCAN\\tessdata"));
|
||||||
|
#else
|
||||||
|
_tcscat(szIniFile, _T("\\twain_32\\HuaGoScan\\tessdata"));
|
||||||
|
#endif //
|
||||||
|
int iLen = WideCharToMultiByte(CP_ACP, 0, szIniFile, -1, NULL, 0, NULL, NULL);
|
||||||
|
char* chRtn = new char[iLen * sizeof(char)];
|
||||||
|
WideCharToMultiByte(CP_ACP, 0, szIniFile, -1, chRtn, iLen, NULL, NULL);
|
||||||
|
CImageApplyRotation(type, m_param.is_backrotate180, m_param.resolution_dst, chRtn).apply(mats,m_param.is_duplex);
|
||||||
|
delete[] chRtn;
|
||||||
|
}
|
||||||
|
FileTools::writelog(log_DEBUG, "图像旋转耗时 " + to_string(sw.elapsed_ms()));
|
||||||
if (m_param.automaticcolor)
|
if (m_param.automaticcolor)
|
||||||
{
|
{
|
||||||
CImageApplyColorRecognition(m_param.automaticcolortype == 1 ? CImageApplyColorRecognition::ColorRecognitionMode::Color_Gray : CImageApplyColorRecognition::ColorRecognitionMode::Color_Mono).apply(mats,m_param.is_duplex);
|
CImageApplyColorRecognition(m_param.automaticcolortype == 1 ? CImageApplyColorRecognition::ColorRecognitionMode::Color_Gray : CImageApplyColorRecognition::ColorRecognitionMode::Color_Mono).apply(mats,m_param.is_duplex);
|
||||||
|
|
|
@ -819,7 +819,8 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
|
||||||
if (vid == 0 || pid == 0)
|
if (vid == 0 || pid == 0)
|
||||||
{
|
{
|
||||||
//ShellExecute(NULL, TEXT("open"), GetHidedlgPath(), CString("201"), NULL, SW_HIDE);
|
//ShellExecute(NULL, TEXT("open"), GetHidedlgPath(), CString("201"), NULL, SW_HIDE);
|
||||||
showmsg("¾¯¸æ", msgs[(UsbSupported)201]);
|
//showmsg("警告", msgs[(UsbSupported)201]);
|
||||||
|
ShellExecute(NULL, TEXT("open"), GetHidedlgPath(), CString("未找到扫描仪!请检查电源或者USB连接线是否接通! 警告"), NULL, SW_HIDE);
|
||||||
if (hMutex) {
|
if (hMutex) {
|
||||||
CloseHandle(hMutex);
|
CloseHandle(hMutex);
|
||||||
hMutex = NULL;
|
hMutex = NULL;
|
||||||
|
|
Loading…
Reference in New Issue