Code Monkey home page Code Monkey logo

standard-ellipse-detection's Introduction

介绍

本库提供了一个可以在工业中稳定使用的椭圆检测方法。对于图像中的标准、明显、完整、大小在 100x100 像素以上的椭圆的检测效果非常好,速度也很快。 这个库的实现参考了论文 https://arxiv.org/pdf/1810.03243v4.pdf。

效果展示

微信小程序搜索"椭圆识别"可以体验效果。

图1

图2

图3

安装

Ubuntu

Install opencv

opencv 需要通过源码安装,ubuntu opencv 的安装可以参考博客 https://blog.csdn.net/Arthur_Holmes/article/details/100146463, 注意本项目中一定要安装 opencv3 的版本,否则可能会有兼容性问题。服务器版本无需安装图像化相关的库。

Install lapack

lapack 是一个矩阵运算的库,也是需要源码安装。 先下载lapack源码,lapack 是 gfortran 写的,要先sudo apt-get install gfortran安装gfortran 才能正常编译。

执行下面的操作完成安装

tar -xzvf lapack-3.9.1.tar.gz && cd lapack-3.9.1
mkdir build && cd build
cmake ..
make -j7
sudo make install
sudo ldconfig
cd ..
sudo cp LAPACKE/include/*.h /usr/local/include/

Install ellipse-detection

执行下面的操作完成安装

git clone https://github.com/memory-overflow/standard-ellipse-detection.git
cd standard-ellipse-detection
mkdir build && cd build
cmake ..
make
sudo make install

Centos

Install opencv

opencv 需要通过源码安装,centos 的 opencv 的安装可以参考博客 https://www.jianshu.com/p/1cb1ca235eb3, 注意本项目中一定要安装 opencv3 的版本,否则可能会有兼容性问题。服务器版本无需安装图像化相关的库。

Install lapack

lapack 是一个矩阵运算的库,也是需要源码安装。 先下载lapack源码,lapack 是 gfortran 写的,要先yum install gcc-gfortran安装 gfortran 才能正常编译。

由于 lapack 的编译需要 cmake3, 先安装 cmake3, yum install cmake3

执行下面的操作完成 lapack 的安装

tar -xzvf lapack-3.9.1.tar.gz && cd lapack-3.9.1
mkdir build && cd build
cmake3 ..
make -j7
sudo make install
sudo ldconfig
cd ..
sudo cp LAPACKE/include/*.h /usr/local/include/

Install ellipse-detection

执行下面的操作完成安装

git clone https://github.com/memory-overflow/standard-ellipse-detection.git
cd standard-ellipse-detection
mkdir build && cd build
cmake3 ..
make
sudo make install

提供一个 centos server 的镜像,可以作为基础镜像开发,里面装好的依赖和库。

docker pull jisuanke/standard-ellipse-detection-centos7

Other system

其他操作系统请自行按照 ubuntu 和 centos 的流程安装。

接口和使用方法

代码中引用头文件#include "ellipse_detection/detect.h",然后引入namespace zgh。

接口说明

bool detectEllipse(const uint8_t *image, int height, int width,
                   std::vector<std::shared_ptr<Ellipse> > &ells,
                   int polarity = 0, double line_width = 2.0);
  • 输入参数:
    • image 图像原始数据,灰度图,彩色图需要先转换成灰度图,并且转换成一维数组输入
    • height 图像高度
    • width 图像宽度
    • polarity 表示椭圆极性,-1、0、1, 默认为 0,检测所有极性。
    • line_width 椭圆线宽,单位像素,推荐使用默认值
  • 输出
    • ells 检测到的椭圆列表

关于 Ellipse 结构的说明

Pointd o; // 椭圆中心点坐标
double a, b; // 短半轴长度,长半轴长度
double phi; // 椭圆偏角,单位为弧度
int polarity; // 椭圆极性
double goodness; // 椭圆评分
double coverangle; // 椭圆角度完整程度
std::vector<Pixel> inliers; // 构成的像素点

测试

提供了1个测试工具,可以查看算法效果。需要桌面版的操作系统才能显示图片,如果是服务器版本的操作系统,需要注释掉 imshow 部分。

cmake3 .. -DBUILD_TESTING=ON
make
./bin/testdetect [image_dir1] [image_dir2] [image_dir3] ...

有问题欢迎联系 [email protected], wechat: islands___

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.