51 lines
1.9 KiB
C
51 lines
1.9 KiB
C
|
/*
|
|||
|
* ====================================================
|
|||
|
|
|||
|
* 功能:镜头脏污检测
|
|||
|
* 作者:刘丁维
|
|||
|
* 生成时间: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();
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 检测
|
|||
|
/// </summary>
|
|||
|
/// <param name="data1">top行待测数据</param>
|
|||
|
/// <param name="data2">bottom行待测数据</param>
|
|||
|
/// <param name="length">数据长度</param>
|
|||
|
/// <param name="threshold1">第一阈值,超过该阈值视为存在脏污</param>
|
|||
|
/// <param name="threshold2">第二阈值,配合width使用,超过该阈值且连续宽度达到width视为存在脏污</param>
|
|||
|
/// <param name="width">脏污宽度,配合threshold2使用</param>
|
|||
|
/// <returns>为0时表示无污染,反之有污染。</returns>
|
|||
|
static int detect1(const uchar *data1, const uchar *data2, int length, uchar threshold1, uchar threshold2, int width);
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 检测
|
|||
|
/// </summary>
|
|||
|
/// <param name="data">图像数据</param>
|
|||
|
/// <param name="width">像素宽度</param>
|
|||
|
/// <param name="height">高度</param>
|
|||
|
/// <param name="channels">通道数</param>
|
|||
|
/// <param name="color">超过该阈值视为存在脏污</param>
|
|||
|
/// <param name="length">脏污累计宽度</param>
|
|||
|
/// <returns>为0时表示无污染;为1时表示脏污无规则,可能由纸张遮挡造成;为2时表示脏污规则</returns>
|
|||
|
static int detect2(const uchar *data, int width, int height, int channels, uchar color, int length);
|
|||
|
};
|
|||
|
|
|||
|
#endif
|