调整校正数据,及支持200dpi处理
This commit is contained in:
parent
bc6243c4a0
commit
96cbfed48d
|
@ -92,6 +92,7 @@ hg_scanner_300::hg_scanner_300(const char* dev_name,int pid, usb_io* io) :
|
|||
int ret = get_device_type(firmware_sup_device_7010);
|
||||
if (firmware_sup_device_7010 && ret == SCANNER_ERR_OK)
|
||||
{
|
||||
set_kernelsnap_ver();
|
||||
get_correction_image(0, 1, 1);
|
||||
get_correction_image(1, 1, 0);
|
||||
get_correction_image(2, 2, 1);
|
||||
|
@ -273,6 +274,7 @@ void hg_scanner_300::thread_handle_usb_read(void)
|
|||
if (firmware_sup_device_7010)
|
||||
{
|
||||
ret = get_img_data_7010();
|
||||
sw.reset();
|
||||
if (ret != SCANNER_ERR_OK)
|
||||
{
|
||||
status_ = ret;
|
||||
|
@ -948,6 +950,13 @@ int hg_scanner_300::get_device_type(bool &type)
|
|||
|
||||
int hg_scanner_300::get_correction_image(int inx , int dpi, int mode)
|
||||
{
|
||||
for (auto it : correction_image_map_)
|
||||
{
|
||||
if (it.second.info.params.colormode == mode && it.second.info.params.dpi == dpi)
|
||||
{
|
||||
return -1;//预防重复添加
|
||||
}
|
||||
}
|
||||
int ret = SCANNER_ERR_OK;
|
||||
setting3288dsp::FLAT_INFO_IMAGE image_info;
|
||||
|
||||
|
@ -989,7 +998,7 @@ int hg_scanner_300::get_correction_image(int inx , int dpi, int mode)
|
|||
{
|
||||
return SCANNER_ERR_NO_DATA;
|
||||
}
|
||||
cv::ImreadModes rmc = image_info.info.params.colormode ? cv::IMREAD_COLOR : cv::IMREAD_GRAYSCALE;
|
||||
cv::ImreadModes rmc = cv::IMREAD_GRAYSCALE;;// image_info.info.params.colormode ? cv::IMREAD_COLOR : cv::IMREAD_GRAYSCALE;
|
||||
cv::Mat mat = cv::imdecode(imagedata, rmc);//color BGR
|
||||
|
||||
//if (mat.channels() == 3)
|
||||
|
@ -1012,14 +1021,16 @@ 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);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
//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;
|
||||
|
|
|
@ -524,29 +524,41 @@ namespace hg_imgproc
|
|||
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 (size_t i = 0; i < correction_image_map_.size(); i++)
|
||||
for (auto it : correction_image_map_)
|
||||
{
|
||||
if (correction_image_map_[i].info.params.colormode == mode && correction_image_map_[i].info.params.dpi == dpi)
|
||||
if (it.second.info.params.colormode == mode && it.second.info.params.dpi == dpi)
|
||||
{
|
||||
if (correction_image_map_[i].info.params.status != 100)
|
||||
if (it.second.info.params.status != 100)
|
||||
{
|
||||
break;
|
||||
}
|
||||
correctColor(mat, correction_image_map_[i].flat_lut);//校正
|
||||
correctColor(mat, it.second.flat_lut);//校正
|
||||
}
|
||||
|
||||
}
|
||||
//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 (param_.dpi < 299)/////7010不支持 200dpi 所以需要手动拉伸宽度
|
||||
//{
|
||||
// float xy = param_.dpi / 300.0;
|
||||
// cv::resize(mat, mat, cv::Size(), xy, 1);
|
||||
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
//cv::imwrite("C:\\image\\imdecode4.png", mat);
|
||||
//cv::imwrite("C:\\Users\\modehua\\Desktop\\image\\imdecode2.jpg",mat);
|
||||
//cv::imwrite("C:\\image\\imdecode2.jpg",mat);
|
||||
|
||||
if (mat.empty())
|
||||
{
|
||||
|
@ -1741,7 +1753,7 @@ namespace hg_imgproc
|
|||
float temp;
|
||||
for (int j = 0, length = (255 - b + 1); j < length; j++)
|
||||
{
|
||||
temp = gamma(tb + step * j, GAMMA_EX) - BLACK_OFFSET;
|
||||
temp = tb + step * j;// gamma(tb + step * j, GAMMA_EX) - BLACK_OFFSET;
|
||||
data[j + b] = (cv::min)(255, (cv::max)(0, static_cast<int>(temp)));
|
||||
}
|
||||
}
|
||||
|
@ -1777,6 +1789,7 @@ namespace hg_imgproc
|
|||
cv::Mat lut_lut(256, 1, CV_8UC1, buffer);
|
||||
cv::LUT(lut, lut_lut, lut);
|
||||
}
|
||||
|
||||
return lut;
|
||||
}
|
||||
|
||||
|
@ -1786,6 +1799,7 @@ namespace hg_imgproc
|
|||
#define CHANNEL 432
|
||||
cv::Mat calcLUT(const cv::Mat& black, const cv::Mat& white, bool isTextCorrection)
|
||||
{
|
||||
static int lut_idx = 0;
|
||||
std::vector<cv::Mat> w;
|
||||
w.push_back(black);
|
||||
w.push_back(white);
|
||||
|
@ -1798,6 +1812,8 @@ namespace hg_imgproc
|
|||
cv::transpose(lutROI, tran);
|
||||
memcpy(lutROI.data, tran.data, tran.total());
|
||||
}
|
||||
|
||||
cv::imwrite("C:\\image\\" + std::to_string(lut_idx++) + ".bmp", lut);
|
||||
return lut;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue