speedcontroller/imageprocess/ImageApplyOutHole.h

68 lines
1.7 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* ====================================================
* 功能:装订孔填充
* 作者:刘丁维
* 生成时间2020/11/21
* 最近修改时间2020/05/12 v1.0
* 2020/11/17 v1.1
* 版本号v1.0
* ====================================================
*/
#ifndef IMAGE_APPLY_OUT_HOLE_H
#define IMAGE_APPLY_OUT_HOLE_H
#include "ImageApply.h"
class CImageApplyOutHole : public CImageApply
{
public:
CImageApplyOutHole();
/*
* borderSize [in]:孔洞面积阈值
* edgeScale [in]:纸张边缘区域比例,取值范围(0,0.5),默认值0.1
* threshold [in]:二值化阈值
*/
CImageApplyOutHole(float borderSize, float edgeScale, double threshold);
~CImageApplyOutHole(void);
virtual void apply(std::vector<cv::Mat>& mats, bool isTwoSide);
float getBorderSize() { return m_borderSize; }
float getEdgeScale() { return m_edgeScale; }
double getThreshold() { return m_threshold; }
void setBorderSize(float size) { m_borderSize = size; }
void setEdgeScale(float scale) { m_edgeScale = scale; }
void setThreshold(double threshold) { m_threshold = (std::min)((std::max)(threshold, 1.0), 254.0); }
private:
virtual void apply(cv::Mat& pDib, int side);
void getRoi(cv::RotatedRect rrect_front, cv::RotatedRect rrect_back, cv::Size srcSize, cv::Rect& roi_front,
cv::Rect& roi_back, cv::RotatedRect& mask_rotatedRect);
std::vector<std::vector<cv::Point> > filterPoly(std::vector<std::vector<cv::Point>>& contours, const std::vector<cv::Vec4i> &m, cv::RotatedRect roi,
float edgeScale, float areaThreshold);
cv::Scalar getBackGroudColor(const cv::Mat& image, const std::vector<cv::Point> pixelPoints);
private:
float m_borderSize;
float m_edgeScale;
double m_threshold;
};
#endif // !IMAGE_APPLY_OUT_HOLE_H