twain3.0/huagao/ImageProcess/ImageApplyRotation.h

69 lines
1.6 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.

/*
* ====================================================
* 功能:旋转图像
* 作者:刘丁维
* 生成时间2020/4/21
* 最近修改时间v1.0 2020/4/21
v1.1 2020/8/12 修复文稿方向自动识别导致崩溃的BUG
* 版本号v1.1
* ====================================================
*/
#ifndef IMAGE_APPLY_ROTATION_H
#define IMAGE_APPLY_ROTATION_H
#include "ImageApply.h"
class CImageApplyRotation : public CImageApply
{
public:
enum class RotationType
{
Invalid, //无效
Rotate_90_clockwise, //顺时针90°
Rotate_180, //180°
Rotate_90_anti_clockwise, //逆时针90°即270°
AutoTextOrientation //自动文稿方向识别旋转
};
public:
/*
* rotation [in]:旋转类型
* isBackTransposed [in]:true为背面180°旋转反之亦然
* dpi [in]:当前图像的DPI该参数在rotation为AutoTextOrientation时生效。在识别文稿方向时会默认将图像变换为200DPI进行识别
* tessadataPath [in]:训练库文件路径该参数在rotation为AutoTextOrientation时生效
*/
CImageApplyRotation(RotationType rotation, bool isBackTransposed = false, int dpi = 200, const char* tessdataPath = nullptr);
virtual ~CImageApplyRotation();
virtual void apply(cv::Mat & pDib, int side) override;
virtual void apply(std::vector<cv::Mat>& mats, bool isTwoSide);
bool isBackTransposed() { return m_backTranspose; }
int getDPI() { return m_dpi; }
RotationType getRotationType() { return m_rotation; }
void setBackTransposed(bool enabled) { m_backTranspose = enabled; }
void setDPI(int dpi) { m_dpi = dpi; }
void setRotationType(RotationType type) { m_rotation = type; }
private:
RotationType m_rotation;
bool m_backTranspose;
int m_dpi;
void* osd;
};
#endif // !IMAGE_APPLY_ROTATION_H