This commit is contained in:
13038267101 2023-12-06 10:47:22 +08:00
commit fc016443cf
7 changed files with 70 additions and 102 deletions

View File

@ -96,59 +96,6 @@ void CImageApplyAutoCrop::myWarpAffine(cv::InputArray _src, cv::OutputArray _dst
M, interpolation, borderType, borderValue.val); M, interpolation, borderType, borderValue.val);
} }
cv::Scalar CImageApplyAutoCrop::getBackGroudColor(const cv::Mat& image)
{
if (image.channels() == 3)
{
uchar table[768] = { 0 };
int hist_bgr[3][256] = { 0 };
int width = image.cols, height = image.rows, bytesPerLine = image.step;
memset(table, 255, 768);
unsigned char* ptr_data = image.data;
unsigned char b = 0;
for (uint i = 0; i < height; i++, ptr_data += bytesPerLine)
for (uint j = 0, x = 0; j < width; j++, x += 3)
{
b = table[ptr_data[x] + ptr_data[x + 1] + ptr_data[x + 2]];
for (uint k = 0; k < 3; k++)
hist_bgr[k][ptr_data[x + k] & b]++;
}
int max_vals[3] = { 0 };
cv::Scalar max_indexes(0, 0, 0);
for (uint i = 5; i < 256; i++)
for (uint j = 0; j < 3; j++)
if (hist_bgr[j][i] > max_vals[j])
{
max_vals[j] = hist_bgr[j][i];
max_indexes[j] = i;
}
return max_indexes;
}
else
{
uchar table[256] = { 0 };
int hist_bgr[256] = { 0 };
int width = image.cols, height = image.rows, bytesPerLine = image.step;
memset(table, 255, 256);
unsigned char* ptr_data = image.data;
unsigned char b = 0;
for (uint i = 0; i < height; i++, ptr_data += bytesPerLine)
for (uint j = 0, x = 0; j < width; j++, x ++)
hist_bgr[ptr_data[x] & table[ptr_data[x]]]++;
int max_vals = 5;
for (uint i = 5; i < 256; i++)
if (hist_bgr[i] > hist_bgr[max_vals])
max_vals = i;
return cv::Scalar(max_vals);
}
}
void CImageApplyAutoCrop::autoCrop_desaskew_fillBlank(cv::Mat& src, cv::Mat& dst, bool isAutoCrop, bool isDesaskew, bool isFillBlank, int dWidth, int dHeight, void CImageApplyAutoCrop::autoCrop_desaskew_fillBlank(cv::Mat& src, cv::Mat& dst, bool isAutoCrop, bool isDesaskew, bool isFillBlank, int dWidth, int dHeight,
bool isConvex, bool isColorBlank, double threshold, int noise, int indent, bool isNormalCrop, double fx, double fy) bool isConvex, bool isColorBlank, double threshold, int noise, int indent, bool isNormalCrop, double fx, double fy)
{ {
@ -226,7 +173,9 @@ void CImageApplyAutoCrop::autoCrop_desaskew_fillBlank(cv::Mat& src, cv::Mat& dst
boudingRect.width *= FX_FY; boudingRect.width *= FX_FY;
boudingRect.height *= FX_FY; boudingRect.height *= FX_FY;
blankColor = getBackGroudColor(resizeMat(boudingRect)); cv::Mat temp_bgc;
cv::resize(resizeMat(boudingRect), temp_bgc, cv::Size(200, 200));
blankColor = hg::getBackGroundColor(temp_bgc, cv::Mat(), threshold);
} }
else else
blankColor = cv::Scalar::all(255); blankColor = cv::Scalar::all(255);
@ -254,9 +203,9 @@ void CImageApplyAutoCrop::autoCrop_desaskew_fillBlank(cv::Mat& src, cv::Mat& dst
int h = rect.size.height; int h = rect.size.height;
int x = (dst.cols - w) / 2; int x = (dst.cols - w) / 2;
int y = (dst.rows - h) / 2; int y = (dst.rows - h) / 2;
dstTri[0] = cv::Point2f(0, h); dstTri[0] = cv::Point2f(x, y + h);
dstTri[1] = cv::Point2f(0, 0); dstTri[1] = cv::Point2f(x, y);
dstTri[2] = cv::Point2f(w, 0); dstTri[2] = cv::Point2f(x + w, y);
dstROI = dst(cv::Rect(x, y, w, h) & cv::Rect(0, 0, dst.cols, dst.rows)); dstROI = dst(cv::Rect(x, y, w, h) & cv::Rect(0, 0, dst.cols, dst.rows));
myWarpAffine(src, dstROI, cv::getAffineTransform(srcTri, dstTri), dstROI.size(), cv::INTER_LINEAR, cv::BORDER_CONSTANT, cv::Scalar::all(0)); myWarpAffine(src, dstROI, cv::getAffineTransform(srcTri, dstTri), dstROI.size(), cv::INTER_LINEAR, cv::BORDER_CONSTANT, cv::Scalar::all(0));

View File

@ -34,7 +34,8 @@
2023/05/15 v1.5.5 稿 2023/05/15 v1.5.5 稿
2023/05/23 v1.5.6 BUG 2023/05/23 v1.5.6 BUG
2023/11/02 v1.6 2023/11/02 v1.6
* v1.5.6 2023/12/05 v1.6.1 BUG
* v1.6.1
* ==================================================== * ====================================================
*/ */
@ -115,8 +116,6 @@ public:
private: private:
static void myWarpAffine(cv::InputArray _src, cv::OutputArray _dst, cv::InputArray _M0, cv::Size dsize, int flags, int borderType, const cv::Scalar& borderValue); static void myWarpAffine(cv::InputArray _src, cv::OutputArray _dst, cv::InputArray _M0, cv::Size dsize, int flags, int borderType, const cv::Scalar& borderValue);
static cv::Scalar getBackGroudColor(const cv::Mat& image);
private: private:
bool m_isCrop; bool m_isCrop;
bool m_isDesaskew; bool m_isDesaskew;

View File

@ -81,6 +81,7 @@ namespace settingsdsp_200
} }
hg_scanner_200::hg_scanner_200(const char* dev_name,int pid, usb_io* io) : hg_scanner(G100Serial, dev_name, io,pid) hg_scanner_200::hg_scanner_200(const char* dev_name,int pid, usb_io* io) : hg_scanner(G100Serial, dev_name, io,pid)
{ {
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "hg_scanner_200(%s) constructing ...\n", hg_log::format_ptr(this).c_str());
//pid_ = pid; //pid_ = pid;
initdevice(); initdevice();
@ -370,12 +371,18 @@ int hg_scanner_200::readusb(USBCB &usb)
} }
int hg_scanner_200::pop_image() int hg_scanner_200::pop_image()
{ {
std::lock_guard<std::mutex> lock(io_lock_);
int ret = SCANNER_ERR_OK; int ret = SCANNER_ERR_OK;
USBCB usbcb = { setting3288dsp::POP_IMAGE, 0, 0 }; USBCB usbcb = { setting3288dsp::POP_IMAGE, 0, 0 };
{
std::lock_guard<std::mutex> lock(io_lock_);
ret = writeusb(usbcb); ret = writeusb(usbcb);
}
if (ret != SCANNER_ERR_OK)
{
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "pop_image = %s\n", hg_scanner_err_name(ret));
}
return ret; return ret;
} }

