美文网首页
直线检测问题

直线检测问题

作者: hi_lan | 来源:发表于2018-10-11 22:41 被阅读0次

For slam, 直线相对于点这些特征来说会更robust, 更常见。 毕竟点特征更需要环境纹理信息很丰富。

刚好最近瞎看了一些关于直线检测的问题。

#############################霍夫变换########################

第一个canny edge检测,她基于梯度可以检测出图像的大部分边缘线。 基本步骤canny

然后如何人基于边缘找直线呢?

1)  Hough Transform

2) 利用线的方向 

Straight line detector =

canny + gradient orientations +orientation binning +linking + check for straightness

#############LSD:a Line Segment Detector####################

可以参考别人的一个博客,写的很清楚LSD

##############################################################

#python opencv自带的提取line的特征

def line_detection_save(self,fidin,rgb):

    gray= cv2.cvtColor(rgb, cv2.COLOR_BGR2GRAY)

lsd= cv2.createLineSegmentDetector(2)

# Detect lines in the image

    lines= lsd.detect(gray)# Position 0 of the returned tuple are the detected lines

    for dlinein lines[0]:

          x0= int(round(dline[0][0]))

           y0= int(round(dline[0][1]))

            x1= int(round(dline[0][2]))

            y1= int(round(dline[0][3]))

            string= str(x0)+ ' ' + str(y0)+ ' ' + str(x1)+ ' ' + str(y1)+ '\n'

        fidin.write(string)

return fidin

##########################################

霍夫变换,同样是opencv python的代码

############################################

img = cv2.imread('lines.jpg')

gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)

edges = cv2.Canny(gray,50,150,apertureSize = 3)

minLineLength=100

lines = cv2.HoughLinesP(image=edges,rho=0.02,theta=np.pi/500, threshold=10,lines=np.array([]), minLineLength=minLineLength,maxLineGap=100)

a,b,c = lines.shape

for i in range(a):    

       cv2.line(img, (lines[i][0][0], lines[i][0][1]), (lines[i][0][2], lines[i][0][3]), (0, 0, 255), 3,  cv2.LINE_AA)   

      cv2.imwrite('houghlines5.jpg',img)

!!!!另外还有一些基于深度学习的方法,但是不是很robust,pixel误差比较大

#######################LSD line 检测##############

有开源代码,超级好用,推荐

相关文章

  • 直线检测问题

    For slam, 直线相对于点这些特征来说会更robust, 更常见。 毕竟点特征更需要环境纹理信息很丰富。 刚...

  • 直线检测

    直线检测大体可分为从上而下以及从下而上两种模式。1。从上而下的直线检测模式典型代表Hough变换,将直线由坐标空间...

  • 2019-06-03 OpenCV学习

    21直线检测 霍夫直线变换用来做直线检测,前提条件是边缘检测已完成。 22圆检测 霍夫圆变换原理: 从平面坐标到极...

  • 18、直线检测

    霍夫直线变化 一、cv.HoughLines (不常用) 二、cv.HoughLinesP(常用) 从中可想而知,...

  • 霍夫变换

    霍夫变换——直线   Hough Line Transform用来做直线检测,前提是已经做了边缘检测。  霍夫变换...

  • Opencv第五课--直线检测和圆检测

    直线检测 直线检测通常会用到Hough变换,原理可参考:https://www.cnblogs.com/AndyJ...

  • 霍夫变换

    一、霍夫直线检测 霍夫变换(Hough Transfrom),是1972年提出的,最开始就是用来在图像中检测直线,...

  • 第 7 章 提取直线、轮廓和区域

    本章包括以下内容: 用Canny 算子检测图像轮廓; 用霍夫变换检测直线; 点集的直线拟合; 提取连续区域; 计算...

  • 霍夫变换之直线检测

    霍夫变换 查看图像 结果: 边缘检测 结果: 霍夫变换检测直线 结果:

  • OpenCV+Python直线、圆检测

    霍夫变换 应用范围 只要能用数学方程表示的形状,都能用霍夫变换检测到 直线检测 直线数学方程:或者,其中是原点到直...

网友评论

      本文标题:直线检测问题

      本文链接:https://www.haomeiwen.com/subject/uxiiaftx.html