/* * ==================================================== * ���ܣ�����ͼ�����㷨�����ֹ��ܿ��ܻ���ImageProcess�������෴��ʹ�� * ���ߣ�����ά * ����ʱ�䣺2020/4/21 * ����޸�ʱ�䣺2020/4/21 * 2021/07/12 v1.1 getBoundingRect�У����ӿ��Ǿ�����ʼ angle > 90 ������� * 2021/07/22 v1.2 convexHull�У��޸��㼯Ϊ�տ��ܵ��±�����BUG�� * 2023/11/02 v1.3 threshold_Mat,��thre<0ʱ����������Ӧ������ֵ���� * 2023/12/01 v1.4 ����getBackGroundColor�㷨�� * 2023/12/02 v1.4.1 getBackGroundColor����threshold��ֵ�� * 2023/12/04 v1.4.2 ����opencv�汾�ӿڡ� * 2023/12/05 v1.4.3 getBackGroundColor֧�ֵ�ͨ��ͼ�񱳾�ɫʶ�� * �汾�ţ�v1.4.3 * ==================================================== */ #ifndef IMAGE_PROCESS_PUBLIC_H #define IMAGE_PROCESS_PUBLIC_H #include "opencv2/opencv.hpp" #include namespace hg { /* * ���ܣ�����Դ�㼯��͹�������������������㼯 * src: Դ�㼯 * dst: Ŀ��㼯 * clockwise: trueΪ˳ʱ������falseΪ��ʱ������ */ void convexHull(const std::vector& src, std::vector& dst, bool clockwise = false); /* * ���ܣ����͹����Σ�Ĭ����ɫΪ��ɫ * image: ���ͼ�� * points: ͹����������㼯����ʱ������ */ void fillConvexHull(cv::Mat& image, const std::vector& points); /* * ���ܣ���䰼����� * image: ���ͼ�� * contours: ������������㼯����ʱ������ * color: �����ɫ */ void fillPolys(cv::Mat& image, const std::vector>& contours, const cv::Scalar& color); /* * ���ܣ���ȡ��ͨ�������� * src: Դͼ�� * contours: ��������� * hierarchy: �������������ϵ����contours��������Ӧ����retrѡ�ͬ��������б仯 * retr: ����������ʽ��Ĭ��Ϊ��ʽ���� * method: �����㷨ѡ��Ĭ��Ϊ��ͨ���� * offset: ������ʼ�㣬Ĭ��Ϊ��0,0���� */ void findContours(const cv::Mat& src, std::vector>& contours, std::vector& hierarchy, int retr = cv::RETR_LIST, int method = cv::CHAIN_APPROX_SIMPLE, cv::Point offset = cv::Point(0, 0)); /// /// ��ȡͼƬ�ĸ��ɫ /// /// ͼ����ͨ�� /// ��Ĥ /// ��ֵ�������ų���ɫ���� /// �ĸ��ɫ cv::Scalar getBackGroundColor(const cv::Mat& image, const cv::Mat& mask = cv::Mat(), int threshold = 20); /* * ���ܣ���ȡ���ǵ㼯����С��Ӿ��� * contour: �㼯 * ����ֵ: ��ת���� */ cv::RotatedRect getBoundingRect(const std::vector& contour); /* * ����: ��ȡ��������������С���͹��������� * contours: ��������ÿ�������ɵ㼯��ɣ� * hierarchy: �������У�����֮��Ĺ�ϵ��������contours��Ӧ * ����ֵ: ͹����������㼯 */ std::vector getMaxContour(const std::vector>& contours, const std::vector& hierarchy); /* * ����: ��ȡ��������������С���͹��������� * contours: ��������ÿ�������ɵ㼯��ɣ� * hierarchy: �������У�����֮��Ĺ�ϵ��������contours��Ӧ * ����ֵ: ͹����������㼯 */ std::vector getVertices(const cv::RotatedRect& rect); /* * ����: �������� * points: �����㼯 * center: Χ��center������ * indent: �������� */ void polyIndent(std::vector& points, const cv::Point& center, int indent); /* * ����: ��ֵ�����ܹ�������ɫ�ͻҶ�ͼ��srcΪ��ɫͼ��ʱ���Ҷ�ͼȡ����ͨ�������ֵ * src: Դͼ * dst: Ŀ��ͼ * thre: ��ֵ����thre < 0ʱ�����ñ���ɫ��Ϊÿ������Ӧ��ֵ�� */ void threshold_Mat(const cv::Mat& src, cv::Mat& dst, double thre); /* * ����: ��ɫת�Ҷȣ��Ҷ�ͼȡ����ͨ�������ֵ * src: Դͼ * ����ֵ: �Ҷ�ͼ */ cv::Mat transforColor(const cv::Mat& src); /* * ����: ��ȡ��ķ���任 * p: ԭ�� * warp_mat: ����任ϵ������ * ����ֵ: �任��ĵ� */ cv::Point warpPoint(const cv::Point& p, const cv::Mat& warp_mat); /* * ����: �㵽����� * p1: ��1 * p2: ��2 * ����ֵ: �㵽����� */ int distanceP2P(const cv::Point& p1, const cv::Point& p2); /* * ����: �㵽ֱ�߾��� * p: �� * l1: ֱ�߶˵�1 * l2: ֱ�߶˵�2 * ����ֵ: �㵽ֱ�߾��� */ float distanceP2L(const cv::Point& p, const cv::Point& l1, const cv::Point& l2); void initLut(const std::string lutpath, bool iscolor); cv::Mat loadLUT(const std::string& file); void correctColor(cv::Mat& src, int dpi, int mode,bool isText); } #endif // !IMAGE_PROCESS_C_H