调整多流输出,调整互斥关系
This commit is contained in:
parent
cfb8957582
commit
207c4d4ad3
|
@ -1,9 +1,10 @@
|
||||||
#include "ImageMulti.h"
|
#include "ImageMulti.h"
|
||||||
|
|
||||||
IMageMulti::IMageMulti(int multiType,int thre)
|
IMageMulti::IMageMulti(int multiType, int thre, short thresholdType, int blockSize, int constant)
|
||||||
|
: m_multiType(multiType)
|
||||||
|
, m_BWBinaray((CImageApplyBWBinaray::ThresholdType)thresholdType, thre, blockSize, constant)
|
||||||
{
|
{
|
||||||
m_multiType = multiType;
|
|
||||||
m_thre = thre;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IMageMulti::~IMageMulti(void)
|
IMageMulti::~IMageMulti(void)
|
||||||
|
@ -27,8 +28,7 @@ std::vector<cv::Mat> IMageMulti::apply(cv::Mat& pDib)
|
||||||
}
|
}
|
||||||
cv::Mat dstThre;
|
cv::Mat dstThre;
|
||||||
cv::cvtColor(pDib, dstThre,cv::COLOR_BGR2GRAY);
|
cv::cvtColor(pDib, dstThre,cv::COLOR_BGR2GRAY);
|
||||||
//cv::threshold(dstThre, dstThre, m_thre, 255, cv::THRESH_BINARY);
|
m_BWBinaray.apply(dstThre, 0);
|
||||||
cv::adaptiveThreshold(dstThre,dstThre,255,cv::ADAPTIVE_THRESH_GAUSSIAN_C,cv::THRESH_BINARY,25,5);
|
|
||||||
if (!dstThre.empty())
|
if (!dstThre.empty())
|
||||||
{
|
{
|
||||||
retMats.push_back(dstThre);
|
retMats.push_back(dstThre);
|
||||||
|
@ -49,20 +49,17 @@ std::vector<cv::Mat> IMageMulti::apply(cv::Mat& pDib)
|
||||||
if (pDib.channels() == 3) {
|
if (pDib.channels() == 3) {
|
||||||
cv::Mat dstGray;
|
cv::Mat dstGray;
|
||||||
cv::cvtColor(pDib, dstGray, cv::COLOR_BGR2GRAY);
|
cv::cvtColor(pDib, dstGray, cv::COLOR_BGR2GRAY);
|
||||||
cv::Mat dstBW;
|
m_BWBinaray.apply(dstGray, 0);
|
||||||
cv::adaptiveThreshold(dstGray,dstBW,255,cv::ADAPTIVE_THRESH_GAUSSIAN_C,cv::THRESH_BINARY,25,5);
|
retMats.push_back(dstGray);
|
||||||
retMats.push_back(dstBW);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GRAYBW://pDib should be GreyImage(channels() == 1)
|
case GRAYBW://pDib should be GreyImage(channels() == 1)
|
||||||
{
|
{
|
||||||
cv::Mat dstBW;
|
cv::Mat dstBW = pDib.clone();
|
||||||
cv::adaptiveThreshold(pDib,dstBW,255,cv::ADAPTIVE_THRESH_GAUSSIAN_C,cv::THRESH_BINARY,25,5);
|
m_BWBinaray.apply(dstBW, 0);
|
||||||
if (!dstBW.empty())
|
if (!dstBW.empty())
|
||||||
{
|
|
||||||
retMats.push_back(dstBW);
|
retMats.push_back(dstBW);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -1,6 +1,19 @@
|
||||||
|
/*
|
||||||
|
* ====================================================
|
||||||
|
|
||||||
|
* 功能:多流输出。
|
||||||
|
* 作者:刘丁维
|
||||||
|
* 生成时间:2022/11/18
|
||||||
|
* 最近修改时间:2022/11/18 v1.0 替换二值化方案,改用CImageApplyBWBinaray进行二值化操作。
|
||||||
|
* 版本号:v1.0
|
||||||
|
|
||||||
|
* ====================================================
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef IMAGE_MULTI_H
|
#ifndef IMAGE_MULTI_H
|
||||||
#define IMAGE_MULTI_H
|
#define IMAGE_MULTI_H
|
||||||
#include "IMulti.h"
|
#include "IMulti.h"
|
||||||
|
#include "ImageApplyBWBinaray.h"
|
||||||
|
|
||||||
class GIMGPROC_LIBRARY_API IMageMulti
|
class GIMGPROC_LIBRARY_API IMageMulti
|
||||||
:public IMulti
|
:public IMulti
|
||||||
|
@ -15,12 +28,23 @@ public:
|
||||||
GRAYBW
|
GRAYBW
|
||||||
};
|
};
|
||||||
public:
|
public:
|
||||||
IMageMulti(int multiType = 0,int thre = 128);
|
/// <summary>
|
||||||
|
/// 构造函数
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="multiType">多流输出类型。详情见enum MultiOutput</param>
|
||||||
|
/// <param name="thre">二值化阈值CImageApplyBWBinaray::threshold</param>
|
||||||
|
/// <param name="thresholdType">二值化方式。详情见CImageApplyBWBinaray::ThresholdType</param>
|
||||||
|
/// <param name="blockSize">二值化blockSize。详情见CImageApplyBWBinaray::blockSize</param>
|
||||||
|
/// <param name="constant">二值化constant。详情见CImageApplyBWBinaray::constant</param>
|
||||||
|
IMageMulti(int multiType = 0, int thre = 40, short thresholdType = 0, int blockSize = 51, int constant = 41);
|
||||||
|
|
||||||
virtual ~IMageMulti(void);
|
virtual ~IMageMulti(void);
|
||||||
|
|
||||||
virtual std::vector<cv::Mat> apply(cv::Mat& pDib);
|
virtual std::vector<cv::Mat> apply(cv::Mat& pDib);
|
||||||
private:
|
private:
|
||||||
int m_multiType;
|
int m_multiType;
|
||||||
int m_thre;
|
|
||||||
|
CImageApplyBWBinaray m_BWBinaray;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // !IMAGE_MULTI_H
|
#endif // !IMAGE_MULTI_H
|
|
@ -1572,12 +1572,12 @@ int hg_scanner::setting_resolution(void* data)
|
||||||
// check paper ...
|
// check paper ...
|
||||||
if (!check_paper_and_resolution(resolution_, image_prc_param_.bits.paper))
|
if (!check_paper_and_resolution(resolution_, image_prc_param_.bits.paper))
|
||||||
{
|
{
|
||||||
resolution_ = old;
|
//resolution_ = old;
|
||||||
*((int*)data) = old;
|
//*((int*)data) = old;
|
||||||
|
|
||||||
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
|
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
|
||||||
}
|
}
|
||||||
if (!check_resolution_and_quality(resolution_, is_img_quality(is_quality_).c_str()))
|
/*if (!check_resolution_and_quality(resolution_, is_img_quality(is_quality_).c_str()))
|
||||||
{
|
{
|
||||||
if (resolution_ == 600 && old < 300)
|
if (resolution_ == 600 && old < 300)
|
||||||
{
|
{
|
||||||
|
@ -1595,7 +1595,7 @@ int hg_scanner::setting_resolution(void* data)
|
||||||
|
|
||||||
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
|
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
sub = on_resolution_changed(resolution_);
|
sub = on_resolution_changed(resolution_);
|
||||||
if (sub == SCANNER_ERR_NOT_EXACT)
|
if (sub == SCANNER_ERR_NOT_EXACT)
|
||||||
|
@ -1604,7 +1604,7 @@ int hg_scanner::setting_resolution(void* data)
|
||||||
ret = sub;
|
ret = sub;
|
||||||
|
|
||||||
VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "Change resolution from %d to %d = %s\n", old, *((int*)data), hg_scanner_err_name(ret));
|
VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "Change resolution from %d to %d = %s\n", old, *((int*)data), hg_scanner_err_name(ret));
|
||||||
*((int*)data) = resolution_;
|
//*((int*)data) = resolution_;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -2028,13 +2028,13 @@ int hg_scanner::setting_img_quality(void* data)
|
||||||
, (char*)data, hg_scanner_err_name(ret));
|
, (char*)data, hg_scanner_err_name(ret));
|
||||||
|
|
||||||
is_quality_ = match_best_img_quality(str,NULL);
|
is_quality_ = match_best_img_quality(str,NULL);
|
||||||
if (!check_resolution_and_quality(resolution_, is_img_quality(is_quality_).c_str()))
|
/*if (!check_resolution_and_quality(resolution_, is_img_quality(is_quality_).c_str()))
|
||||||
{
|
{
|
||||||
is_quality_ = old;
|
is_quality_ = old;
|
||||||
strcpy((char*)data, is_img_quality(is_quality_).c_str());
|
strcpy((char*)data, is_img_quality(is_quality_).c_str());
|
||||||
|
|
||||||
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
|
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
return SCANNER_ERR_OK;
|
return SCANNER_ERR_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -746,7 +746,6 @@ else
|
||||||
else if ((image_prc_param_.bits.multi_out == MULTI_OUT_ALL ||image_prc_param_.bits.multi_out == MULTI_COLOR_AND_GRAY||image_prc_param_.bits.multi_out == MULTI_COLOR_AND_BW) && is_multiout)
|
else if ((image_prc_param_.bits.multi_out == MULTI_OUT_ALL ||image_prc_param_.bits.multi_out == MULTI_COLOR_AND_GRAY||image_prc_param_.bits.multi_out == MULTI_COLOR_AND_BW) && is_multiout)
|
||||||
{
|
{
|
||||||
ic.pixtype = 2;
|
ic.pixtype = 2;
|
||||||
|
|
||||||
}
|
}
|
||||||
if (is_multiout)
|
if (is_multiout)
|
||||||
{
|
{
|
||||||
|
|
|
@ -500,9 +500,71 @@ int hg_scanner_239::writedown_image_configuration(void)
|
||||||
ic.isuoloadexceptionimage = (double_paper_handle_ & DOUBLE_PAPER_SAVE_IMG) == DOUBLE_PAPER_SAVE_IMG;
|
ic.isuoloadexceptionimage = (double_paper_handle_ & DOUBLE_PAPER_SAVE_IMG) == DOUBLE_PAPER_SAVE_IMG;
|
||||||
adjust_filling_hole(&ic);
|
adjust_filling_hole(&ic);
|
||||||
ic.fold_concatmode = fold_type_;
|
ic.fold_concatmode = fold_type_;
|
||||||
|
//多流输出优先级最高
|
||||||
|
if (is_multiout)
|
||||||
|
{
|
||||||
|
ic.pixtype = image_prc_param_.bits.multi_out == MULTI_GRAY_AND_BW ? COLOR_MODE_256_GRAY : COLOR_MODE_24_BITS;
|
||||||
|
ic.filter = 3;
|
||||||
|
ic.hsvcorrect = 0;
|
||||||
|
ic.multi_output_red = 0;
|
||||||
|
ic.fadeback = false;
|
||||||
|
ic.sharpen = 0;
|
||||||
|
ic.removeMorr = 0;
|
||||||
|
ic.textureRemove = 0;
|
||||||
|
ic.errorExtention = 0;
|
||||||
|
ic.detachnoise.is_detachnoise = 0;
|
||||||
|
}
|
||||||
|
else if(image_prc_param_.bits.multi_out == COLOR_MODE_24_BITS)
|
||||||
|
{
|
||||||
|
ic.filter = 3;
|
||||||
|
ic.errorExtention = 0;
|
||||||
|
ic.detachnoise.is_detachnoise = 0;
|
||||||
|
}
|
||||||
|
else if (image_prc_param_.bits.multi_out == COLOR_MODE_256_GRAY)
|
||||||
|
{
|
||||||
|
int filter_clr[] = { 3, 0, 1, 2, 5, 6, 7 };
|
||||||
|
ic.filter = filter_clr[image_prc_param_.bits.rid_color];
|
||||||
|
ic.multi_output_red = 0;
|
||||||
|
ic.hsvcorrect = 0;
|
||||||
|
ic.fadeback = false;
|
||||||
|
ic.errorExtention = 0;
|
||||||
|
ic.detachnoise.is_detachnoise = 0;
|
||||||
|
}
|
||||||
|
else if (image_prc_param_.bits.multi_out == COLOR_MODE_BLACK_WHITE)
|
||||||
|
{
|
||||||
|
int filter_clr[] = { 3, 0, 1, 2, 5, 6, 7 };
|
||||||
|
ic.filter = filter_clr[image_prc_param_.bits.rid_color];
|
||||||
|
ic.multi_output_red = 0;
|
||||||
|
ic.hsvcorrect = 0;
|
||||||
|
ic.fadeback = false;
|
||||||
|
ic.sharpen = 0;
|
||||||
|
ic.removeMorr = 0;
|
||||||
|
ic.textureRemove = 0;
|
||||||
|
}
|
||||||
|
else if (image_prc_param_.bits.multi_out == COLOR_MODE_AUTO_MATCH)
|
||||||
|
{
|
||||||
|
ic.pixtype = 2;
|
||||||
|
ic.filter = 3;
|
||||||
|
ic.hsvcorrect = 0;
|
||||||
|
ic.multi_output_red = 0;
|
||||||
|
ic.fadeback = false;
|
||||||
|
ic.sharpen = 0;
|
||||||
|
ic.removeMorr = 0;
|
||||||
|
ic.textureRemove = 0;
|
||||||
|
ic.errorExtention = 0;
|
||||||
|
ic.detachnoise.is_detachnoise = 0;
|
||||||
|
|
||||||
int filter_clr[] = { 3, 0, 1, 2, 5, 6, 7 };
|
}
|
||||||
if(image_prc_param_.bits.color_mode == COLOR_MODE_24_BITS || image_prc_param_.bits.color_mode == COLOR_MODE_AUTO_MATCH)
|
|
||||||
|
|
||||||
|
|
||||||
|
/*if (ic.filter != 3 && (image_prc_param_.bits.color_mode == COLOR_MODE_BLACK_WHITE || image_prc_param_.bits.color_mode != COLOR_MODE_256_GRAY))
|
||||||
|
{
|
||||||
|
ic.hsvcorrect = 0;
|
||||||
|
ic.multi_output_red = 0;
|
||||||
|
ic.multiOutput = MultiOutput::Unused;
|
||||||
|
}
|
||||||
|
if (image_prc_param_.bits.color_mode == COLOR_MODE_24_BITS || image_prc_param_.bits.color_mode == COLOR_MODE_AUTO_MATCH)
|
||||||
ic.filter = 3;
|
ic.filter = 3;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -523,20 +585,8 @@ int hg_scanner_239::writedown_image_configuration(void)
|
||||||
else if ((image_prc_param_.bits.multi_out == MULTI_OUT_ALL ||image_prc_param_.bits.multi_out == MULTI_COLOR_AND_GRAY||image_prc_param_.bits.multi_out == MULTI_COLOR_AND_BW) && is_multiout)
|
else if ((image_prc_param_.bits.multi_out == MULTI_OUT_ALL ||image_prc_param_.bits.multi_out == MULTI_COLOR_AND_GRAY||image_prc_param_.bits.multi_out == MULTI_COLOR_AND_BW) && is_multiout)
|
||||||
{
|
{
|
||||||
ic.pixtype = 2;
|
ic.pixtype = 2;
|
||||||
|
|
||||||
}
|
}
|
||||||
if (is_multiout)
|
|
||||||
{
|
|
||||||
ic.hsvcorrect = 0;
|
|
||||||
ic.multi_output_red = 0;
|
|
||||||
ic.fadeback = false;
|
|
||||||
ic.sharpen = 0;
|
|
||||||
ic.removeMorr = 0;
|
|
||||||
ic.textureRemove = 0;
|
|
||||||
|
|
||||||
ic.errorExtention = 0;
|
|
||||||
ic.detachnoise.is_detachnoise = 0;
|
|
||||||
}
|
|
||||||
if (ic.pixtype == 0)
|
if (ic.pixtype == 0)
|
||||||
{
|
{
|
||||||
ic.hsvcorrect = 0;
|
ic.hsvcorrect = 0;
|
||||||
|
@ -545,7 +595,7 @@ int hg_scanner_239::writedown_image_configuration(void)
|
||||||
ic.sharpen = 0;
|
ic.sharpen = 0;
|
||||||
ic.removeMorr = 0;
|
ic.removeMorr = 0;
|
||||||
ic.textureRemove = 0;
|
ic.textureRemove = 0;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
//自定义裁切
|
//自定义裁切
|
||||||
if (image_prc_param_.bits.paper == PAPER_AUTO_MATCH
|
if (image_prc_param_.bits.paper == PAPER_AUTO_MATCH
|
||||||
|
@ -1272,7 +1322,7 @@ void hg_scanner_239::thread_handle_usb_read(void)
|
||||||
if (status_ == SCANNER_ERR_DEVICE_STOPPED)
|
if (status_ == SCANNER_ERR_DEVICE_STOPPED)
|
||||||
{
|
{
|
||||||
SANE_Bool b = false;
|
SANE_Bool b = false;
|
||||||
status_ = ret = get_scanner_paperon(&b);
|
//status_ = ret = get_scanner_paperon(&b);
|
||||||
}
|
}
|
||||||
VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "USB thread exit with code: %s, status = %s\n", hg_scanner_err_name(ret), hg_scanner_err_name(status_));
|
VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "USB thread exit with code: %s, status = %s\n", hg_scanner_err_name(ret), hg_scanner_err_name(status_));
|
||||||
}
|
}
|
||||||
|
|
|
@ -287,7 +287,7 @@ namespace hg_imgproc
|
||||||
}
|
}
|
||||||
~imgproc()
|
~imgproc()
|
||||||
{
|
{
|
||||||
free_auto_txt_hanld();
|
//free_auto_txt_hanld();
|
||||||
}
|
}
|
||||||
|
|
||||||
// load data
|
// load data
|
||||||
|
|
Loading…
Reference in New Issue