4

I am working on this problem of finding popping crease of the cricket pitch and I have somewhat achieved what I wanted to do that is I can detect vertical line segments using LSD from opencv but what I dont seem to understand is how to join different line segments on the same line to make a complete line.

The code for finding line segments:

import cv2
import math
import numpy as np

#Read gray image
img = cv2.imread("2.jpg",0)

#Create default parametrization LSD
lsd = cv2.createLineSegmentDetector(0)

#Detect lines in the image
lines = lsd.detect(img)[0] #Position 0 of the returned tuple are the detected lines
print(lines[0][0][0])

ver_lines = []

for line in lines:
    angletan = math.degrees(math.atan2((round(line[0][3],2) - round(line[0][1],2)), (round(line[0][2],2) - round(line[0][0],2))))

    if(angletan > 85 and angletan < 95):
        ver_lines.append(line)

#Draw detected lines in the image
drawn_img = lsd.drawSegments(img,np.array(ver_lines))

#Show image
cv2.imshow("LSD",drawn_img )
cv2.waitKey(0)

Input Image:enter image description here

Detected lines:enter image description here

what I would like to have:enter image description here

1
  • First segment the image to get only the white line, using color segmentation, then use LSD on the binary output. Commented Dec 25, 2018 at 10:15

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.