4

私はクリケットピッチのポッピング折り目を見つけるというこの問題に取り組んでおり、opencvからLSDを使用して垂直線分を検出できるという、やりたいことをある程度達成しましたが、理解していないように見えるのは、異なる線分を結合する方法です完全な行を作るために同じ行に。

線分を見つけるためのコード:

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)

入力画像:ここに画像の説明を入力

検出された行:ここに画像の説明を入力

私がしたいこと:ここに画像の説明を入力

4

1 に答える 1