Created
September 15, 2017 03:44
-
-
Save MasazI/2669a8edd8fe0d8616459c54ed8f5ff1 to your computer and use it in GitHub Desktop.
sample extract result
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import json | |
dir = "./movie" | |
def main(): | |
files = os.listdir(dir) | |
with open('dap.txt', 'w') as of: | |
for i, file in enumerate(files): | |
mpath = os.path.join(dir, file) | |
if not os.path.isdir(mpath): | |
continue | |
print("NO.%d %s" % (i, mpath)) | |
images = os.listdir(mpath) | |
frame_list = [] | |
nearmiss_frame_list = [] | |
for image in images: | |
ipath = os.path.join(mpath, image) | |
ipathname, ext = os.path.splitext(ipath) | |
if ext == '.png': | |
frame_list.append(ipath) | |
if ext == '.json': | |
with open(ipath) as f: | |
data = json.load(f) | |
near_miss_frames = data['near_miss_frames'] | |
for near_miss_frame in near_miss_frames: | |
nearmiss_frame_path = os.path.join(mpath, "%s_nearmiss.png" % (near_miss_frame['frame_id'])) | |
nearmiss_frame_list.append(nearmiss_frame_path) | |
for frame in frame_list: | |
if frame in nearmiss_frame_list: | |
print("Nearmiss: %s" % frame) | |
line = "%s\t1" % frame | |
else: | |
line = "%s\t0" % frame | |
of.write(line) | |
of.write("\n") | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment