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
1 changed files with 2 additions and 1 deletions
|
|
@ -625,8 +625,9 @@ def resample_segments(segments, n=1000):
|
||||||
"""
|
"""
|
||||||
for i, s in enumerate(segments):
|
for i, s in enumerate(segments):
|
||||||
s = np.concatenate((s, s[0:1, :]), axis=0)
|
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))
|
xp = np.arange(len(s))
|
||||||
|
x = np.insert(x, np.searchsorted(x, xp), xp) if len(s) < n else x
|
||||||
segments[i] = (
|
segments[i] = (
|
||||||
np.concatenate([np.interp(x, xp, s[:, i]) for i in range(2)], dtype=np.float32).reshape(2, -1).T
|
np.concatenate([np.interp(x, xp, s[:, i]) for i in range(2)], dtype=np.float32).reshape(2, -1).T
|
||||||
) # segment xy
|
) # segment xy
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue