Opencv中求点集的最小外结矩使用方法minAreaRect,求点集的最小外接圆使用方法minEnclosingCircle。
minAreaRect方法原型:
RotatedRect minAreaRect( InputArray points );
输入参数points是所要求最小外结矩的点集数组或向量;
minEnclosingCircle方法原型:
void minEnclosingCircle( InputArray points,
CV_OUT Point2f& center, CV_OUT float& radius );
第一个参数points是所要求最小外结圆的点集数组或向量;
第二个参数Point2f类型的center是求得的最小外接圆的中心坐标;
第三个参数float类型的radius是求得的最小外接圆的半径;
使用minAreaRect和minEnclosingCircle方法分别求最小外接矩和圆:
#include "core/core.hpp"
#include "highgui/highgui.hpp"
#include "imgproc/imgproc.hpp"
#include "iostream"
using namespace std;
using namespace cv;
int main(int argc,char *argv[])
{
Mat imageSource=imread(argv[1],0);
imsh