zynq_7010/ImageProcess_Public.h

131 lines
4.7 KiB
C
Raw Normal View History

2023-07-17 03:29:37 +00:00
// /*
// * ====================================================
// * 功能公共图像处理算法。部分功能可能会在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