Skip to content

Commit fdae3b1

Browse files
committed
fixed major error and added averaging
1 parent 186bfb8 commit fdae3b1

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

video-localization/demo.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ def getCaptionData(idx):
9494
a.build(n_trees)
9595

9696
# start processing:
97-
j = 0 # index in caption file
9897
for i in range(frame_count-2):
9998
ret, frame = cap.read()
10099

@@ -111,12 +110,13 @@ def getCaptionData(idx):
111110

112111
# get appropriate caption based on recognized frame position in video
113112
if i < 1:
114-
t1,t2,textc = getCaptionData(j)
115-
116-
tn = neighbors[0] * 1/fps # get time in seconds of this matched frame
117-
if not(tn >= t1 and tn < t2):
118-
j += 1
119-
t1,t2,textc = getCaptionData(j) # get next caption item
113+
t1,t2,textc = getCaptionData(0)
114+
115+
ave_neighbor = np.mean(neighbors)
116+
tn = ave_neighbor * 1/fps # get time in seconds of this matched frame
117+
for j in range(len(captions)):
118+
t1,t2,tmp = getCaptionData(j) # get next caption item
119+
if (tn >= t1 and tn < t2): textc = tmp
120120

121121
# print(i, neighbors[0], j, t1, tn, t2, textc)
122122

0 commit comments

Comments
 (0)