-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDifFrame.py
32 lines (23 loc) · 966 Bytes
/
DifFrame.py
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
import itertools
import time
from multiprocessing import Pool, cpu_count
import numpy as np
from FrameProcessor import FrameProcessor
def main():
print('DifFrame Main')
frame_processor = FrameProcessor('SampleFrames-Mob_Psycho_100', 0.92)
frame_range_raw = [y for y in range(17)]
frame_range_chunks = np.array_split(frame_range_raw, cpu_count())
frame_processor.set_dicing_rate(2)
with Pool() as pool:
pool_output = pool.starmap(frame_processor.identify_differences, [(x, True) for x in frame_range_chunks])
for item in list(itertools.chain(*pool_output)):
frame_processor.frameCollector.dictionary_append(item.FrameIndex, item.FrameX, item.FrameY)
frame_processor.generate_batch_frames()
if __name__ == "__main__":
time0 = time.time()
loop_count = 10
for i in range(loop_count):
main()
time1 = time.time()
print(f"Time taken to execute {loop_count} time(s): {time1 - time0} (s)")