opencv3用椭圆拟合二维点集-fitEllipse函数
2015-10-20 00:16
267 查看
#include<iostream> #include<vector> #include<opencv2/opencv.hpp> using namespace cv; using namespace std; int main() { Mat srcImage(Size(600, 600), CV_8UC3, Scalar(0)); RNG &rng = theRNG(); char key; while (1) { //随机生成一些点 //首先就是随机生成点的总数量 int g_nPointCount = rng.uniform(10, 30); //接下来就是随机生成一些点的坐标 vector<Point> points; for (int i = 0; i < g_nPointCount; i++) { Point midPoint; midPoint.x = rng.uniform(srcImage.cols / 4, srcImage.cols * 3 / 4); midPoint.y = rng.uniform(srcImage.rows / 4, srcImage.rows * 3 / 4); points.push_back(midPoint); } //显示刚刚随机生成的那些点 for (int i = 0; i < g_nPointCount; i++) { circle(srcImage, points[i], 0, Scalar(rng.uniform(0, 255), rng.uniform(0, 255), rng.uniform(0, 255)), 3); } //在生成的那些随机点中寻找拟合的椭圆 RotatedRect ellipsemege = fitEllipse(points); //根据得到的椭圆的信息 绘制椭圆 ellipse(srcImage, ellipsemege, Scalar(rng.uniform(0, 255), rng.uniform(0, 255), rng.uniform(0, 255)), 3); imshow("【绘制结束后的图像】", srcImage); key = waitKey(); if (key == 27) break; else srcImage = Scalar::all(0); } return 0; }
相关文章推荐
- opencv3寻找最小包围圆形在图像中的应用-滚动条
- 01_基于应用拆分的技术架构
- 01_基于应用拆分的技术架构
- opencv3寻找最小包围圆形-minEnclosingCircle函数
- opencv3寻找最小包围矩形在图像中的应用-滚动条
- opencv3寻找最小包围矩形-minAreaRect函数
- 【Linux命令】文件和目录操作命令
- opencv3实现分水岭算法-watershed函数
- opencv3矩的计算-在图像中的应用-滚动条
- opencv3矩的计算-在图像中的应用
- Linux之split命令详解
- 表单提交错误后返回内容消失问题的解决方法(PHP网站)
- CXF+Spring+Tomcat简明示例
- AOP的半自动代理 及 缺点
- Linux常见的挂载目录说明
- Linux中mysql忘记密码,或者登录不上,等等,都可使用以下方式
- Linux安装软件
- svnserve.conf: Option expected的问题解决方法
- nginx整合tomcat实现域名泛解析
- linux 开机自动清空/tmp目录是怎么回事