twain3/ImageProcess/ImageApplyDogEarDetection.h

57 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/10/30
* 最近修改时间2020/10/30
* 版本号v1.0
* ====================================================
*/
#ifndef IMAGE_APPLY_DOGEAR_DETECTION_H
#define IMAGE_APPLY_DOGEAR_DETECTION_H
#include "ImageApply.h"
class CImageApplyDogEarDetection :public CImageApply
{
public:
/// <summary>
/// 折角检测默认构造函数threshold = 40 zoom = 1.0 distance = 50
/// </summary>
CImageApplyDogEarDetection();
/// <summary>
/// 折角检测构造函数
/// </summary>
/// <param name="threshlod">二值化阈值</param>
/// <param name="zoom">原图缩放比例对于大尺寸图像而言通过zoom缩小图像可减少计算量。默认值1.0(不缩放)</param>
/// <param name="distance">理论顶点到实际轮廓最小距离的阈值大于该阈值则判定为折角默认值50像素</param>
CImageApplyDogEarDetection(double threshlod, double zoom = 1.0, double distance = 50);
virtual ~CImageApplyDogEarDetection(void);
/// <summary>
/// 获取检测结果。该函数须在调用apply之后使用。
/// </summary>
/// <returns>true为折角false为不折角</returns>
inline bool getResult() { return m_result; }
virtual void apply(cv::Mat& pDib, int side);
private:
virtual void apply(std::vector<cv::Mat>& mats, bool isTwoSide);
private:
double m_threshold;
double m_zoom;
double m_distance;
bool m_result;
};
#endif // IMAGE_APPLY_DOGEAR_DETECTION_H