fix(utils): missing edge when resample segments (#8092)

Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
pull/8162/head
HRan2004 2022-06-09 16:52:05 +08:00 committed by GitHub
parent 2dd3db0050
commit cf298fb72f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 0 deletions

View File

@ -738,6 +738,7 @@ def segments2boxes(segments):
def resample_segments(segments, n=1000):
# Up-sample an (n,2) segment
for i, s in enumerate(segments):
s = np.concatenate((s, s[0:1, :]), axis=0)
x = np.linspace(0, len(s) - 1, n)
xp = np.arange(len(s))
segments[i] = np.concatenate([np.interp(x, xp, s[:, i]) for i in range(2)]).reshape(2, -1).T # segment xy