diff --git a/hgdriver/hgdev/hg_scanner.cpp b/hgdriver/hgdev/hg_scanner.cpp index 2a47c6d..c511333 100644 --- a/hgdriver/hgdev/hg_scanner.cpp +++ b/hgdriver/hgdev/hg_scanner.cpp @@ -3138,6 +3138,9 @@ hg_imgproc::IMGPRCPARAM hg_scanner::get_image_process_object(int model) param.width = mat_width; 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; //img_conf_.brightness = (float)bright_; //img_conf_.contrast = (float)contrast_; diff --git a/hgdriver/hgdev/hg_scanner_239.cpp b/hgdriver/hgdev/hg_scanner_239.cpp index 06b73a6..a6790df 100644 --- a/hgdriver/hgdev/hg_scanner_239.cpp +++ b/hgdriver/hgdev/hg_scanner_239.cpp @@ -1338,6 +1338,7 @@ void hg_scanner_239::thread_get_dves_image(void) svdevs_err_.clear(); StopWatch sw; + StopWatch sw1; bool is_quit_wait_paper_scan = false; while (run_)//&& !user_cancel_ @@ -1354,7 +1355,7 @@ void hg_scanner_239::thread_get_dves_image(void) if (ret == SCANNER_ERR_TIMEOUT) { 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; 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; } - 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;//标记待纸扫描时间到了自动结束 do_stop(); @@ -1504,7 +1505,10 @@ void hg_scanner_239::thread_get_dves_image(void) str += ":" + to_string(++auoto_paper_indx); 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_); + } else break; } diff --git a/hgdriver/hgdev/image_process.cpp b/hgdriver/hgdev/image_process.cpp index 728f7f4..a877467 100644 --- a/hgdriver/hgdev/image_process.cpp +++ b/hgdriver/hgdev/image_process.cpp @@ -431,7 +431,22 @@ namespace hg_imgproc int ret = SCANNER_ERR_OK; 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; edgeScale[0] = top; edgeScale[1] = low; diff --git a/hgdriver/hgdev/image_process.h b/hgdriver/hgdev/image_process.h index 47dbfec..945c747 100644 --- a/hgdriver/hgdev/image_process.h +++ b/hgdriver/hgdev/image_process.h @@ -153,6 +153,8 @@ namespace hg_imgproc int width; // in pixel int height; // in pixel unsigned total_bytes;// total bytes + bool is_sup_real_300dpi_; + bool is_sup_real_600dpi_; bool device_7010; }IMGPRCPARAM, *LPIMGPRCPARAM; typedef struct _img_header diff --git a/hgdriver/hgdev/usb_manager.cpp b/hgdriver/hgdev/usb_manager.cpp index efb385f..887fd76 100644 --- a/hgdriver/hgdev/usb_manager.cpp +++ b/hgdriver/hgdev/usb_manager.cpp @@ -70,7 +70,7 @@ int LIBUSB_CALL usb_manager::usb_pnp_callback(libusb_context* ctx, libusb_device usb_manager* obj = (usb_manager*)monitor; // 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) // 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); if (retry) { - if(std::chrono::duration_cast(std::chrono::system_clock::now() - pd.happen_time).count() + if (std::chrono::duration_cast(std::chrono::system_clock::now() - pd.happen_time).count() <= 5000) pnp_events_.Put(pd, sizeof(pd)); + else + retry = false; if(pnp_events_.Size() == 1) this_thread::sleep_for(chrono::milliseconds(1000)); else 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; unsigned ms = std::chrono::duration_cast(std::chrono::system_clock::now() - born_).count(); + libusb_ref_device(device); pd.ctx = ctx; pd.dev = device; pd.event = event; @@ -295,9 +301,12 @@ int usb_manager::on_usb_pnp_event(libusb_context *ctx, libusb_device *device, li else { bool retry = false; + libusb_ref_device(device); notify_usb_event(pd, &retry); if(retry) pnp_events_.Put(pd, sizeof(pd)); + else + libusb_unref_device(device); } return 0;