我将如何检测这两条线的角度?

How would I detect the angle of these two lines?

正如您在图片中看到的,当一个人使用地图时会生成一个圆锥体。我想知道是否有可能检测到锥体的两条外线 like this 但最终目标是使用此信息找到线所在的角度。

我在关注 this tutorial on hough-transform but end up with this。如果可能,寻找一种更简单的方法来找到角度。

import numpy as np

from skimage.transform import hough_line
from scipy import misc

import matplotlib.pyplot as plt
from matplotlib import cm

image = misc.imread("cone.jpg", flatten=True)

# Classic straight-line Hough transform
h, theta, d = hough_line(image)

# Generating figure 1
fig, axes = plt.subplots(1, 3, figsize=(9, 3),
                         subplot_kw={'adjustable': 'box-forced'})
ax = axes.ravel()

ax[0].imshow(image, cmap=cm.gray)
ax[0].set_title('Input image')
ax[0].set_axis_off()

ax[1].imshow(np.log(1 + h),
             extent=[np.rad2deg(theta[-1]), np.rad2deg(theta[0]), d[-1], d[0]],
             cmap=cm.gray, aspect=1/1.5)
ax[1].set_title('Hough transform')
ax[1].set_xlabel('Angles (degrees)')
ax[1].set_ylabel('Distance (pixels)')
ax[1].axis('image')

ax[2].imshow(image, cmap=cm.gray)
for _, angle, dist in zip(*hough_line_peaks(h, theta, d)):
    y0 = (dist - 0 * np.cos(angle)) / np.sin(angle)
    y1 = (dist - image.shape[1] * np.cos(angle)) / np.sin(angle)
    ax[2].plot((0, image.shape[1]), (y0, y1), '-r')
ax[2].set_xlim((0, image.shape[1]))
ax[2].set_ylim((image.shape[0], 0))
ax[2].set_axis_off()
ax[2].set_title('Detected lines')

plt.tight_layout()
plt.show()

这是我的结果:


你应该先参考这个: Detect Colored Segment in an image


我的步骤是:

  1. 将其转换为 HSV,得到 S
  2. 精明 S
  3. 检测精巧的边缘,按一些标尺过滤。