nim_duilib/examples/contour/i_contours_extractor.hpp

80 lines
2.4 KiB
C++
Raw Permalink Normal View History

2025-03-16 16:42:44 +08:00
#pragma once
#include <vector>
#include "opencv2/opencv.hpp"
namespace cvpr
{
enum class SMOOTH_METHOD {
NONE = 0,
BSPLINE
//DEANGEL
};
class __declspec(dllexport) IContoursExtractor {
public:
virtual ~IContoursExtractor() = default;
virtual void init() = 0;
virtual void destroy() = 0;
/*
* threshold,
*/
virtual void setAreaThreshold(double threshold = 500.0) = 0;
virtual double areaThreshold() = 0;
/*
* contourOffset, contourOffset取值为0时setSmoothMethod()method参数
*/
virtual void setContourOffset(int32_t offset = 12) = 0;
virtual int32_t contourOffset() = 0;
/*
* epsilon, 线
*/
virtual void setApproxPolyEpsilon(double epsilon = 5) = 0;
virtual double approxPolyEpsilon() = 0;
/*
* method, 线b样条曲线
*/
virtual void setSmoothMethod(SMOOTH_METHOD method = SMOOTH_METHOD::BSPLINE) = 0;
virtual SMOOTH_METHOD smoothMethod() = 0;
/*
* threshold, 线b样条曲线进行平滑SMOOTH_METHOD::DEANGEL模式下有效
*/
virtual void setAngelThreshold(double threshold = 20.0) = 0;
virtual double angelThreshold() = 0;
/*
* threshold,
*/
virtual void setDefectThreshold(double threshold = 0.0) = 0;
virtual double defectThreshold() = 0;
/*
* smoothStep, 线0.01.0
*/
virtual void setSmoothStep(double step = 0.001) = 0;
virtual double smoothStep() = 0;
/* 描述: 提取轮廓或轮廓偏置线
*
* alpha, alpha通道
* outputContours,
*/
virtual void extract(const cv::Mat& alpha, std::vector<std::vector<cv::Point>>& outputContours) = 0;
};
}