Preserve original points in resample_segments (#18051)
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
parent
9be4b2ca04
commit
1f5646634d
@ -625,8 +625,9 @@ def resample_segments(segments, n=1000):
|
||||
"""
|
||||
for i, s in enumerate(segments):
|
||||
s = np.concatenate((s, s[0:1, :]), axis=0)
|
||||
x = np.linspace(0, len(s) - 1, n)
|
||||
x = np.linspace(0, len(s) - 1, n - len(s) if len(s) < n else n)
|
||||
xp = np.arange(len(s))
|
||||
x = np.insert(x, np.searchsorted(x, xp), xp) if len(s) < n else x
|
||||
segments[i] = (
|
||||
np.concatenate([np.interp(x, xp, s[:, i]) for i in range(2)], dtype=np.float32).reshape(2, -1).T
|
||||
) # segment xy
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user