You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
2.4 KiB
C++
82 lines
2.4 KiB
C++
#ifndef COUTLINEDETECTOR_H
|
|
#define COUTLINEDETECTOR_H
|
|
//轮廓线识别
|
|
#include <opencv2\opencv.hpp>
|
|
#include <QImage>
|
|
#include <vector>
|
|
|
|
#include "..\..\SSBase\VoronoiMap\PolygonTreeInterface.h"
|
|
#include "ImageUtils.h"
|
|
#include "ContourUtils.h"
|
|
|
|
class COutlineDetector
|
|
{
|
|
public:
|
|
COutlineDetector();
|
|
void clear(void);
|
|
|
|
void setSurface(GSurface* pSurf, float zlower = 0, float zupper = 0, unsigned int nIters = 1);
|
|
//膨胀迭代次数
|
|
void setIterations(unsigned int nIterations);
|
|
//设置目标区域z值范围
|
|
void setTargetZRange(float zlower, float zupper);
|
|
//设置最小轮廓线面积
|
|
void setContourMinArea(float area);
|
|
//设置输出轮廓线平滑次数
|
|
void setContourSmoothTimes(unsigned int times);
|
|
|
|
//执行图像处理,生成初始轮廓线,并进行光滑
|
|
bool ProcessImage(void);
|
|
|
|
//生成沉积相轮廓线,局部合并内部包含孔洞的轮廓线
|
|
int CreateFaciesContours(void);
|
|
|
|
cv::Mat& getResultMat(); //返回结果图片
|
|
|
|
//图片中轮廓线转换为曲面坐标 dstContour, smoothTimes转换后为平滑次数
|
|
void multiContourToRealCoords(const Contours& inputContour, Contours& dstContour, int smoothTimes);
|
|
|
|
//获取初始轮廓线
|
|
Contours& GetOriginalContours(void);
|
|
|
|
//获取沉积相轮廓线
|
|
CPolygonTreeInterface* GetFaciesContours(void);
|
|
//获取沉积相轮廓线
|
|
shared_ptr<Contours> GetRealContours(void);
|
|
private:
|
|
|
|
void morphologySolve(void);
|
|
//由matMorp生成轮廓线
|
|
void createContours(void);
|
|
//面积过滤输出等值线,不符合条件的剔除
|
|
void FilterContours(float minArea, Contours& ReservedContours);
|
|
|
|
//五点三次平滑
|
|
void SmoothContours();
|
|
|
|
//图片中轮廓线转换为曲面坐标 dstContour, smoothTimes转换后为平滑次数
|
|
void contourToRealCoords(const Contour& inputContour, Contour& dstContour, int smoothTimes);
|
|
|
|
//生成边界轮廓线
|
|
void TraceBorder(void);
|
|
|
|
GSurface* m_pSurface;
|
|
cv::Mat m_matSrc; //原始图片(黑白图)
|
|
cv::Mat m_matMorp; // 形态学处理后的图片
|
|
cv::Mat m_matBorder; //用来追踪边界轮廓的黑白图
|
|
|
|
int m_nIterations;
|
|
float m_zlower;
|
|
float m_zupper;
|
|
double m_minArea;
|
|
int m_smoothTimes;
|
|
|
|
//图像处理后 生成的初始轮廓线
|
|
Contours m_originalContours;
|
|
std::vector<cv::Vec4i> m_hierarchy;
|
|
CPolygonTreeInterface m_pgnTree;
|
|
Contour m_border;
|
|
};
|
|
|
|
#endif // COUTLINEDETECTOR_H
|