twain3.0/huagao/ImageProcess/ImageApplyColorRecognition.h

67 lines
1.9 KiB
C++
Raw 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.

/*
* ====================================================
* 功能色彩识别将识别会“灰度”的24位图转化为256色8位图 把识别为“黑白”图转化为二值化的8位图
* 作者:刘丁维
* 生成时间2020/7/17
* 最近修改时间2020/12/15
* 版本号v1.0 2020/7/17
* v1.1 2020/12/15 调整策略,仅判断红色像素,存在红色像素为彩色,否则为灰度;删除输出结果,直接转换图像。
* v1.2 2020/12/16 增加颜色限制模式(输出结果只可能两种),增加结果访问接口
* ====================================================
*/
#ifndef IMAGE_APPLY_COLOR_RECOGNITION_H
#define IMAGE_APPLY_COLOR_RECOGNITION_H
#include "ImageApply.h"
class CImageApplyColorRecognition : public CImageApply
{
public :
//色彩识别模式
enum ColorRecognitionMode
{
AllColor, //全色模式 识别结果可能会是彩色、灰度、黑白
Color_Gray, //彩色灰度模式 识别结果只会是彩色或者灰度
Color_Mono, //彩色黑白模式 识别结果只会是彩色或者黑白
Gray_Mono //灰度黑白模式 识别结果只会是灰度或者黑白
};
//色彩类型
enum ColorType
{
Color, //彩色
Gray, //灰度
Mono //黑白
};
public:
CImageApplyColorRecognition(ColorRecognitionMode mode = AllColor);
virtual ~CImageApplyColorRecognition(void);
virtual void apply(cv::Mat& pDib, int side);
virtual void apply(std::vector<cv::Mat>& mats, bool isTwoSide);
/// <summary>
/// 获取图片色彩类型。配合void apply(cv::Mat&, int)接口使用
/// </summary>
/// <returns>色彩类型</returns>
ColorType getResult();
/// <summary>
/// 获取图片色彩类型。配合void apply(std::vector<cv::Mat>&, int)接口使用
/// </summary>
/// <returns>色彩类型数组</returns>
std::vector<ColorType> getResults();
private:
ColorType m_result;
std::vector<ColorType> m_results;
ColorRecognitionMode m_mode;
};
#endif // !IMAGE_APPLY_CONCATENATION_H