-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathVideoClipExtract.py
More file actions
56 lines (44 loc) · 1.63 KB
/
VideoClipExtract.py
File metadata and controls
56 lines (44 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import subprocess
import os
from glob import glob
import csv
# Function to make shots
def make_shots(var):
os.mkdir("VideoClips")
subprocess.run(["scenedetect", "-i", var, "-o", "/home/aman/Desktop/Mini-Project/VideoClips", "detect-content",
"-t", "27", "split-video"])
if __name__ == '__main__':
try:
os.remove("feature_vector.csv")
os.remove("label_vector.csv")
except OSError:
pass
labelvector = []
# Running algorithm for Accident Videos
for var in glob("/home/aman/Desktop/Mini-Project/RoadAccidents/RoadAccident*.mp4"):
print(var)
make_shots(var)
os.system("python FrameExtract.py")
os.system("python KeyFrameExtract.py")
os.system("python GaborFeatureExtraction.py")
labelvector.append(1)
# Running algorithm for Non-Accident Videos
for var in glob("/home/aman/Desktop/Mini-Project/NonAccidents/videoplayback*.mp4"):
print(var)
make_shots(var)
os.system("python FrameExtract.py")
os.system("python KeyFrameExtract.py")
os.system("python GaborFeatureExtraction.py")
labelvector.append(0)
# Making label_vector.csv
with open("label_vector.csv", 'a') as outfile:
writer = csv.writer(outfile, delimiter=' ')
writer.writerow(labelvector)
# Reading feature_vector.csv file for checking purpose
# readlist = []
# with open("feature_vector.csv", 'r') as my_file:
# reader = csv.reader(my_file, delimiter=' ')
# readlist = list(reader)
#
# new_list = [list(map(float, lst)) for lst in readlist]
# print(new_list)