twain2/AutoCrop.h

49 lines
1.8 KiB
C++

#pragma once
#include "ImageApply.h"
class CAutoCrop : public CImageApply
{
public:
CAutoCrop( bool bFill = true,bool bautoDeScrew = true,bool bCrop = true,SIZE dstsize = CSize(0, 0),SIZE originsize=CSize(0,0),int tw_pixType=2);
virtual ~CAutoCrop();
void apply(cv::Mat& dib,int side);
void setFill(bool val);
bool getFill();
void setCrop(bool val);
bool getCrop();
private:
enum RC_TYPE {
RC_INVALID = 0x0,
RC_ROTATED = 0x1,
RC_CUT = 0x2,
RC_BLACK_BACKGROUD = 0x4,
RC_SHARPING = 0x8
};
void sharpen(cv::Mat& Mat);
cv::Point2f warpPoint(cv::Point p, const cv::Mat& warp_Mat);
void rotated_and_cut(cv::Mat &src, cv::Mat& dst,int flags,double threshold,int noise,int indent);
void fillBlackBackGround(cv::Mat& src, std::vector<cv::Point> points, float indent);
void polyIndent(std::vector<cv::Point>& points, float indent);
void fill_poly(cv::Mat& src, const std::vector<std::vector<cv::Point>>& contours, const cv::Scalar& color, int lineType = 8, int shift = 0, cv::Point offset = cv::Point());
cv::RotatedRect getBoundingRect(const std::vector<cv::Point>& contour);
std::vector<cv::Point> getMaxContour(const std::vector<std::vector<cv::Point>>& contours, const std::vector<cv::Vec4i>& hierarchy);
void findContours(const cv::Mat& src, std::vector<std::vector<cv::Point>>& contours, std::vector<cv::Vec4i>& hierarchy,
int retr = cv::RETR_LIST, int method = cv::CHAIN_APPROX_SIMPLE, cv::Point offset = cv::Point(0, 0));
void threshold_Mat(const cv::Mat& src, cv::Mat& dst, double thre, int noise);
cv::Mat transforColor(const cv::Mat& src);
void MyConvexHull(const std::vector<cv::Point>& src, std::vector<cv::Point>& dst, bool clockwise = false);
bool m_bCrop;
bool m_bFill;
bool m_bAutoDescrew;
SIZE m_dstSize;
SIZE m_originSize;
int tw_pixType;
};