调整真实dpi和以前的dpi互斥关系
This commit is contained in:
parent
9856642541
commit
f5f6882ebd
|
@ -3303,7 +3303,8 @@ void hg_scanner::image_process(std::shared_ptr<tiny_buffer>& buffer)
|
|||
|
||||
if (pid_ != 0x239 && pid_ != 0x439)
|
||||
{
|
||||
ret = hg_imgproc::auto_crop(ImagePrc_pHandle_);
|
||||
float dpi3288 = (img_conf_.resolution_dst < 300 && is_kernelsnap3288_221106_) ? 200 : 300;
|
||||
ret = hg_imgproc::auto_crop(ImagePrc_pHandle_, dpi3288);
|
||||
(this->*dump_img_)(ImagePrc_pHandle_, "auto_crop");
|
||||
}
|
||||
|
||||
|
@ -3320,10 +3321,12 @@ void hg_scanner::image_process(std::shared_ptr<tiny_buffer>& buffer)
|
|||
(this->*dump_img_)(ImagePrc_pHandle_, "fadeback");
|
||||
}
|
||||
|
||||
if (((img_conf_.resolution_dst != img_conf_.resolution_native) && (pid_ != 0x239 && pid_ != 0x439))
|
||||
&& (!is_kernelsnap3288_221106_ ))
|
||||
if (((img_conf_.resolution_dst != img_conf_.resolution_native) && (pid_ != 0x239 && pid_ != 0x439) && !is_kernelsnap3288_221106_)
|
||||
|| (is_kernelsnap3288_221106_ && img_conf_.resolution_dst > 200))
|
||||
{
|
||||
hg_imgproc::resolution_change(ImagePrc_pHandle_);
|
||||
float dpi3288 = (img_conf_.resolution_dst < 300 && is_kernelsnap3288_221106_) ? 200 : 300;
|
||||
|
||||
hg_imgproc::resolution_change(ImagePrc_pHandle_, dpi3288);
|
||||
(this->*dump_img_)(ImagePrc_pHandle_, "resolution_change");
|
||||
}
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ hg_scanner_300::hg_scanner_300(const char* dev_name,int pid, usb_io* io) : hg_sc
|
|||
string fw = get_firmware_version();
|
||||
if (fw.size() > 5)
|
||||
{
|
||||
if (atoi(fw.substr(6, 4).c_str()) >= 1106)
|
||||
if (atoi(fw.substr(4, 6).c_str()) >= 221106)
|
||||
is_kernelsnap3288_221106_ = true;
|
||||
else
|
||||
is_kernelsnap3288_221106_ = false;
|
||||
|
@ -107,14 +107,7 @@ void hg_scanner_300::thread_handle_usb_read(void)
|
|||
|
||||
if (ret == SCANNER_ERR_DEVICE_STOPPED)
|
||||
{
|
||||
if (!savestatus_.empty())
|
||||
{
|
||||
status_ = savestatus_[0]; //以第一个消息为准
|
||||
}
|
||||
else
|
||||
{
|
||||
status_ = SCANNER_ERR_OK;
|
||||
}
|
||||
status_ = !savestatus_.empty() ? savestatus_[0] : SCANNER_ERR_OK;//以第一个消息为准
|
||||
savestatus_.clear();
|
||||
break;
|
||||
}
|
||||
|
@ -125,17 +118,10 @@ void hg_scanner_300::thread_handle_usb_read(void)
|
|||
}
|
||||
else
|
||||
statu = SANE_Image_Statu_OK;
|
||||
|
||||
if (sw.elapsed_ms() > 30000)//防止状态信息一直取不上来导致卡死
|
||||
{
|
||||
|
||||
if (!savestatus_.empty())
|
||||
{
|
||||
status_ = savestatus_[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
status_ = SCANNER_ERR_TIMEOUT;
|
||||
}
|
||||
status_ = !savestatus_.empty() ? savestatus_[0] : SCANNER_ERR_OK;//以第一个消息为准
|
||||
savestatus_.clear();
|
||||
hg_log::log(LOG_LEVEL_WARNING, "get status timeout,get image out\n");
|
||||
break;
|
||||
|
@ -458,7 +444,7 @@ int hg_scanner_300::on_paper_check_changed(bool& check)
|
|||
int hg_scanner_300::on_resolution_changed(int& dpi)
|
||||
{
|
||||
int ret = SCANNER_ERR_OK;
|
||||
dsp_config.params_3288.dpi = is_kernelsnap3288_221106_ ? (dsp_config.params_3288.dpi = (dpi > 200) ? 2 : 1) : 1;//暂时还未有固件支持
|
||||
dsp_config.params_3288.dpi = is_kernelsnap3288_221106_ ? (dsp_config.params_3288.dpi = (dpi >= 300) ? 2 : 1) : 1;
|
||||
|
||||
ret = writedown_device_configuration();
|
||||
return ret;
|
||||
|
|
|
@ -729,13 +729,13 @@ namespace hg_imgproc
|
|||
return SCANNER_ERR_OK;
|
||||
}
|
||||
/*pixtype 0 colcor; 1 gray; 2 bw*/
|
||||
int auto_crop()
|
||||
int auto_crop(float dpi)
|
||||
{
|
||||
int ret = SCANNER_ERR_OK;
|
||||
std::vector<cv::Mat> mats(mats_);
|
||||
mats_.clear();
|
||||
|
||||
SIZE temp_Size = papersize_.GetPaperSize(img_conf_.papertype, img_conf_.resolution_dst,img_conf_.paperAlign);
|
||||
SIZE temp_Size = papersize_.GetPaperSize(img_conf_.papertype, dpi,img_conf_.paperAlign);
|
||||
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);
|
||||
|
||||
|
@ -773,7 +773,7 @@ namespace hg_imgproc
|
|||
}
|
||||
return SCANNER_ERR_OK;
|
||||
}
|
||||
int resolution_change()
|
||||
int resolution_change(float dpi3288)
|
||||
{
|
||||
int ret = SCANNER_ERR_OK;
|
||||
CImageApplyFilter::FilterMode sharpenType = CImageApplyFilter::FilterMode::None;
|
||||
|
@ -787,16 +787,17 @@ namespace hg_imgproc
|
|||
if (img_conf_.is_autocrop || img_conf_.cropRect.enable)
|
||||
{
|
||||
resizeType = CImageApplyResize::ResizeType::RATIO;
|
||||
ratio = img_conf_.resolution_dst / (float)img_conf_.resolution_native;
|
||||
ratio = img_conf_.resolution_dst / dpi3288;
|
||||
}
|
||||
else
|
||||
resizeType = CImageApplyResize::ResizeType::DSIZE;
|
||||
resizeType = CImageApplyResize::ResizeType::DSIZE;
|
||||
|
||||
|
||||
CImageApplyResize resize(resizeType,cvSize,ratio,ratio);
|
||||
resize.apply(mats,img_conf_.is_duplex);
|
||||
|
||||
|
||||
if (img_conf_.resolution_dst > 200 && img_conf_.sharpen == CImageApplyFilter::FilterMode::None)
|
||||
if (img_conf_.resolution_dst > 300 && img_conf_.sharpen == CImageApplyFilter::FilterMode::None && dpi3288 ==200)
|
||||
{
|
||||
if (img_conf_.resolution_dst <= 300)
|
||||
sharpenType = CImageApplyFilter::FilterMode::Sharpen;
|
||||
|
@ -1535,17 +1536,17 @@ namespace hg_imgproc
|
|||
{
|
||||
return ((imgproc*)himg)->auto_matic_color(color_type);
|
||||
}
|
||||
int auto_crop(HIMGPRC himg)
|
||||
int auto_crop(HIMGPRC himg,float dpi)
|
||||
{
|
||||
return ((imgproc*)himg)->auto_crop();
|
||||
return ((imgproc*)himg)->auto_crop(dpi);
|
||||
}
|
||||
int fillhole(HIMGPRC himg, float top, float low, float l, float r)
|
||||
{
|
||||
return ((imgproc*)himg)->fillhole(top, low, l,r);
|
||||
}
|
||||
int resolution_change(HIMGPRC himg)
|
||||
int resolution_change(HIMGPRC himg,float dpi3288)
|
||||
{
|
||||
return ((imgproc*)himg)->resolution_change();
|
||||
return ((imgproc*)himg)->resolution_change(dpi3288);
|
||||
}
|
||||
int croprect(HIMGPRC himg)
|
||||
{
|
||||
|
|
|
@ -177,9 +177,9 @@ namespace hg_imgproc
|
|||
int multi_out(HIMGPRC himg,int out_type);
|
||||
int multi_out_red(HIMGPRC himg);
|
||||
int auto_matic_color(HIMGPRC himg,int color_type);
|
||||
int auto_crop(HIMGPRC himg);
|
||||
int auto_crop(HIMGPRC himg, float dpi);
|
||||
int fillhole(HIMGPRC himg, float top, float low, float r, float l);
|
||||
int resolution_change(HIMGPRC himg);
|
||||
int resolution_change(HIMGPRC himg,float dpi3288);
|
||||
int croprect(HIMGPRC himg);
|
||||
int channel(HIMGPRC himg);
|
||||
int adjust_color(HIMGPRC himg, unsigned char* table = nullptr, int tableLength = 0/*default value is to adjust color, or apply custom gamma*/);
|
||||
|
|
Loading…
Reference in New Issue