算法介绍: 对图像中的任意多边形进行检测
输入: 图像,多边形逼近精度,多边形最小面积
输出: 检测出的多边形角点
函数声明:
vector<vector<Point>> polygonDetect(Mat&,double epsilon,int minAcreage); //多边形检测
调用:
Mat matin=camera->read(); //视频流读入
vector<vector<Point>> polygonDetectRet=polygonDetect(matin,8,2000);
for(int i=0;i<polygonDetectRet.size();i++)
for(int j=0;j<polygonDetectRet[i].size();j++){
circle(matin,polygonDetectRet[i][j],4,Scalar(0,0,255),-1);
}
imshow("多边形检测结果",matin);
效果图:
源码:
//多边形检测
vector<vector<Point>> polygonDetect(Mat&