Detect dotted (broken) lines only in an image using OpenCV

Barry Scott barry at barrys-emacs.org
Thu Apr 16 12:41:12 EDT 2020



> On 16 Apr 2020, at 00:36, Edu Py <haider.khalidy2 at gmail.com> wrote:
> 
> I am trying to learn techniques on image feature detection.

Cool.

> 
> I have managed to detect horizontal line(unbroken/continuous), however I am having trouble detecting all the dotted/broken lines in an image.

We can help with the python side of things, but speaking for myself, I've little
knowledge of computer vision. Have you thought about looking for a specialist
list on computer vision or cv2?

Barry

> 
> Here is my test image, as you can see there are dotted lines and some text/boxes etc.
> 
> 
> my code is below:
> 
> import cv2
> import numpy as np
> 
> img=cv2.imread('test.jpg')
> img=functions.image_resize(img,1000,1000) #function from a script to resize image to fit my screen
> imgGray=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
> imgEdges=cv2.Canny(imgGray,100,250)
> imgLines= cv2.HoughLinesP(imgEdges,2,np.pi/100,60, minLineLength = 10, maxLineGap = 100)
> for x1,y1,x2,y2 in imgLines[0]:
>    cv2.line(img,(x1,y1),(x2,y2),(0,255,0),2)
> 
> cv2.imshow('Final Image with dotted Lines detected',img) 
> 
> My output image is below. As you can see I only managed to detect the last dotted line. I have played around with the parameters rho,theta,min/max line but no luck.
> 
> Any advice is greatly appreciated :)
> 
> For the original link - which has the images 
> https://stackoverflow.com/questions/61239652/detect-dotted-broken-lines-only-in-an-image-using-opencv
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 



More information about the Python-list mailing list