Standard Ellipse Detection 使用教程
1、项目介绍
Standard Ellipse Detection 是一个基于弧线支持的线段进行椭圆检测的开源项目。它适用于工业领域,可以稳定地检测图像中标准、明显、完整且大小在 100x100 像素以上的椭圆。该库的检测效果非常好,且速度较快,基于 C++ 实现。
2、项目快速启动
安装依赖
-
OpenCV 3:
- Ubuntu: 参考博客 https://blog.csdn.net/Arthur_Holmes/article/details/100146463 进行安装。
- CentOS: 参考博客 https://www.jianshu.com/p/1cb1ca235eb3 进行安装。
-
LAPACK:
- 下载 LAPACK 源码,使用 gfortran 编译安装。
-
Standard Ellipse Detection:
- 使用 git 克隆代码仓库:
git clone https://github.com/memory-overflow/standard-ellipse-detection
- 进入项目目录,执行以下命令编译安装:
mkdir build && cd build cmake .. make sudo make install
- 使用 git 克隆代码仓库:
使用方法
-
引入头文件:
#include "ellipse_detection/detect.h"
-
引入命名空间:
using namespace zgh;
-
使用 detectEllipse 函数进行检测:
bool detectEllipse( const uint8_t *image, // 图像原始数据,灰度图 int height, // 图像高度 int width, // 图像宽度 std::vector<std::shared_ptr<Ellipse> > &ells, // 检测到的椭圆列表 int polarity = 0, // 椭圆极性 (-1, 0, 1) double line_width = 2.0 // 椭圆线宽 );
-
Ellipse 结构说明:
struct Ellipse { Pointd o; // 椭圆中心点坐标 double a, b; // 短半轴长度, 长半轴长度 double phi; // 椭圆偏角, 单位为弧度 int polarity; // 椭圆极性 double goodness; // 椭圆评分 double coverangle; // 椭圆角度完整程度 std::vector<Pixel> inliers; // 构成的像素点 };
3、应用案例和最佳实践
应用案例
- 工业检测: 用于检测产品上的标准椭圆标记。
- 图像处理: 用于分割图像中的椭圆区域。
最佳实践
- 确保图像质量,避免噪声干扰。
- 调整参数,如极性和线宽,以适应不同场景。
- 对检测结果进行后续处理,如滤波和跟踪。
4、典型生态项目
- ellipse-detection: 基于 arc-support line segment 的椭圆检测项目。
- opencv: 开源计算机视觉库。
- lapack: 线性代数软件包。