-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtoolchain.py
More file actions
63 lines (49 loc) · 2.14 KB
/
Copy pathtoolchain.py
File metadata and controls
63 lines (49 loc) · 2.14 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
57
58
59
60
61
62
63
#!/usr/bin/env python3
import argparse
import subprocess
import skvideo.io
import skimage.io
import numpy
import os
import time
numpy.float = numpy.float64
numpy.int = numpy.int_
from pathlib import Path
def main():
"""
The main entry point of the toolchain.
The toolchain takes two arguments, a specification file and a video file.
It will extract the specified number of frames from the video, save them
as rgba images in the frames directory, and then run the temporal
analysis on the frames.
Args:
filename (str): The name of the specification file
videoFile (str): The name of the video file
"""
parser = argparse.ArgumentParser(description='Process a file.')
parser.add_argument('filename', type=str, help='The name of the specification file')
parser.add_argument('videoFile', type=str, help='The video file to process')
args = parser.parse_args()
Path("/home/ubuntu/VoxLogicA2/src/frames").mkdir(parents=True, exist_ok=True)
frames = skvideo.io.vread(args.videoFile + ".mkv", outputdict={"-pix_fmt": "rgba"})
numFrames = len(frames)
for i in range(0,numFrames):
name = "/home/ubuntu/VoxLogicA2/src/frames/video_" + str(i) + ".png"
skimage.io.imsave(name, frames[i])
now = time.time()
print(now)
args = parser.parse_args()
spec = args.filename.split(".")[0]
#spec = spec2.split("/")[-1]
os.chdir("/home/ubuntu/VoxLogicA2/src")
subprocess.run("python3 temporal.py " + args.filename + " " + str(numFrames), shell=True)
subprocess.run("cp stdlib2.imgql /home/ubuntu/VoxLogicA/src", shell=True)
os.chdir("/home/ubuntu/VoxLogicA/src")
subprocess.run("rm -rf frames", shell=True)
subprocess.run("mv /home/ubuntu/VoxLogicA2/src/frames /home/ubuntu/VoxLogicA/src", shell=True)
subprocess.run("mv /home/ubuntu/VoxLogicA2/src/" + spec + "-temporal-new-VL1.imgql /home/ubuntu/VoxLogicA/src", shell=True)
subprocess.run("/home/ubuntu/VoxLogicA/releases/VoxLogicA_1.3.3-experimental_linux-x64/VoxLogicA " + spec + "-temporal-new-VL1.imgql", shell=True)
end = time.time()
print(end-now)
if __name__ == "__main__":
main()