/*
* ====================================================
* 功能:镜头脏污检测
* 作者:刘丁维
* 生成时间:2023/10/09
* 最近修改时间:2023/10/09 v1.0
2023/11/08 v1.1 增加接口,对数据顶部和底部数据同时检测,避免受到纸张越界产生的误判。
2023/12/05 v1.2 增加接口,通过判定多行数据,来确认脏污性质。
2023/12/06 v1.2.1 微调接口2判定逻辑。
* 版本号:v1.2.1
* ====================================================
*/
#ifndef CONTAMINATION_DETECTION_H
#define CONTAMINATION_DETECTION_H
typedef unsigned char uchar;
class ContaminationDetection
{
public:
ContaminationDetection();
///
/// 检测
///
/// top行待测数据
/// bottom行待测数据
/// 数据长度
/// 第一阈值,超过该阈值视为存在脏污
/// 第二阈值,配合width使用,超过该阈值且连续宽度达到width视为存在脏污
/// 脏污宽度,配合threshold2使用
/// 为0时表示无污染,反之有污染。
static int detect1(const uchar *data1, const uchar *data2, int length, uchar threshold1, uchar threshold2, int width);
///
/// 检测
///
/// 图像数据
/// 像素宽度
/// 高度
/// 通道数
/// 超过该阈值视为存在脏污
/// 脏污累计宽度
/// 为0时表示无污染;为1时表示脏污无规则,可能由纸张遮挡造成;为2时表示脏污规则
static int detect2(const uchar *data, int width, int height, int channels, uchar color, int length);
};
#endif