This commit is contained in:
13038267101 2023-11-24 16:22:11 +08:00
commit cbeb2f5653
5 changed files with 38 additions and 5 deletions

View File

@ -3138,6 +3138,9 @@ hg_imgproc::IMGPRCPARAM hg_scanner::get_image_process_object(int model)
param.width = mat_width; param.width = mat_width;
param.height = mat_height; param.height = mat_height;
} }
param.is_sup_real_300dpi_ = firmware_sup_dpi_300;
param.is_sup_real_600dpi_ = firmware_sup_dpi_600;
param.device_7010 = firmware_sup_device_7010; param.device_7010 = firmware_sup_device_7010;
//img_conf_.brightness = (float)bright_; //img_conf_.brightness = (float)bright_;
//img_conf_.contrast = (float)contrast_; //img_conf_.contrast = (float)contrast_;

View File

@ -1338,6 +1338,7 @@ void hg_scanner_239::thread_get_dves_image(void)
svdevs_err_.clear(); svdevs_err_.clear();
StopWatch sw; StopWatch sw;
StopWatch sw1;
bool is_quit_wait_paper_scan = false; bool is_quit_wait_paper_scan = false;
while (run_)//&& !user_cancel_ while (run_)//&& !user_cancel_
@ -1354,7 +1355,7 @@ void hg_scanner_239::thread_get_dves_image(void)
if (ret == SCANNER_ERR_TIMEOUT) if (ret == SCANNER_ERR_TIMEOUT)
{ {
std::this_thread::sleep_for(std::chrono::milliseconds(400)); std::this_thread::sleep_for(std::chrono::milliseconds(400));
if (sw.elapsed_s() > 60 && !is_auto_scan()) if (sw.elapsed_s() > 120 && !is_auto_scan())
{ {
status_ = ret; status_ = ret;
notify_ui_working_status(from_default_language(STATU_DESC_SCANNER_ERR_DEVICE_GET_IMAGE_OUTTIME), SANE_EVENT_ERROR, ret); // 取图通信超时 notify_ui_working_status(from_default_language(STATU_DESC_SCANNER_ERR_DEVICE_GET_IMAGE_OUTTIME), SANE_EVENT_ERROR, ret); // 取图通信超时
@ -1362,7 +1363,7 @@ void hg_scanner_239::thread_get_dves_image(void)
break; break;
} }
if (is_auto_scan() && sw.elapsed_s() >= is_auto_paper_scan_exit_time && is_auto_paper_scan_exit_time != 0) if (is_auto_scan() && sw1.elapsed_s() >= is_auto_paper_scan_exit_time && is_auto_paper_scan_exit_time != 0)
{ {
is_quit_wait_paper_scan = true;//标记待纸扫描时间到了自动结束 is_quit_wait_paper_scan = true;//标记待纸扫描时间到了自动结束
do_stop(); do_stop();
@ -1504,7 +1505,10 @@ void hg_scanner_239::thread_get_dves_image(void)
str += ":" + to_string(++auoto_paper_indx); str += ":" + to_string(++auoto_paper_indx);
if (!user_cancel_ && is_auto_scan() && svdevs_err_.empty() && !is_quit_wait_paper_scan) if (!user_cancel_ && is_auto_scan() && svdevs_err_.empty() && !is_quit_wait_paper_scan)
{
sw1.reset();
notify_ui_working_status(str.c_str(), SANE_EVENT_ERROR, status_); notify_ui_working_status(str.c_str(), SANE_EVENT_ERROR, status_);
}
else else
break; break;
} }

View File

@ -431,7 +431,22 @@ namespace hg_imgproc
int ret = SCANNER_ERR_OK; int ret = SCANNER_ERR_OK;
float scale = img_conf_.fillhole.fillholeratio / 100.0; float scale = img_conf_.fillhole.fillholeratio / 100.0;
float val = img_conf_.resolution_dst / 10; int dpi = img_conf_.resolution_dst;
if (!param_.is_sup_real_300dpi_)
{
dpi = 200;
}
else
{
if (!param_.is_sup_real_600dpi_)
{
if (dpi >= 300)
dpi = 300;
}
}
float val = dpi / 10;
cv::Vec4f edgeScale; cv::Vec4f edgeScale;
edgeScale[0] = top; edgeScale[0] = top;
edgeScale[1] = low; edgeScale[1] = low;

View File

@ -153,6 +153,8 @@ namespace hg_imgproc
int width; // in pixel int width; // in pixel
int height; // in pixel int height; // in pixel
unsigned total_bytes;// total bytes unsigned total_bytes;// total bytes
bool is_sup_real_300dpi_;
bool is_sup_real_600dpi_;
bool device_7010; bool device_7010;
}IMGPRCPARAM, *LPIMGPRCPARAM; }IMGPRCPARAM, *LPIMGPRCPARAM;
typedef struct _img_header typedef struct _img_header

View File

@ -70,7 +70,7 @@ int LIBUSB_CALL usb_manager::usb_pnp_callback(libusb_context* ctx, libusb_device
usb_manager* obj = (usb_manager*)monitor; usb_manager* obj = (usb_manager*)monitor;
// if (event == LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED) // if (event == LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED)
libusb_ref_device(device); // keep the object until handle it //libusb_ref_device(device); // keep the object until handle it
//else if(event == LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT) //else if(event == LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT)
// libusb_unref_device(device); // libusb_unref_device(device);
@ -187,17 +187,22 @@ void usb_manager::thread_notify_usb_event()
} }
} }
libusb_ref_device(pd.dev); // for re-enter the queue pnp_events_
notify_usb_event(pd, &retry); notify_usb_event(pd, &retry);
if (retry) if (retry)
{ {
if(std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - pd.happen_time).count() if (std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - pd.happen_time).count()
<= 5000) <= 5000)
pnp_events_.Put(pd, sizeof(pd)); pnp_events_.Put(pd, sizeof(pd));
else
retry = false;
if(pnp_events_.Size() == 1) if(pnp_events_.Size() == 1)
this_thread::sleep_for(chrono::milliseconds(1000)); this_thread::sleep_for(chrono::milliseconds(1000));
else else
this_thread::sleep_for(chrono::milliseconds(delay)); this_thread::sleep_for(chrono::milliseconds(delay));
} }
if (!retry)
libusb_unref_device(pd.dev);
} }
} }
} }
@ -283,6 +288,7 @@ int usb_manager::on_usb_pnp_event(libusb_context *ctx, libusb_device *device, li
PNPDEV pd; PNPDEV pd;
unsigned ms = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - born_).count(); unsigned ms = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - born_).count();
libusb_ref_device(device);
pd.ctx = ctx; pd.ctx = ctx;
pd.dev = device; pd.dev = device;
pd.event = event; pd.event = event;
@ -295,9 +301,12 @@ int usb_manager::on_usb_pnp_event(libusb_context *ctx, libusb_device *device, li
else else
{ {
bool retry = false; bool retry = false;
libusb_ref_device(device);
notify_usb_event(pd, &retry); notify_usb_event(pd, &retry);
if(retry) if(retry)
pnp_events_.Put(pd, sizeof(pd)); pnp_events_.Put(pd, sizeof(pd));
else
libusb_unref_device(device);
} }
return 0; return 0;