@@ -31,7 +31,7 @@ def __init__(self,
31
31
detect_method : str = 'threshold' ,
32
32
frame_size : str = None ,
33
33
frame_rate : int = 10 ,
34
- frame_num : int = - 1 ,
34
+ vframes : int = - 1 ,
35
35
sframes : int = - 1 ,
36
36
drop_raw_data : bool = False ,
37
37
* args ,
@@ -42,7 +42,7 @@ def __init__(self,
42
42
self .distance_metric = distance_metric
43
43
self .detect_method = detect_method
44
44
self .frame_rate = frame_rate
45
- self .frame_num = frame_num
45
+ self .vframes = vframes
46
46
self .sframes = sframes
47
47
self .drop_raw_data = drop_raw_data
48
48
self ._detector_kwargs = kwargs
@@ -83,11 +83,11 @@ def apply(self, doc: 'gnes_pb2.Document') -> None:
83
83
input_data = doc .raw_bytes ,
84
84
scale = self .frame_size ,
85
85
fps = self .frame_rate ,
86
- vframes = self .frame_num )
86
+ vframes = self .vframes )
87
87
elif raw_type == gnes_pb2 .NdArray :
88
88
video_frames = blob2array (doc .raw_video )
89
- if self .frame_num > 0 :
90
- video_frames = video_frames [0 :self .frame_num , :]
89
+ if self .vframes > 0 :
90
+ video_frames = video_frames [0 :self .vframes , :]
91
91
92
92
num_frames = len (video_frames )
93
93
if num_frames > 0 :
@@ -99,9 +99,12 @@ def apply(self, doc: 'gnes_pb2.Document') -> None:
99
99
shot_len = len (frames )
100
100
c .weight = shot_len / num_frames
101
101
if self .sframes > 0 and shot_len > self .sframes :
102
- start_id = int ((shot_len - self .sframes ) / 2 )
103
- end_id = start_id + self .sframes
104
- frames = frames [start_id :end_id ]
102
+ begin = 0
103
+ if self .sframes < 3 :
104
+ begin = (shot_len - self .sframes ) // 2
105
+ step = (shot_len ) // self .sframes
106
+ frames = [frames [_ ] for _ in range (begin , shot_len , step )]
107
+
105
108
chunk_data = np .array (frames )
106
109
c .blob .CopyFrom (array2blob (chunk_data ))
107
110
else :
0 commit comments