圆检测学习笔记

目录

边缘检测,再检测圆 

霍夫圆检测


转自:

深度OpenCV开发之精准找圆

 

GitHub - zikai1/CircleDetection: circle detection, inscribed triangles, image processing, Hough transform

 有图片资源:

本机:\CircleDetection-master

dataset Mini.zip

GitHub - zhouqun92/Circle-detect-based-on-Hough-Transform-: Preference :"Size invariant circle detection"

边缘检测,再检测圆 

GitHub - starbead/opencv_circlefind: using canny and houghcircles for find coins

https://github.com/mdNzaman/Coin-Detection-using-hough-Circles-master

圆标注:

python opencv 圆形roi_jacke121的专栏-CSDN博客

有数据:

GitHub - AlanLuSun/Circle-detection: Circle detection/circle detector by arc-support line segments. The source code for IEEE ICIP paper.

支持Windows:

https://github.com/vpplatonov/ellipse_detector

在原作者上修改了一下, 原版地址:

GitHub - dlut-dimt/ellipse-detector

原作者的不乱码,

vpplatonov的代码中文乱码,导致编译失败

比如报错:出现很多未声明的标识符:

因为里面的中文乱码了,把乱码删掉可以。

但是程序运行结果不对,对着原版把注释拷贝过来,

用notepad++,把右下角改为如下图:

但是中文注释正常显示,就能编译成功了。 

c++圆检测,圆弧检测,

基于OpenCV和Python的图像圆弧检测 - 问答 - Python中文网

python opencv 工业园检测:

工业圆型检测_楠梧斋的博客-CSDN博客

 https://github.com/memory-overflow/standard-ellipse-detection

由于业界没有好的椭圆检测算法,所以我写一个库用来做椭圆检测。这个库对于图像中的标准、明显、完整、大小在 100x100 像素以上的椭圆的检测效果非常好,速度也很快。 这个库的实现参考了论文 https://arxiv.org/pdf/1810.03243v4.pdf。

ubuntu 的使用方法

  1. 首先需要安装两个库的支持,opencv 库,这个可以搜一下网上的教程安装一下。第二个库是一个矩阵运算的库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/
  1. 安装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

效果未测:

识别圆的强化RANSAC算法_JY_JOKE的博客-CSDN博客_ransac 圆

椭圆检测:

说明,matlab的:

【MATLAB】椭圆检测(Ellipse Detection)算法(含代码)_HPC_ZY-CSDN博客_matlab椭圆检测

High-quality-ellipse-detection/generateEllipseCandidates.cpp at master · AlanLuSun/High-quality-ellipse-detection · GitHub

c++调用matlab的代码:

C++调用Matlab的.m编程文件_蓦然回首-CSDN博客

【转】C++调用Matlab的.m文件_weixin_34354945的博客-CSDN博客

霍夫圆检测:

霍夫圆检测_jacke121的专栏-CSDN博客_霍夫圆检测

tf模型:

GitHub - mhamdan91/Circle_detector: Detect complete and incomplete circular shapes in noisy images

输入时200*200,只能检测提供的圆,真实场景效果不好

    params=(125, 117 , 7)
    results=[]
    img=cv2.imread(R"C:\Users\002.jpg")
    img=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
    img_o=cv2.resize(img,(200,200))
    img=img_o.astype(np.float)/255
    detected = find_circle(img)


    draw_circle(img_o, int(detected[0]), int(detected[1]), int(detected[2]))
    cv2.imshow("asdf",img_o)
    cv2.waitKey()

import numpy as np
from shapely.geometry.point import Point
from skimage.draw import circle_perimeter_aa
from tqdm import tqdm
import matplotlib.pyplot as plt
import cv2
import predictor


def draw_circle(img, row, col, rad):
    rr, cc, val = circle_perimeter_aa(row, col, rad)
    valid = (
        (rr >= 0) &
        (rr < img.shape[0]) &
        (cc >= 0) &
        (cc < img.shape[1])
    )
    img[rr[valid], cc[valid]] = val[valid]


def noisy_circle(size, radius, noise):
    img = np.zeros((size, size), dtype=np.float)

    # Circle
    row = np.random.randint(size)
    col = np.random.randint(size)
    rad = np.random.randint(10, max(10, radius))
    draw_circle(img, row, col, rad)

    # Noise
    img_noisy = img + noise * np.random.rand(*img.shape)

    return (row, col, rad), img_noisy, img


def find_circle(img):
    # Fill in this function
    detect = predictor.circle_find(img)
    return detect


def iou(params0, params1):
    row0, col0, rad0 = params0
    row1, col1, rad1 = params1

    shape0 = Point(row0, col0).buffer(rad0)
    shape1 = Point(row1, col1).buffer(rad1)

    return (
        shape0.intersection(shape1).area /
        shape0.union(shape1).area
    )


def main():
    for attempt in range(1):
        results = []
        for _ in tqdm(range(1000)):
            params,img_noisy, img = noisy_circle(200, 50, 2)
            detected = find_circle(img)
            results.append(iou(params, detected))
        results = np.array(results)
        # print((results > 0.7))
        print('Accuracy:', (results > 0.5).mean(), 'attempt ', attempt+1)
        
        # Plot the last generated image -- Although out scope but defined in memory
        fig, (ax,ax1,ax2) = plt.subplots(1,3, figsize=(10,5))
        y, x, r = params
        img_rec = cv2.rectangle(img_noisy.copy(), (x - r - 1, y - r - 1), (x + r + 1, y + r + 1), (0, 0, 0), 2)
        ax.imshow(img)
        ax.set_title("Original image")
        ax1.imshow(img_noisy.copy())
        ax1.set_title("Image with added noise")
        ax2.imshow(img_rec)
        ax2.set_title("Detected noisy circle")
        plt.show()
        # stacked_img = np.hstack([img, img_noisy, np.zeros([200, 1], dtype=np.uint8), img_rec])
        # plt.imshow(stacked_img)
        # plt.show()

if __name__ == '__main__':
    main()

GitHub - jacke121/Circle_detector: Detect complete and incomplete circular shapes in noisy images

霍夫圆检测

霍夫圆检测_jacke121的专栏-CSDN博客_霍夫圆检测

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

AI算法网奇

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值