调整多流输出,调整互斥关系

This commit is contained in:
13038267101 2022-11-19 11:46:01 +08:00
parent cfb8957582
commit 207c4d4ad3
6 changed files with 109 additions and 39 deletions

View File

@ -1,9 +1,10 @@
#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)
@ -27,8 +28,7 @@ std::vector<cv::Mat> IMageMulti::apply(cv::Mat& pDib)
}
cv::Mat dstThre;
cv::cvtColor(pDib, dstThre,cv::COLOR_BGR2GRAY);
//cv::threshold(dstThre, dstThre, m_thre, 255, cv::THRESH_BINARY);
cv::adaptiveThreshold(dstThre,dstThre,255,cv::ADAPTIVE_THRESH_GAUSSIAN_C,cv::THRESH_BINARY,25,5);
m_BWBinaray.apply(dstThre, 0);
if (!dstThre.empty())
{
retMats.push_back(dstThre);
@ -49,21 +49,18 @@ std::vector<cv::Mat> IMageMulti::apply(cv::Mat& pDib)
if (pDib.channels() == 3) {
cv::Mat dstGray;
cv::cvtColor(pDib, dstGray, cv::COLOR_BGR2GRAY);
cv::Mat dstBW;
cv::adaptiveThreshold(dstGray,dstBW,255,cv::ADAPTIVE_THRESH_GAUSSIAN_C,cv::THRESH_BINARY,25,5);
retMats.push_back(dstBW);
m_BWBinaray.apply(dstGray, 0);
retMats.push_back(dstGray);
}
}
break;
case GRAYBW://pDib should be GreyImage(channels() == 1)
{
cv::Mat dstBW;
cv::adaptiveThreshold(pDib,dstBW,255,cv::ADAPTIVE_THRESH_GAUSSIAN_C,cv::THRESH_BINARY,25,5);
cv::Mat dstBW = pDib.clone();
m_BWBinaray.apply(dstBW, 0);
if (!dstBW.empty())
{
retMats.push_back(dstBW);
}
}
break;
default:
break;

View File

@ -1,6 +1,19 @@
/*
* ====================================================
*
*
* 2022/11/18
* 2022/11/18 v1.0 CImageApplyBWBinaray进行二值化操作
* v1.0
* ====================================================
*/
#ifndef IMAGE_MULTI_H
#define IMAGE_MULTI_H
#include "IMulti.h"
#include "ImageApplyBWBinaray.h"
class GIMGPROC_LIBRARY_API IMageMulti
:public IMulti
@ -15,12 +28,23 @@ public:
GRAYBW
};
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 std::vector<cv::Mat> apply(cv::Mat& pDib);
private:
int m_multiType;
int m_thre;
CImageApplyBWBinaray m_BWBinaray;
};
#endif // !IMAGE_MULTI_H

View File

@ -1572,12 +1572,12 @@ int hg_scanner::setting_resolution(void* data)
// check paper ...
if (!check_paper_and_resolution(resolution_, image_prc_param_.bits.paper))
{
resolution_ = old;
*((int*)data) = old;
//resolution_ = old;
//*((int*)data) = old;
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)
{
@ -1595,7 +1595,7 @@ int hg_scanner::setting_resolution(void* data)
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
}
}
}*/
sub = on_resolution_changed(resolution_);
if (sub == SCANNER_ERR_NOT_EXACT)
@ -1604,7 +1604,7 @@ int hg_scanner::setting_resolution(void* data)
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));
*((int*)data) = resolution_;
//*((int*)data) = resolution_;
return ret;
}
@ -2028,13 +2028,13 @@ int hg_scanner::setting_img_quality(void* data)
, (char*)data, hg_scanner_err_name(ret));
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;
strcpy((char*)data, is_img_quality(is_quality_).c_str());
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
}
}*/
return SCANNER_ERR_OK;
}

View File

@ -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)
{
ic.pixtype = 2;
}
if (is_multiout)
{

View File

@ -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;
adjust_filling_hole(&ic);
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 };
if(image_prc_param_.bits.color_mode == COLOR_MODE_24_BITS || image_prc_param_.bits.color_mode == COLOR_MODE_AUTO_MATCH)
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;
}
/*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;
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)
{
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)
{
ic.hsvcorrect = 0;
@ -545,7 +595,7 @@ int hg_scanner_239::writedown_image_configuration(void)
ic.sharpen = 0;
ic.removeMorr = 0;
ic.textureRemove = 0;
}
}*/
//自定义裁切
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)
{
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_));
}

View File

@ -287,7 +287,7 @@ namespace hg_imgproc
}
~imgproc()
{
free_auto_txt_hanld();
//free_auto_txt_hanld();
}
// load data