From d70e877e352eb16d77526aaf01eab622d321bd92 Mon Sep 17 00:00:00 2001 From: felix Date: Thu, 5 Sep 2019 12:48:52 +0800 Subject: [PATCH] fix(shot-detector): fix case of only one shot in video --- gnes/preprocessor/helper.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gnes/preprocessor/helper.py b/gnes/preprocessor/helper.py index 09e93580..d723a1b9 100644 --- a/gnes/preprocessor/helper.py +++ b/gnes/preprocessor/helper.py @@ -358,6 +358,9 @@ def motion_algo(distances: List[float], **kwargs) -> List[int]: shots = [] num_frames = len(distances) + 1 p = peakutils.indexes(np.array(distances).astype('float32'), thres=arg_dict['threshold'], min_dist=arg_dict['min_dist']) + if len(p) == 0: + return [0, num_frames] + shots.append(0) shots.append(p[0] + 2) for i in range(1, len(p)):