/* * ==================================================== * ���ܣ�Mark�㶨λ�ü���ʶ���Ծ��е�mark�㣬���о�ƫ�ü����ù��ܲ�����ȫ����ʹ�ã���Ϊ���ܻ�ʶ��ʧ�ܣ�Ȼ����Ҫ�����ô�ͳ�ü���ƫ���в��䡣 * ���ߣ�����ά * ����ʱ�䣺2020/5/22 * ����޸�ʱ�䣺2020/5/22 v1.0 2020/7/29 v1.1 �Ż�Mark��ʶ���Լ��ĸ巽���ж� 2020/7/30 v1.1.1 �Ż�Mark��ʶ���Լ��ĸ巽���ж� 2020/8/3 v1.2 ������죬������Mark��ʶ���ĸ巽��ԭ���ķ�ʽ����Ϊ���ʶ���ĸ巽�� 2020/8/12 v1.3 ������죬�����������ж��㷨�������ж��Ծ��Ƿ�Ϊָ���Ծ���������ֻ�Ǵ���ʶ���Ƿ������룬��������׼ȷʶ�� apply�ӿ�����barCode�����������Ƿ������ж����빦�� 2020/8/12 v1.4 ������죬���Ӳü��ӿڣ��ɽ��вü��벻�ü�����ѡ�� * �汾�ţ�v1.4 * ==================================================== */ #ifndef IMAGEMARKCROPAPPLY_H #define IMAGEMARKCROPAPPLY_H #include "ImageApply.h" class CImageApplyMarkCrop { public: //ʶ���ĸ巽��ʽ enum DirectionMethod { Trilateral_7Net, //���߶�λ�ĸ巽������������� Multilateral //��߶�λ�ĸ巽�� }; enum DPI : ushort { DPI_200 = 200, DPI_300 = 300 }; enum DeviceModel { G400 = 2, G300 = 3 }; enum Orientation { Default = 0, Left_RT, //����ĸ巽��ʶ��ʱ����Ϊ����7��3markʶ��ʱ��ȱ��������Ϊ�� Top_RB, //����ĸ巽��ʶ��ʱ����Ϊ����7��3markʶ��ʱ��ȱ��������Ϊ�� Right_LB, //����ĸ巽��ʶ��ʱ����Ϊ����7��3markʶ��ʱ��ȱ��������Ϊ�� Bottom_LT //����ĸ巽��ʶ��ʱ����Ϊ����7��3markʶ��ʱ��ȱ��������Ϊ�� }; public: CImageApplyMarkCrop(DeviceModel device, bool isCropped = true, double threshold = 20, int noise = 40, DPI dpi = DPI::DPI_200, DirectionMethod direction = DirectionMethod::Multilateral); /* * src [in]: ԭͼ * dst [out]:�����ɹ�ʱ�����صĽ��ͼ�� * markOri [in]: �ĸ巽���ж���ʽ * barCode [in]: �Ƿ��ж������룬�ù���ֻ���Trilateral_7Netģʽ * angle [out]:�����ĸ巽��ƫת�Ƕȡ���0��90��180��270������� * ����ֵ�� 0���ɹ��� -1��ԭͼΪ�գ������޷��ҵ�ͼƬ����������ͼ�ᱨ�ô��󣩣� -2��markС��3�� -3��ѡ��Multilateralģʽʱ��mark��С��4�� -4��ʶ��������ʱ��Ŀ��ͼ���С���޷����������� -5���������� */ int apply(const cv::Mat& src, cv::Mat& dst, Orientation markOri, bool barCode, int& angle); inline DeviceModel getDeviceModel() { return m_device; } inline void setDeviceModel(DeviceModel device) { m_device = device; } inline bool isCropped() { return m_b_isCropped; } inline void setCropped(bool cropped) { m_b_isCropped = cropped; } inline double getThreshold() { return m_threshold; } inline void setThreshold(double threshold) { m_threshold = threshold; } inline int getNoise() { return m_noise; } inline void setNoise(int noise) { m_noise = noise; } inline DPI getDPI() { return m_dpi; } inline void setDPI(DPI dpi) { m_dpi = dpi; } inline const cv::Range getSizeRange() { return m_range; } inline void setSizeRange(const cv::Range& range) { m_range = range; } inline void setSizeRange(int low, int up) { m_range = cv::Range(low, up); } private: void findMarks(const std::vector>& contours, const cv::RotatedRect& region, const cv::Range& range, std::vector>& marks, std::vector& rrect); bool isContainBarCode(const cv::Mat& image); private: DeviceModel m_device; bool m_b_isCropped; double m_threshold; int m_noise; DPI m_dpi; cv::Range m_range; DirectionMethod m_direction; }; #endif // IMAGEMARKCROPAPPLY_H