From e873553d488536835db05855dfe5cb3332383bb7 Mon Sep 17 00:00:00 2001 From: lovelyyoung <1002639516@qq.com> Date: Tue, 17 Mar 2020 21:06:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=A8=E8=99=9A=E5=87=BD=E6=95=B0apply?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E4=B8=AD=E5=A2=9E=E5=8A=A0=E5=88=A4=E6=96=AD?= =?UTF-8?q?=EF=BC=8C=E4=BB=A5=E9=81=BF=E5=85=8D=E5=A4=84=E7=90=86=E7=A9=BA?= =?UTF-8?q?=E5=9B=BE=E5=83=8F=E5=AF=BC=E8=87=B4=E7=9A=84=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- huagao/ImageProcess/ImageApplyAdjustColors.cpp | 10 +++++++--- huagao/ImageProcess/ImageApplyAutoCrop.cpp | 7 +++++-- huagao/ImageProcess/ImageApplyBWBinaray.cpp | 11 ++++++++--- huagao/ImageProcess/ImageApplyChannel.cpp | 10 +++++++--- huagao/ImageProcess/ImageApplyCrop.cpp | 10 +++++++--- huagao/ImageProcess/ImageApplyDiscardBlank.cpp | 10 +++++++--- huagao/ImageProcess/ImageApplyResize.cpp | 10 +++++++--- huagao/ImageProcess/ImageApplyRotation.cpp | 10 +++++++--- 8 files changed, 55 insertions(+), 23 deletions(-) diff --git a/huagao/ImageProcess/ImageApplyAdjustColors.cpp b/huagao/ImageProcess/ImageApplyAdjustColors.cpp index d298e84e..0d1eead8 100644 --- a/huagao/ImageProcess/ImageApplyAdjustColors.cpp +++ b/huagao/ImageProcess/ImageApplyAdjustColors.cpp @@ -44,11 +44,15 @@ void CImageApplyAdjustColors::apply(cv::Mat& pDib,int side) void CImageApplyAdjustColors::apply(std::vector& mats, bool isTwoSide) { if (mats.empty()) return; + if (!mats[0].empty()) { + apply(mats[0], 0); + } - apply(mats[0], 0); - if (isTwoSide && mats.size() > 1) - apply(mats[1], 1); + if (isTwoSide && mats.size() > 1) { + if(!mats[1].empty()) + apply(mats[1], 1); + } } void CImageApplyAdjustColors::setAdjustColors(int brightness, int contrast, float gamma) diff --git a/huagao/ImageProcess/ImageApplyAutoCrop.cpp b/huagao/ImageProcess/ImageApplyAutoCrop.cpp index 2dd22256..93b9fcd3 100644 --- a/huagao/ImageProcess/ImageApplyAutoCrop.cpp +++ b/huagao/ImageProcess/ImageApplyAutoCrop.cpp @@ -166,8 +166,10 @@ void CImageApplyAutoCrop::apply(cv::Mat& pDib, int side) void CImageApplyAutoCrop::apply(std::vector& mats, bool isTwoSide) { if (mats.empty()) return; + if (!mats[0].empty()) { + apply(mats[0], 0); + } - apply(mats[0], 0); if (isTwoSide && mats.size() > 1) { @@ -175,7 +177,8 @@ void CImageApplyAutoCrop::apply(std::vector& mats, bool isTwoSide) if (!mats[0].empty()) m_fixedSize = mats[0].size(); - apply(mats[1], 1); + if(!mats[0].empty()) + apply(mats[1], 1); if (!mats[0].empty()) m_fixedSize = dSize; diff --git a/huagao/ImageProcess/ImageApplyBWBinaray.cpp b/huagao/ImageProcess/ImageApplyBWBinaray.cpp index 2d1125b9..14d868b9 100644 --- a/huagao/ImageProcess/ImageApplyBWBinaray.cpp +++ b/huagao/ImageProcess/ImageApplyBWBinaray.cpp @@ -74,10 +74,15 @@ void CImageApplyBWBinaray::apply(std::vector& mats, bool isTwoSide) { if (mats.empty()) return; - apply(mats[0], 0); + if (!mats[0].empty()) { + apply(mats[0], 0); + } - if (isTwoSide && mats.size() > 1) - apply(mats[1], 1); + + if (isTwoSide && mats.size() > 1) { + if (!mats[1].empty()) + apply(mats[1], 1); + } } void CImageApplyBWBinaray::errorDiffuse(cv::Mat & image) diff --git a/huagao/ImageProcess/ImageApplyChannel.cpp b/huagao/ImageProcess/ImageApplyChannel.cpp index ba96ca49..4e1832b4 100644 --- a/huagao/ImageProcess/ImageApplyChannel.cpp +++ b/huagao/ImageProcess/ImageApplyChannel.cpp @@ -63,10 +63,14 @@ void CImageApplyChannel::apply(std::vector& mats, bool isTwoSide) { if (mats.empty()) return; - apply(mats[0], 0); + if (!mats[0].empty()) { + apply(mats[0], 0); + } - if (isTwoSide && mats.size() > 1) - apply(mats[1], 1); + if (isTwoSide && mats.size() > 1) { + if (!mats[1].empty()) + apply(mats[1], 1); + } } void CImageApplyChannel::except_channel(const cv::Mat & src, cv::Mat & dst, int channel) diff --git a/huagao/ImageProcess/ImageApplyCrop.cpp b/huagao/ImageProcess/ImageApplyCrop.cpp index 763da940..a95e63b5 100644 --- a/huagao/ImageProcess/ImageApplyCrop.cpp +++ b/huagao/ImageProcess/ImageApplyCrop.cpp @@ -41,8 +41,12 @@ void CImageApplyCrop::apply(std::vector& mats, bool isTwoSide) { if (mats.empty()) return; - apply(mats[0], 0); + if (!mats[0].empty()) { + apply(mats[0], 0); + } - if (isTwoSide && mats.size() > 1) - apply(mats[1], 1); + if (isTwoSide && mats.size() > 1) { + if (!mats[1].empty()) + apply(mats[1], 1); + } } diff --git a/huagao/ImageProcess/ImageApplyDiscardBlank.cpp b/huagao/ImageProcess/ImageApplyDiscardBlank.cpp index ff768b79..7d28c26f 100644 --- a/huagao/ImageProcess/ImageApplyDiscardBlank.cpp +++ b/huagao/ImageProcess/ImageApplyDiscardBlank.cpp @@ -168,8 +168,12 @@ void CImageApplyDiscardBlank::apply(std::vector& mats, bool isTwoSide) { if (mats.empty()) return; - apply(mats[0], 0); + if (!mats[0].empty()) { + apply(mats[0], 0); + } - if (isTwoSide && mats.size() > 1) - apply(mats[1], 1); + if (isTwoSide && mats.size() > 1) { + if (!mats[1].empty()) + apply(mats[1], 1); + } } \ No newline at end of file diff --git a/huagao/ImageProcess/ImageApplyResize.cpp b/huagao/ImageProcess/ImageApplyResize.cpp index ddf7e8f5..34073789 100644 --- a/huagao/ImageProcess/ImageApplyResize.cpp +++ b/huagao/ImageProcess/ImageApplyResize.cpp @@ -48,8 +48,12 @@ void CImageApplyResize::apply(std::vector& mats, bool isTwoSide) { if (mats.empty()) return; - apply(mats[0], 0); + if (!mats[0].empty()) { + apply(mats[0], 0); + } - if (isTwoSide && mats.size() > 1) - apply(mats[1], 1); + if (isTwoSide && mats.size() > 1) { + if (!mats[1].empty()) + apply(mats[1], 1); + } } diff --git a/huagao/ImageProcess/ImageApplyRotation.cpp b/huagao/ImageProcess/ImageApplyRotation.cpp index e82fe2d0..f2706c6b 100644 --- a/huagao/ImageProcess/ImageApplyRotation.cpp +++ b/huagao/ImageProcess/ImageApplyRotation.cpp @@ -121,8 +121,12 @@ void CImageApplyRotation::apply(std::vector& mats, bool isTwoSide) { if (mats.empty()) return; - apply(mats[0], 0); + if (!mats[0].empty()) { + apply(mats[0], 0); + } - if (isTwoSide && mats.size() > 1) - apply(mats[1], 1); + if (isTwoSide && mats.size() > 1) { + if (!mats[1].empty()) + apply(mats[1], 1); + } }