从足球场线看同位素

问题描述 投票:0回答:1

我正在使用一场足球比赛的视频,并尝试使用同构技术将帧映射到球场的俯视图。我已经开始使用Hough线和线段检测器从帧中找到所有的白线,其中线段检测器似乎效果更好一些。请看下面我的代码和例子。

import cv2
import numpy as np

cv2.imread("frame-27.jpg")
hsv = cv2.cvtColor(frame, cv2.COLOR_RGB2HSV)
mask_green = cv2.inRange(hsv, (36, 25, 25), (86, 255, 255)) # green mask to select only the field
frame_masked = cv2.bitwise_and(frame, frame, mask=mask_green)

gray = cv2.cvtColor(frame_masked, cv2.COLOR_RGB2GRAY)
_, thresh = cv2.threshold(gray, 127, 255, cv2.THRESH_BINARY)

canny = cv2.Canny(gray, 50, 150, apertureSize=3)
# Hough line detection
lines = cv2.HoughLinesP(canny, 1, np.pi / 180, 50, None, 50, 20)
# Line segment detection
lines_lsd = lsd.detect(canny)[0]

这段代码使用了这个输入帧

enter image description here

并返回这个Hough线的图像

enter image description here

和这张图片进行线段检测。

enter image description here

我的问题有两个。(1)任何关于如何进一步完善线段检测的想法(即减少假阳性,如球员周围的线段和场外的线段)和(2)使用检测线段来创建同构的好方法,这样我就可以将画面映射到更高的场面概览上(这样). 任何帮助是非常感激的

python opencv opencv3.0
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.