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

pull/775/head^2
HRan2004 2022-09-12 22:37:21 +08:00 committed by GitHub
parent 1cb8aa5c9f
commit 2e99efb27f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 0 deletions

View File

@ -310,6 +310,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