View File

@ -87,8 +87,9 @@ hg_scanner_300::hg_scanner_300(const char* dev_name,int pid, usb_io* io) :
,papersize(pid) ,papersize(pid)
,is_devs_sleep_(false) ,is_devs_sleep_(false)
{ {
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "hg_scanner_300(%s) constructing ...\n", hg_log::format_ptr(this).c_str());
dsp_config.value = 0; dsp_config.value = 0;
dsp_config.params_3288.enableLed = 1; //默认值 dsp_config.params_3288.enableLed = 1; //暺䁅恕<EFBFBD>?
dsp_config.params_3288.isCorrect = 1; dsp_config.params_3288.isCorrect = 1;
int ret = initdevice(); int ret = initdevice();
@ -117,7 +118,7 @@ hg_scanner_300::hg_scanner_300(const char* dev_name,int pid, usb_io* io) :
firmware_sup_log_export_G300_ = year_date.compare("230430") >= 0 ? true : false; firmware_sup_log_export_G300_ = year_date.compare("230430") >= 0 ? true : false;
#ifndef MAPPING_FUNCTION_IN_BASE #ifndef MAPPING_FUNCTION_IN_BASE
init_setting_map(setting_map_, ARRAY_SIZE(setting_map_));//优先初始化 init_setting_map(setting_map_, ARRAY_SIZE(setting_map_));//隡睃<EFBFBD><EFBFBD><EFBFBD><EFBFBD>?
#endif #endif
if (init_settings(pid_)) if (init_settings(pid_))
@ -158,11 +159,11 @@ void hg_scanner_300::thread_handle_usb_read(void)
} }
//printf("usb.u32_Data = %d ret = %d\r\n",usb.u32_Data,ret); //printf("usb.u32_Data = %d ret = %d\r\n",usb.u32_Data,ret);
//如果设备出现卡纸 或者双张等设备信息问题需要等到设备进行发送stop才能停止。 所以始终以 "停止" 消息为结束信号 //<EFBFBD><EFBFBD>霈曉<EFBFBD><EFBFBD>箇緵<EFBFBD>∠爾 <20>𤥁<EFBFBD><F0A4A581><EFBFBD>撘删<E69298>霈曉<E99C88>靽⊥<E99DBD><E28AA5><EFBFBD>嚗屸<E59A97><EFBFBD><E996AC><EFBFBD>啗挽憭<E68CBD><E686AD><EFBFBD><E98AB5><EFBFBD><EFBFBD>top<6F><EFBFBD><E6BBA9>𨀣迫<F0A880A3>?<3F><>隞亙<E99A9E><EFBFBD>誑 "<22>𨀣迫" 瘨<><E798A8>銝箇<E98A9D><E7AE87>煺縑<E785BA>?
//如果有图的情况下,并且卡纸或双张等,设备会先发送卡纸双张信息。所以接受到错误信息之后,仍需要把图像取出来。 //<EFBFBD><EFBFBD><EFBFBD>匧㦛<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>僎銝𥪜㨃蝥豢<EFBFBD><EFBFBD><EFBFBD><EFBFBD>蝑㚁<EFBFBD>霈曉<EFBFBD>隡𡁜<EFBFBD><EFBFBD><EFBFBD><EFBFBD>㨃蝥詨<EFBFBD>撘牐縑<EFBFBD><EFBFBD><EFBFBD><EFBFBD>隞交𦻖<EFBFBD><EFBFBD><EFBFBD>躰秤靽⊥<EFBFBD>銋见<EFBFBD>嚗䔶<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>硋枂<EFBFBD><EFBFBD>?
if (ret == SCANNER_ERR_DEVICE_STOPPED) if (ret == SCANNER_ERR_DEVICE_STOPPED)
{ {
status_ = !savestatus_.empty() ? savestatus_[0] : SCANNER_ERR_OK;//以第一个消息为准 status_ = !savestatus_.empty() ? savestatus_[0] : SCANNER_ERR_OK;//隞亦洵銝<EFBFBD>銝芣<EFBFBD><EFBFBD>臭蛹<EFBFBD>?
savestatus_.clear(); savestatus_.clear();
if (user_cancel_) if (user_cancel_)
{ {
@ -239,7 +240,7 @@ void hg_scanner_300::thread_handle_usb_read(void)
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "%s\n", hg_scanner_err_description(status_)); VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "%s\n", hg_scanner_err_description(status_));
break; break;
} }
if (sw.elapsed_ms() > 30000 && img_conf_.resolution_dst != 600)//防止状态信息一直取不上来导致卡死 if (sw.elapsed_ms() > 30000 && img_conf_.resolution_dst != 600)//<EFBFBD>脫迫<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>銝滢<EFBFBD><EFBFBD>亙紡<EFBFBD>游㨃甇?
{ {
if ((img_conf_.papertype == TwSS::MaxSize || img_conf_.papertype == TwSS::USStatement) && pid_ == 0x0300 && firmware_sup_dpi_600) if ((img_conf_.papertype == TwSS::MaxSize || img_conf_.papertype == TwSS::USStatement) && pid_ == 0x0300 && firmware_sup_dpi_600)
{ {
@ -247,30 +248,30 @@ void hg_scanner_300::thread_handle_usb_read(void)
} }
else else
{ {
if (!savestatus_.empty())//以第一个消息为准 if (!savestatus_.empty())//隞亦洵銝<EFBFBD>銝芣<EFBFBD><EFBFBD>臭蛹<EFBFBD>?
{ {
status_ = savestatus_[0]; status_ = savestatus_[0];
} }
savestatus_.clear(); savestatus_.clear();
hg_log::log(LOG_LEVEL_WARNING, "Get Status TimeOut,get image out 30S\n"); hg_log::log(LOG_LEVEL_WARNING, "Get Status TimeOut,get image out 30S\n");
notify_ui_working_status(hg_log::lang_load(ID_STATU_DESC_SCANNER_ERR_DEVICE_GET_IMAGE_OUTTIME), SANE_EVENT_ERROR, status_); // 鍙栧浘閫氫俊瓒呮椂 notify_ui_working_status(hg_log::lang_load(ID_STATU_DESC_SCANNER_ERR_DEVICE_GET_IMAGE_OUTTIME), SANE_EVENT_ERROR, status_); // <EFBFBD>蹱𡵆瘚㗛𢥫瘞思<EFBFBD><EFBFBD>鍦䴴璊?
break; break;
} }
} }
if (sw.elapsed_s() > 130) if (sw.elapsed_s() > 130)
{ {
if (!savestatus_.empty())//以第一个消息为准 if (!savestatus_.empty())//隞亦洵銝<EFBFBD>銝芣<EFBFBD><EFBFBD>臭蛹<EFBFBD>?
{ {
status_ = savestatus_[0]; status_ = savestatus_[0];
} }
savestatus_.clear(); savestatus_.clear();
hg_log::log(LOG_LEVEL_WARNING, "MaxSize TimeOut,Get Image 130s\n"); hg_log::log(LOG_LEVEL_WARNING, "MaxSize TimeOut,Get Image 130s\n");
notify_ui_working_status(hg_log::lang_load(ID_STATU_DESC_SCANNER_ERR_DEVICE_GET_IMAGE_OUTTIME), SANE_EVENT_ERROR, status_); // 鍙栧浘閫氫俊瓒呮椂 notify_ui_working_status(hg_log::lang_load(ID_STATU_DESC_SCANNER_ERR_DEVICE_GET_IMAGE_OUTTIME), SANE_EVENT_ERROR, status_); // <EFBFBD>蹱𡵆瘚㗛𢥫瘞思<EFBFBD><EFBFBD>鍦䴴璊?
break; break;
} }
if (ret == SCANNER_ERR_OK && usb.u32_Count > 0) if (ret == SCANNER_ERR_OK && usb.u32_Count > 0)
{ {
int totalNum = usb.u32_Count & 0x3fffffff; // 2022-08-04: 兼容Android默认图片大小均在1GB以内 int totalNum = usb.u32_Count & 0x3fffffff; // 2022-08-04: <EFBFBD>澆捆Android嚗屸<EFBFBD>霈文㦛<EFBFBD><EFBFBD>之撠誩<EFBFBD><EFBFBD>?GB隞亙<E99A9E>
VLOG_MINI_2(LOG_LEVEL_WARNING, "Get Scaner Image Size:%d bytes,Image Num[%d]\n", totalNum,img_num); VLOG_MINI_2(LOG_LEVEL_WARNING, "Get Scaner Image Size:%d bytes,Image Num[%d]\n", totalNum,img_num);
img_num++; img_num++;
if (totalNum) if (totalNum)
@ -381,7 +382,7 @@ int hg_scanner_300::do_start(void)
{ {
return ret; return ret;
} }
if (is_devs_sleep_)//设备在睡眠的状态当中获取固件是失败的,所以在这个地方进行标志位设置。(总感觉不保险) if (is_devs_sleep_)//霈曉<EFBFBD><EFBFBD>函辺<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>銝剛繮<EFBFBD>硋𤐄隞嗆糓憭梯揖<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>隞亙銁餈嗘葵<EFBFBD>唳䲮餈𥡝<EFBFBD><EFBFBD><EFBFBD><EFBFBD>雿滩挽蝵柴<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>閫劐<EFBFBD>靽嗪埯嚗?
{ {
is_devs_sleep_ = false; is_devs_sleep_ = false;
set_kernelsnap_ver(); set_kernelsnap_ver();
@ -476,6 +477,10 @@ int hg_scanner_300::pop_image()
std::lock_guard<std::mutex> lock(io_lock_); std::lock_guard<std::mutex> lock(io_lock_);
ret = writeusb(usbcb); ret = writeusb(usbcb);
} }
if (ret != SCANNER_ERR_OK)
{
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "pop_image = %s\n", hg_scanner_err_name(ret));
}
return ret; return ret;
} }
@ -802,7 +807,7 @@ int hg_scanner_300::initdevice()
if (status_ != SCANNER_ERR_DEVICE_SLEEPING) if (status_ != SCANNER_ERR_DEVICE_SLEEPING)
{ {
set_kernelsnap_ver(); set_kernelsnap_ver();
is_devs_sleep_ = false; // 睡眠唤醒 客户提前点击设置这边固件版本号 还没有做判断的 is_devs_sleep_ = false; // <EFBFBD><EFBFBD><EFBFBD><EFBFBD><E691B0><EFBCB8>𣂼<EFBFBD><F0A382BC>孵稬霈曄蔭餈躰器<E8BAB0>箔辣<E7AE94><E8BEA3>𧋦<EFBFBD>?餈䀹瓷<E480B9><EFBFBD><E58CA7>斗鱏<E69697>?
} }
return status_; return status_;
} }
@ -834,7 +839,7 @@ void hg_scanner_300::writedown_image_configuration(void)
// ic.hardwarecaps.is_autopaper = dsp_config_.params_dsp.is_autopaper; // ic.hardwarecaps.is_autopaper = dsp_config_.params_dsp.is_autopaper;
ic.hardwarecaps.capturepixtype = 0; //暂无参数 获取图像类型 ic.hardwarecaps.capturepixtype = 0; //暂无参数 获取图像类型
ic.hardwarecaps.lowpowermode = LowPowerMode::Min_None; //暂无参数 设置休眠时间 两个参数3399未使用 ic.hardwarecaps.lowpowermode = LowPowerMode::Min_None; //<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㺭 霈曄蔭隡𤑳<E99AA1><F0A491B3>園𡢿 銝支葵<E694AF><E891B5>㺭3399<39>芯蝙<E88AAF>?
image_configuration(ic); image_configuration(ic);
} }
void hg_scanner_300::printf_devconfig(setting_hardware::HGSCANCONF_3288 *d) void hg_scanner_300::printf_devconfig(setting_hardware::HGSCANCONF_3288 *d)
@ -975,7 +980,7 @@ int hg_scanner_300::get_correction_image(int inx , int dpi, int mode)
cv::Mat white_mat; cv::Mat white_mat;
cv::Mat black_mat;; cv::Mat black_mat;;
for (size_t i = 0; i < 2; i++) //黑白一起保存下来 for (size_t i = 0; i < 2; i++) //暺𤑳蒾銝<EFBFBD>韏瑚<EFBFBD>摮䀝<EFBFBD><EFBFBD>?
{ {
vector<unsigned char> imagedata; vector<unsigned char> imagedata;
@ -1017,7 +1022,7 @@ int hg_scanner_300::get_correction_image(int inx , int dpi, int mode)
if (mat.empty()) if (mat.empty())
{ {
VLOG_MINI_1(LOG_LEVEL_WARNING, "get_correction_image image is NULL:%d\n", image_info.info.params.status); VLOG_MINI_1(LOG_LEVEL_WARNING, "get_correction_image image is NULL:%d\n", image_info.info.params.status);
return SCANNER_ERR_NO_DATA; //只要有一张图没有 直接退了 return SCANNER_ERR_NO_DATA; //<EFBFBD><EFBFBD><EFBFBD><EFBFBD>撘惩㦛瘝⊥<EFBFBD> <20>湔𦻖<E6B994><F0A6BB96>鈭?
} }
float f = 0.0; float f = 0.0;
@ -1050,7 +1055,7 @@ std::string hg_scanner_300::get_firmware_version()
{ {
char buf[20] = { 0 }; char buf[20] = { 0 };
int ret = SCANNER_ERR_OK, int ret = SCANNER_ERR_OK,
len = 10; //协议定义长度为10 100 200 =8 len = 10; //<EFBFBD>讛悅摰帋<EFBFBD><EFBFBD>踹漲銝?0 100 200 =8
USBCB cmd = { setting3288dsp::GET_FW_VERSION,len,0,}; USBCB cmd = { setting3288dsp::GET_FW_VERSION,len,0,};
{ {

View File

@ -550,7 +550,10 @@ int hg_scanner_302::pop_first_image(void)
std::lock_guard<std::mutex> lock(io_lock_); std::lock_guard<std::mutex> lock(io_lock_);
int ret = write_register(setting3399::SR_IM_POP, 1); int ret = write_register(setting3399::SR_IM_POP, 1);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "popup first image = %s\n", hg_scanner_err_name(ret)); if (ret != SCANNER_ERR_OK)
{
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "pop_first_image = %s\n", hg_scanner_err_name(ret));
}
return ret; return ret;
} }

View File

@ -82,8 +82,9 @@ hg_scanner_306::hg_scanner_306(const char* dev_name,int pid, usb_io* io) :
, frame_width_(0) , frame_width_(0)
, frame_hegiht_(0) , frame_hegiht_(0)
{ {
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "hg_scanner_306(%s) constructing ...\n", hg_log::format_ptr(this).c_str());
dsp_config.value = 0; dsp_config.value = 0;
dsp_config.params_7010.enableLed = 1; //默认值 dsp_config.params_7010.enableLed = 1; //暺䁅恕<EFBFBD>?
dsp_config.params_7010.isCorrect = 1; dsp_config.params_7010.isCorrect = 1;
int ret = get_device_type(firmware_sup_device_7010); int ret = get_device_type(firmware_sup_device_7010);
@ -100,7 +101,7 @@ hg_scanner_306::hg_scanner_306(const char* dev_name,int pid, usb_io* io) :
} }
#ifndef MAPPING_FUNCTION_IN_BASE #ifndef MAPPING_FUNCTION_IN_BASE
init_setting_map(setting_map_, ARRAY_SIZE(setting_map_));//优先初始化 init_setting_map(setting_map_, ARRAY_SIZE(setting_map_));//隡睃<EFBFBD><EFBFBD><EFBFBD><EFBFBD>?
#endif #endif
if (init_settings(pid_)) if (init_settings(pid_))
init_settings((jsontext1 + jsontext2 + jsontext3).c_str()); init_settings((jsontext1 + jsontext2 + jsontext3).c_str());
@ -135,11 +136,11 @@ void hg_scanner_306::thread_handle_usb_read(void)
} }
//printf("usb.u32_Data = %d ret = %d\r\n",usb.u32_Data,ret); //printf("usb.u32_Data = %d ret = %d\r\n",usb.u32_Data,ret);
//如果设备出现卡纸 或者双张等设备信息问题需要等到设备进行发送stop才能停止。 所以始终以 "停止" 消息为结束信号 //<EFBFBD><EFBFBD>霈曉<EFBFBD><EFBFBD>箇緵<EFBFBD>∠爾 <20>𤥁<EFBFBD><F0A4A581><EFBFBD>撘删<E69298>霈曉<E99C88>靽⊥<E99DBD><E28AA5><EFBFBD>嚗屸<E59A97><EFBFBD><E996AC><EFBFBD>啗挽憭<E68CBD><E686AD><EFBFBD><E98AB5><EFBFBD><EFBFBD>top<6F><EFBFBD><E6BBA9>𨀣迫<F0A880A3>?<3F><>隞亙<E99A9E><EFBFBD>誑 "<22>𨀣迫" 瘨<><E798A8>銝箇<E98A9D><E7AE87>煺縑<E785BA>?
//如果有图的情况下,并且卡纸或双张等,设备会先发送卡纸双张信息。所以接受到错误信息之后,仍需要把图像取出来。 //<EFBFBD><EFBFBD><EFBFBD>匧㦛<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>僎銝𥪜㨃蝥豢<EFBFBD><EFBFBD><EFBFBD><EFBFBD>蝑㚁<EFBFBD>霈曉<EFBFBD>隡𡁜<EFBFBD><EFBFBD><EFBFBD><EFBFBD>㨃蝥詨<EFBFBD>撘牐縑<EFBFBD><EFBFBD><EFBFBD><EFBFBD>隞交𦻖<EFBFBD><EFBFBD><EFBFBD>躰秤靽⊥<EFBFBD>銋见<EFBFBD>嚗䔶<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>硋枂<EFBFBD><EFBFBD>?
if (ret == SCANNER_ERR_DEVICE_STOPPED) if (ret == SCANNER_ERR_DEVICE_STOPPED)
{ {
status_ = !savestatus_.empty() ? savestatus_[0] : SCANNER_ERR_OK;//以第一个消息为准 status_ = !savestatus_.empty() ? savestatus_[0] : SCANNER_ERR_OK;//隞亦洵銝<EFBFBD>銝芣<EFBFBD><EFBFBD>臭蛹<EFBFBD>?
savestatus_.clear(); savestatus_.clear();
if (user_cancel_) if (user_cancel_)
{ {
@ -216,7 +217,7 @@ void hg_scanner_306::thread_handle_usb_read(void)
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "%s\n", hg_scanner_err_description(status_)); VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "%s\n", hg_scanner_err_description(status_));
break; break;
} }
if (sw.elapsed_ms() > 30000 && img_conf_.resolution_dst != 600)//防止状态信息一直取不上来导致卡死 if (sw.elapsed_ms() > 30000 && img_conf_.resolution_dst != 600)//<EFBFBD>脫迫<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>銝滢<EFBFBD><EFBFBD>亙紡<EFBFBD>游㨃甇?
{ {
if ((img_conf_.papertype == TwSS::MaxSize || img_conf_.papertype == TwSS::USStatement) && pid_ == 0x0300 && firmware_sup_dpi_600) if ((img_conf_.papertype == TwSS::MaxSize || img_conf_.papertype == TwSS::USStatement) && pid_ == 0x0300 && firmware_sup_dpi_600)
{ {
@ -224,25 +225,25 @@ void hg_scanner_306::thread_handle_usb_read(void)
} }
else else
{ {
if (!savestatus_.empty())//以第一个消息为准 if (!savestatus_.empty())//隞亦洵銝<EFBFBD>銝芣<EFBFBD><EFBFBD>臭蛹<EFBFBD>?
{ {
status_ = savestatus_[0]; status_ = savestatus_[0];
} }
savestatus_.clear(); savestatus_.clear();
hg_log::log(LOG_LEVEL_WARNING, "Get Status TimeOut,get image out 30S\n"); hg_log::log(LOG_LEVEL_WARNING, "Get Status TimeOut,get image out 30S\n");
notify_ui_working_status(hg_log::lang_load(ID_STATU_DESC_SCANNER_ERR_DEVICE_GET_IMAGE_OUTTIME), SANE_EVENT_ERROR, status_); // 鍙栧浘閫氫俊瓒呮椂 notify_ui_working_status(hg_log::lang_load(ID_STATU_DESC_SCANNER_ERR_DEVICE_GET_IMAGE_OUTTIME), SANE_EVENT_ERROR, status_); // <EFBFBD>蹱𡵆瘚㗛𢥫瘞思<EFBFBD><EFBFBD>鍦䴴璊?
break; break;
} }
} }
if (sw.elapsed_s() > 130) if (sw.elapsed_s() > 130)
{ {
if (!savestatus_.empty())//以第一个消息为准 if (!savestatus_.empty())//隞亦洵銝<EFBFBD>銝芣<EFBFBD><EFBFBD>臭蛹<EFBFBD>?
{ {
status_ = savestatus_[0]; status_ = savestatus_[0];
} }
savestatus_.clear(); savestatus_.clear();
hg_log::log(LOG_LEVEL_WARNING, "MaxSize TimeOut,Get Image 130s\n"); hg_log::log(LOG_LEVEL_WARNING, "MaxSize TimeOut,Get Image 130s\n");
notify_ui_working_status(hg_log::lang_load(ID_STATU_DESC_SCANNER_ERR_DEVICE_GET_IMAGE_OUTTIME), SANE_EVENT_ERROR, status_); // 鍙栧浘閫氫俊瓒呮椂 notify_ui_working_status(hg_log::lang_load(ID_STATU_DESC_SCANNER_ERR_DEVICE_GET_IMAGE_OUTTIME), SANE_EVENT_ERROR, status_); // <EFBFBD>蹱𡵆瘚㗛𢥫瘞思<EFBFBD><EFBFBD>鍦䴴璊?
break; break;
} }
if (ret == SCANNER_ERR_OK && usb.u32_Count > 0) if (ret == SCANNER_ERR_OK && usb.u32_Count > 0)
@ -337,7 +338,7 @@ int hg_scanner_306::do_start(void)
{ {
return ret; return ret;
} }
if (is_devs_sleep_)//设备在睡眠的状态当中获取固件是失败的,所以在这个地方进行标志位设置。(总感觉不保险) if (is_devs_sleep_)//霈曉<EFBFBD><EFBFBD>函辺<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>銝剛繮<EFBFBD>硋𤐄隞嗆糓憭梯揖<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>隞亙銁餈嗘葵<EFBFBD>唳䲮餈𥡝<EFBFBD><EFBFBD><EFBFBD><EFBFBD>雿滩挽蝵柴<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>閫劐<EFBFBD>靽嗪埯嚗?
{ {
is_devs_sleep_ = false; is_devs_sleep_ = false;
set_kernelsnap_ver(); set_kernelsnap_ver();
@ -432,6 +433,10 @@ int hg_scanner_306::pop_image()
std::lock_guard<std::mutex> lock(io_lock_); std::lock_guard<std::mutex> lock(io_lock_);
ret = writeusb(usbcb); ret = writeusb(usbcb);
} }
if (ret != SCANNER_ERR_OK)
{
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "pop_image = %s\n", hg_scanner_err_name(ret));
}
return ret; return ret;
} }
@ -758,7 +763,7 @@ int hg_scanner_306::initdevice()
if (status_ != SCANNER_ERR_DEVICE_SLEEPING) if (status_ != SCANNER_ERR_DEVICE_SLEEPING)
{ {
set_kernelsnap_ver(); set_kernelsnap_ver();
is_devs_sleep_ = false; // 睡眠唤醒 客户提前点击设置这边固件版本号 还没有做判断的 is_devs_sleep_ = false; // <EFBFBD><EFBFBD><EFBFBD><EFBFBD><E691B0><EFBCB8>𣂼<EFBFBD><F0A382BC>孵稬霈曄蔭餈躰器<E8BAB0>箔辣<E7AE94><E8BEA3>𧋦<EFBFBD>?餈䀹瓷<E480B9><EFBFBD><E58CA7>斗鱏<E69697>?
} }
return SCANNER_ERR_OK; return SCANNER_ERR_OK;
} }
@ -790,7 +795,7 @@ void hg_scanner_306::writedown_image_configuration(void)
// ic.hardwarecaps.is_autopaper = dsp_config_.params_dsp.is_autopaper; // ic.hardwarecaps.is_autopaper = dsp_config_.params_dsp.is_autopaper;
ic.hardwarecaps.capturepixtype = 0; //暂无参数 获取图像类型 ic.hardwarecaps.capturepixtype = 0; //暂无参数 获取图像类型
ic.hardwarecaps.lowpowermode = LowPowerMode::Min_None; //暂无参数 设置休眠时间 两个参数3399未使用 ic.hardwarecaps.lowpowermode = LowPowerMode::Min_None; //<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㺭 霈曄蔭隡𤑳<E99AA1><F0A491B3>園𡢿 銝支葵<E694AF><E891B5>㺭3399<39>芯蝙<E88AAF>?
image_configuration(ic); image_configuration(ic);
} }
void hg_scanner_306::printf_devconfig(setting_hardware::HGSCANCONF_7010 *d) void hg_scanner_306::printf_devconfig(setting_hardware::HGSCANCONF_7010 *d)
@ -870,7 +875,7 @@ int hg_scanner_306::get_correction_image(int inx , int dpi, int mode)
cv::Mat white_mat; cv::Mat white_mat;
cv::Mat black_mat;; cv::Mat black_mat;;
for (size_t i = 0; i < 2; i++) //黑白一起保存下来 for (size_t i = 0; i < 2; i++) //暺𤑳蒾銝<EFBFBD>韏瑚<EFBFBD>摮䀝<EFBFBD><EFBFBD>?
{ {
vector<unsigned char> imagedata; vector<unsigned char> imagedata;
@ -908,7 +913,7 @@ int hg_scanner_306::get_correction_image(int inx , int dpi, int mode)
if (mat.empty()) if (mat.empty())
{ {
VLOG_MINI_1(LOG_LEVEL_WARNING, "get_correction_image image is NULL:%d\n", image_info.info.params.status); VLOG_MINI_1(LOG_LEVEL_WARNING, "get_correction_image image is NULL:%d\n", image_info.info.params.status);
return SCANNER_ERR_NO_DATA; //只要有一张图没有 直接退了 return SCANNER_ERR_NO_DATA; //<EFBFBD><EFBFBD><EFBFBD><EFBFBD>撘惩㦛瘝⊥<EFBFBD> <20>湔𦻖<E6B994><F0A6BB96>鈭?
} }
float f = 0.0; float f = 0.0;
@ -934,7 +939,7 @@ std::string hg_scanner_306::get_firmware_version()
{ {
char buf[20] = { 0 }; char buf[20] = { 0 };
int ret = SCANNER_ERR_OK, int ret = SCANNER_ERR_OK,
len = 10; //协议定义长度为10 100 200 =8 len = 10; //<EFBFBD>讛悅摰帋<EFBFBD><EFBFBD>踹漲銝?0 100 200 =8
USBCB cmd = { setting3288dsp::GET_FW_VERSION,len,0,}; USBCB cmd = { setting3288dsp::GET_FW_VERSION,len,0,};
{ {
@ -1221,13 +1226,13 @@ int hg_scanner_306::set_scan_lock_check_val(string str)
} }
//#enum scanner_err //#enum scanner_err
//#{ //#{
//# SCANNER_ERR_OK = 0, //设备正常状态 //# SCANNER_ERR_OK = 0, //霈曉<EFBFBD><EFBFBD><EFBFBD><EFBFBD>?
//# SCANNER_ERR_SLEEP, 1 //设备处于休眠当中 //# SCANNER_ERR_SLEEP, 1 //设备处于休眠当中
//# SCANNER_ERR_UPDATE_OK, 2 //设备更新:成功 //# SCANNER_ERR_UPDATE_OK, 2 //霈曉<EFBFBD><EFBFBD>湔鰵嚗𡁏<EFBFBD><EFBFBD>?
//# SCANNER_ERR_UPDATE_UPDATAING, 3 //设备更新:进行中 //# SCANNER_ERR_UPDATE_UPDATAING, 3 //设备更新:进行中
//# SCANNER_ERR_UPDATE_CHECK_VAL_ERROR, 4 //设备更新:校验检测错误 //# SCANNER_ERR_UPDATE_CHECK_VAL_ERROR, 4 //霈曉<EFBFBD><EFBFBD>湔鰵嚗𡁏嵗撉峕<EFBFBD>瘚钅<EFBFBD>霂?
//# SCANNER_ERR_UPDATE_CHECK_FILE_LOST, 5 //设备更新:文件丢失 //# SCANNER_ERR_UPDATE_CHECK_FILE_LOST, 5 //霈曉<EFBFBD><EFBFBD>湔鰵嚗𡁏<EFBFBD>隞嗡腺憭?
//# SCANNER_ERR_UPDATE_UNZIP_FAIL, 6 //设备更新:解压失败 //# SCANNER_ERR_UPDATE_UNZIP_FAIL, 6 //霈曉<EFBFBD><EFBFBD>湔鰵嚗朞圾<EFBFBD>见仃韐?
//#}; //#};
int hg_scanner_306::set_firmware_upgrade(std::string str) int hg_scanner_306::set_firmware_upgrade(std::string str)
{ {

View File

@ -842,7 +842,7 @@ namespace hg_imgproc
SIZE temp_Size = papersize_.GetPaperSize(img_conf_.papertype, dpi,img_conf_.paperAlign); SIZE temp_Size = papersize_.GetPaperSize(img_conf_.papertype, dpi,img_conf_.paperAlign);
cv::Size cvSize(temp_Size.cx, temp_Size.cy); cv::Size cvSize(temp_Size.cx, temp_Size.cy);
CImageApplyAutoCrop crop(img_conf_.is_autocrop,img_conf_.autodescrew,img_conf_.fillbackground,cvSize,img_conf_.is_convex,img_conf_.isfillcolor); CImageApplyAutoCrop crop(img_conf_.is_autocrop,img_conf_.autodescrew,img_conf_.fillbackground,cvSize,img_conf_.is_convex,img_conf_.isfillcolor, 30);
crop.apply(mats,img_conf_.is_duplex); crop.apply(mats,img_conf_.is_duplex);
mats_ = mats; mats_ = mats;