新增除摩尔纹模式

This commit is contained in:
13038267101 2023-10-16 16:24:44 +08:00
parent 66276e6c9f
commit 16bd0223c0
5 changed files with 74 additions and 30 deletions

View File

@ -723,6 +723,8 @@ namespace setting3288dsp
{
FLAT_INFO info;
cv::Mat flat_lut;
float vratio;
float hratio;
};
struct HG_JpegCompressInfo

View File

@ -5048,7 +5048,7 @@ void hg_scanner::image_process(std::shared_ptr<tiny_buffer>& buffer, uint32_t id
(this->*dump_img_)(ImagePrc_pHandle_, "textureRemove");
}
if (img_conf_.removeMorr && (pid_ != 0x239 && pid_ != 0x439) && !firmware_sup_morr_)
if (img_conf_.removeMorr && (pid_ != 0x239 && pid_ != 0x439 && pid_ != 0x300) && !firmware_sup_morr_)
{
hg_imgproc::remove_morr(ImagePrc_pHandle_);
(this->*dump_img_)(ImagePrc_pHandle_, "remove_morr");

View File

@ -99,6 +99,7 @@ hg_scanner_300::hg_scanner_300(const char* dev_name,int pid, usb_io* io) :
get_correction_image(3, 2, 0);
get_correction_image(4, 3, 1);
get_correction_image(5, 3, 0);
firmware_sup_morr_ = true;
}
else
{
@ -948,6 +949,30 @@ int hg_scanner_300::get_device_type(bool &type)
return ret;
}
int hg_scanner_300::get_devs_distortion_check_val(float& data, int dpi, int dir)
{
int ret = SCANNER_ERR_OK;
USBCB usbcb = { dir ? setting3288dsp::GET_JUST_COF_V : setting3288dsp::GET_JUST_COF_H ,0,dpi };
int len = sizeof(usbcb);
{
ret = io_->write_bulk(&usbcb, &len);
if (ret != SCANNER_ERR_OK)
{
return ret;
}
io_->set_timeout(3000);
ret = io_->read_bulk(&usbcb, &len);
}
if (ret != SCANNER_ERR_OK)
{
return ret;
}
int val = usbcb.u32_Data;
data = *(float*)&val;
}
int hg_scanner_300::get_correction_image(int inx , int dpi, int mode)
{
for (auto it : correction_image_map_)
@ -1009,11 +1034,22 @@ int hg_scanner_300::get_correction_image(int inx , int dpi, int mode)
VLOG_MINI_1(LOG_LEVEL_WARNING, "get_correction_image image is NULL:%d\n", image_info.info.params.status);
return SCANNER_ERR_NO_DATA; //只要有一张图没有 直接退了
}
float f = 0.0;
get_devs_distortion_check_val(f, dpi, i);
if (i)
{
image_info.vratio = f;
white_mat = mat;
}
else
{
image_info.hratio = f;
black_mat = mat;
}
}
}
//cv::imwrite("C://image//correction_image_white_mat" + to_string(inx) + ".bmp", white_mat);
@ -1021,16 +1057,6 @@ int hg_scanner_300::get_correction_image(int inx , int dpi, int mode)
ret = hg_imgproc::correction_image(ImagePrc_pHandle_, image_info.flat_lut, black_mat, white_mat);
//cv::imwrite("C://image//correction_image_black_mat" + to_string(inx) + ".bmp", black_mat);
//for (size_t j = 0; j < correction_image_map_.size(); j++) //以防重复添加
//{
// if (correction_image_map_[j].info.params.dpi == dpi
// && correction_image_map_[j].info.params.colormode == mode)
// {
// return ret;
// }
//}
correction_image_map_[inx] = image_info;
return ret;

View File

@ -66,6 +66,7 @@ private:
void writedown_image_configuration(void);
void printf_devconfig(setting_hardware::HGSCANCONF_3288 *d = NULL);
int get_device_type(bool &type);
int get_devs_distortion_check_val(float& data, int dpi, int dir);//获取设备畸变值 DPI=1、2、3 dir = 0,1;
setting3288dsp::HG_JpegCompressInfo frame_info_;
///////////////////////7010专有协议获取校正数据//////////////////////

View File

@ -521,40 +521,55 @@ namespace hg_imgproc
else
mat = m_dst.clone();
cv::imwrite("C:\\image\\imdecode" + std::to_string(img_idx++) + ".jpg", mat);
float vratio = 0.0;
float hratio = 0.0;
//cv::imwrite("C:\\image\\imdecode" + std::to_string(img_idx++) + ".jpg", mat);
int dpi = param_.dpi == 600 ? 3 : (param_.dpi < 599 && param_.dpi >= 300) ? 2 : 1;
int mode = param_.color_mode == COLOR_MODE_24_BITS ? 1 : 0;
for (auto it : correction_image_map_)
{
if (img_conf_.removeMorr && param_.dpi != 600) //除摩尔纹 使用300dpi校正数据
{
if (it.second.info.params.dpi == 2)
{
if (it.second.info.params.status != 100)
break;
vratio = it.second.vratio;
hratio = it.second.hratio;
correctColor(mat, it.second.flat_lut);
break;
}
continue;
}
if (it.second.info.params.colormode == mode && it.second.info.params.dpi == dpi)
{
if (it.second.info.params.status != 100)
{
break;
}
vratio = it.second.vratio;
hratio = it.second.hratio;
correctColor(mat, it.second.flat_lut);//校正
break;
}
}
//for (size_t i = 0; i < correction_image_map_.size(); i++)
//{
// if (correction_image_map_[i].info.params.colormode == mode && correction_image_map_[i].info.params.dpi == dpi)
// {
// if (correction_image_map_[i].info.params.status != 100)
// {
// continue;
// }
// correctColor(mat, correction_image_map_[i].flat_lut);//校正
// }
//}
//cv::imwrite("C:\\image\\imdecode" + std::to_string(img_idx++) + ".jpg", mat);
//if (param_.dpi < 299)/////7010不支持 200dpi 所以需要手动拉伸宽度
//{
// float xy = param_.dpi / 300.0;
// cv::resize(mat, mat, cv::Size(), xy, 1);
if (!(vratio >= 0.8f && vratio <= 1.20f && hratio > 0.8f && hratio < 1.2f))
vratio = hratio = 1.0f;
//}
if (dpi == 1 && img_conf_.removeMorr)
hratio = (200.0 / 300.0) * hratio;
if (img_conf_.removeMorr && dpi != 3)
vratio = dpi == 1 ? vratio * 0.5186 : vratio * 0.7787;
if (img_conf_.removeMorr)
resize(mat, mat, cv::Size(0, 0), hratio, vratio, cv::InterpolationFlags::INTER_AREA);
else
resize(mat, mat, cv::Size(0, 0), hratio, vratio);
}
//cv::imwrite("C:\\image\\imdecode4.png", mat);