minEnclosingCircle函数怎么使用
时间: 2023-12-03 08:04:41 浏览: 41
minEnclosingCircle函数是OpenCV中的一个函数,用于计算一组点的最小外接圆。它的用法如下:
```cpp
void minEnclosingCircle(InputArray points, Point2f& center, float& radius);
```
其中,points参数是一个包含输入点集的Mat或vector对象,center参数是一个Point2f对象,表示计算得到的圆心,radius参数是一个float类型,表示计算得到的圆的半径。
下面是一个使用示例:
```cpp
#include <opencv2/opencv.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main()
{
vector<Point2f> points;
points.push_back(Point2f(100, 100));
points.push_back(Point2f(200, 200));
points.push_back(Point2f(300, 300));
Point2f center;
float radius;
minEnclosingCircle(points, center, radius);
cout << "center: " << center << endl;
cout << "radius: " << radius << endl;
return 0;
}
```
在这个例子中,我们定义了一个包含三个点的vector对象points,然后调用minEnclosingCircle函数计算最小外接圆的圆心和半径,并输出结果。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)