def visualize_span_points(name, small, span_points, corners):
display = small.copy()
for i, points in enumerate(span_points):
points = norm2pix(small.shape, points, False)
mean, small_evec = cv2.PCACompute(points.reshape((-1, 2)),
None,
maxComponents=1)
dps = np.dot(points.reshape((-1, 2)), small_evec.reshape((2, 1)))
dpm = np.dot(mean.flatten(), small_evec.flatten())
point0 = mean + small_evec * (dps.min()-dpm)
point1 = mean + small_evec * (dps.max()-dpm)
for point in points:
cv2.circle(display, fltp(point), 3,
CCOLORS[i % len(CCOLORS)], -1, cv2.LINE_AA)
cv2.line(display, fltp(point0), fltp(point1),
(255, 255, 255), 1, cv2.LINE_AA)
cv2.polylines(display, [norm2pix(small.shape, corners, True)],
True, (255, 255, 255))
debug_show(name, 3, 'span points', display)
评论列表
文章目录