mirror of http://192.168.1.51:8099/lmh188/twain3
84 lines
2.7 KiB
C++
84 lines
2.7 KiB
C++
#ifndef IMAGE_APPLY_AUTO_CROP_H
|
||
#define IMAGE_APPLY_AUTO_CROP_H
|
||
|
||
#include "ImageApply.h"
|
||
|
||
class CImageApplyAutoCrop : public CImageApply
|
||
{
|
||
public:
|
||
CImageApplyAutoCrop();
|
||
|
||
/*
|
||
* isCrop [in]:自动幅面裁剪使能,true自动裁剪,false为固定裁剪
|
||
* isDesaskew [in]:自动纠偏使能,true自动纠偏,false为不纠偏
|
||
* isFillBlank [in]:黑底填充使能,true为填充,false为不填充
|
||
* fixedSize [in]:固定幅面尺寸,当isCrop为false时生效,结果尺寸按fixedSize大小输出,单位像素
|
||
* isConvex [in]:黑底填充时的填充方式,true为凸多边形填充,false为凹多边形填充,默认true
|
||
* isFillColor [in]:黑底填充时采用自适应色彩填充,false为白色填充,true为自适应文稿底色填充,默认false
|
||
* threshold [in]:二值化阈值,取值范围(0, 255),默认40
|
||
* noise [in]:除噪像素,能够消除noise宽度的背景竖条纹干扰,默认40
|
||
* indent [in]:轮廓缩进,裁剪、纠偏或者黑底填充时,对探索到的纸张轮廓进行缩进indent像素,默认5
|
||
*/
|
||
CImageApplyAutoCrop(bool isCrop, bool isDesaskew, bool isFillBlank, const cv::Size& fixedSize, bool isConvex = true, bool isFillColor = false, double threshold = 40, int noise = 40, int indent = 5);
|
||
|
||
virtual ~CImageApplyAutoCrop();
|
||
|
||
virtual void apply(cv::Mat& pDib, int side);
|
||
|
||
virtual void apply(std::vector<cv::Mat>& mats, bool isTwoSide);
|
||
|
||
bool isAutoCrop() { return m_isCrop; }
|
||
|
||
bool isFillBlank() { return m_isFillBlank; }
|
||
|
||
bool isDesaskew() { return m_isDesaskew; }
|
||
|
||
bool isConvexHull() { return m_isConvexHull; }
|
||
|
||
double threshold() { return m_threshold; }
|
||
|
||
int noise() { return m_noise; }
|
||
|
||
int indent() { return m_indent; }
|
||
|
||
cv::Size fixedSize() { return m_fixedSize; }
|
||
|
||
const std::vector<cv::Point>& maxContour() { return m_maxContour; }
|
||
|
||
void setAutoCrop(bool enabled) { m_isCrop = enabled; }
|
||
|
||
void setFillBlank(bool enabled) { m_isFillBlank = enabled; }
|
||
|
||
void setDesaskew(bool enabled) { m_isDesaskew = enabled; }
|
||
|
||
void setConvexHull(bool convex) { m_isConvexHull = convex; }
|
||
|
||
void setThreshold(double value) { m_threshold = value; }
|
||
|
||
void setNoise(int value) { m_noise = value; }
|
||
|
||
void setIndent(int value) { m_indent = value; }
|
||
|
||
void setFixedSize(cv::Size size) { m_fixedSize = size; }
|
||
|
||
private:
|
||
cv::Scalar getBackGroudColor(const cv::Mat& image, int total);
|
||
|
||
uchar getBackGroudChannelMean(const cv::Mat& gray, int total);
|
||
|
||
private:
|
||
bool m_isCrop;
|
||
bool m_isDesaskew;
|
||
bool m_isFillBlank;
|
||
bool m_isConvexHull;
|
||
bool m_isFillColor;
|
||
|
||
double m_threshold;
|
||
int m_noise;
|
||
int m_indent;
|
||
cv::Size m_fixedSize;
|
||
std::vector<cv::Point> m_maxContour;
|
||
};
|
||
|
||
#endif // !IMAGE_APPLY_AUTO_CROP_H
|