Skip to content
This repository was archived by the owner on Feb 22, 2020. It is now read-only.

Commit b69591d

Browse files
committed
fix(shotdetect): fix shot boundary
1 parent fda7f96 commit b69591d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

gnes/preprocessor/helper.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ def kmeans_algo(distances: List[float], **kwargs) -> List[int]:
319319
shots.append(0)
320320
for i in range(0, len(clt.labels_)):
321321
if big_center == clt.labels_[i]:
322-
shots.append((i + 2))
322+
shots.append((i + 1))
323323
if shots[-1] < num_frames:
324324
shots.append(num_frames)
325325
else:
@@ -356,18 +356,18 @@ def motion_algo(distances: List[float], **kwargs) -> List[int]:
356356
arg_dict.update(kwargs)
357357

358358
shots = []
359-
num_frames = len(distances) + 1
359+
num_frames = len(distances) + 2 * 2 + 1
360360
p = peakutils.indexes(np.array(distances).astype('float32'), thres=arg_dict['threshold'], min_dist=arg_dict['min_dist']) if len(distances) else []
361361
if len(p) == 0:
362362
return [0, num_frames]
363363

364364
shots.append(0)
365-
shots.append(p[0] + 2)
365+
shots.append(p[0] + 2 + 1)
366366
for i in range(1, len(p)):
367367
# We check that the peak is not due to a motion in the image
368368
valid_dist = arg_dict['motion_step'] or not check_motion(distances[p[i]-arg_dict['motion_step']:p[i]], distances[p[i]])
369369
if valid_dist:
370-
shots.append(p[i] + 2)
370+
shots.append(p[i] + 2 + 1)
371371
if shots[-1] < num_frames - arg_dict['min_dist']:
372372
shots.append(num_frames)
373373
elif shots[-1] > num_frames:

0 commit comments

Comments
 (0)