code_device/hgdriver/ImageProcess/LineContinuityDetection.h

29 lines
1.1 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.

#ifndef LINE_CONTINUITY_DETECTION_H
#define LINE_CONTINUITY_DETECTION_H
#include <opencv2/opencv.hpp>
class LineContinuityDetection
{
public:
LineContinuityDetection();
static bool isContinuous(const cv::Mat& image, double area_threshold = 100);
private:
/// <summary>
/// 获取连通区域轮廓
/// </summary>
/// <param name="src">源图像</param>
/// <param name="contours">结果轮廓集</param>
/// <param name="hierarchy">轮廓集的排序关系。与contours的数量对应受retr选项不同排序会有变化</param>
/// <param name="retr">轮廓集排序方式,默认为链式排序</param>
/// <param name="method">查找算法选择,默认为普通查找</param>
/// <param name="offset">查找起始点默认为0,0点</param>
static void myFindContours(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));
static bool findBlock(const std::vector<std::vector<cv::Point>>& contours, const std::vector<cv::Vec4i>& hierarchy, double area_threshold);
};
#endif //LINE_CONTINUITY_DETECTION_H