code_app/modules/imgproc/ImageProcess/ImageProcess_Public.h

131 lines
4.2 KiB
C
Raw Normal View History

/*
* ====================================================
* ImageProcess里面多个类反复使用
*
* 2020/4/21
* 2020/4/21
* 2021/07/12 v1.1 getBoundingRect中 angle > 90
* 2021/07/22 v1.2 convexHull中BUG
* v1.2
* ====================================================
*/
#ifndef IMAGE_PROCESS_PUBLIC_H
#define IMAGE_PROCESS_PUBLIC_H
#include "opencv2/opencv.hpp"
#include <vector>
namespace hg
{
/*
*
* src:
* dst:
* clockwise: true为顺时针排序false为逆时针排序
*/
void convexHull(const std::vector<cv::Point>& src, std::vector<cv::Point>& dst, bool clockwise = false);
/*
*
* image:
* points:
*/
void fillConvexHull(cv::Mat& image, const std::vector<cv::Point>& points);
/*
*
* image:
* contours:
* color:
*/
void fillPolys(cv::Mat& image, const std::vector<std::vector<cv::Point>>& contours, const cv::Scalar& color);
/*
*
* src:
* contours:
* hierarchy: contours的数量对应retr选项不同
* retr:
* method:
* offset: 0,0
*/
void findContours(const cv::Mat& src, std::vector<std::vector<cv::Point>>& contours, std::vector<cv::Vec4i>& hierarchy,
int retr = cv::RETR_LIST, int method = cv::CHAIN_APPROX_SIMPLE, cv::Point offset = cv::Point(0, 0));
/*
*
* contour:
* :
*/
cv::RotatedRect getBoundingRect(const std::vector<cv::Point>& contour);
/*
* :
* contours:
* hierarchy: contours对应
* :
*/
std::vector<cv::Point> getMaxContour(const std::vector<std::vector<cv::Point>>& contours, const std::vector<cv::Vec4i>& hierarchy);
/*
* :
* contours:
* hierarchy: contours对应
* :
*/
std::vector<cv::Point> getVertices(const cv::RotatedRect& rect);
/*
* :
* points:
* center: center点缩进
* indent:
*/
void polyIndent(std::vector<cv::Point>& points, const cv::Point& center, int indent);
/*
* : src为彩色图像时
* src:
* dst:
* thre:
*/
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);
}
#endif // !IMAGE_PROCESS_C_H