Cleanup code and add simple README

This commit is contained in:
Marco Thomas
2022-04-18 13:19:17 +02:00
parent d5de0d3db6
commit 89dbe4adca
6 changed files with 88 additions and 32 deletions

View File

@@ -1,15 +1,28 @@
"""
Convert a video to a txt in a format, which i need
Convert a video to a textfile in a format, which i need:
ASCII_TXT:
---
IMAGE
IMAGE
IMAGE
...
---
Using: https://github.com/ivanl-exe/image-to-ascii/
"""
import cv2
import os
import shutil
import argparse
OUTPUT = 'assets/output'
ASCII_TXT = 'assets/ascii.txt'
TOOL_PATH = '../image-to-ascii/target/release/image_to_ascii'
def parse_args():
"""
@@ -22,6 +35,7 @@ def parse_args():
return parser.parse_args()
def main():
"""
Convert frames to jpgs, convert each to ascii, and append it to the ascii.txt
@@ -59,11 +73,21 @@ def main():
for f in os.listdir(OUTPUT):
filename = os.path.abspath(OUTPUT + '/' + f)
print(f'Processing: {filename}')
os.system(f'../image-to-ascii/target/release/image_to_ascii {args.width} {args.height} true {filename} >> {ASCII_TXT}')
os.system(f'{TOOL_PATH} {args.width} {args.height} true {filename} >> {ASCII_TXT}')
# cleanup
video.release()
cv2.destroyAllWindows()
def check_deps():
"""
Checks if the deps, used in this script, are present
"""
if not os.path.isfile(TOOL_PATH):
print("Missing image-to-ascii at expected location!")
exit(1)
if __name__ == '__main__':
check_deps()
main()