code_app/modules/imgproc/ImageProcess/ImageApplyOutHole.h

77 lines
2.6 KiB
C
Raw Permalink Normal View History

/*
* ====================================================
*
*
* 2020/11/21
* 2020/05/12 v1.0
* 2020/11/17 v1.1
* 2021/09/06 v1.2 50100
* 2021/11/03 v1.3 10穿
* 2021/11/04 v1.4 5
* 2021/11/17 v1.5 opencv版本导致的BUG
* 2022/04/18 v1.6 BUG
* 2022/05/04 v1.6.1
* v1.6.1
* ====================================================
*/
#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, const cv::Size& srcSize_front, const cv::Size& srcSize_back, 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);
cv::Scalar getBackGroudColor(const cv::Mat& image, int total);
uchar getBackGroudChannelMean(const cv::Mat& gray, int total);
private:
float m_borderSize;
float m_edgeScale;
double m_threshold;
};
#endif // !IMAGE_APPLY_OUT_HOLE_H