diff options
| author | jules <jules@asdf.us> | 2018-05-01 20:20:27 +0200 |
|---|---|---|
| committer | jules <jules@asdf.us> | 2018-05-01 20:20:27 +0200 |
| commit | 20662ee305cd21838078eab97568bbbbb9acffd0 (patch) | |
| tree | 16b58c750be5e054c7d9e266c8e2481f359b400c /canny-single.py | |
| parent | 5979723a35c577ffe70c1107415199444fb5c7fe (diff) | |
new scripts using canny
Diffstat (limited to 'canny-single.py')
| -rw-r--r-- | canny-single.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/canny-single.py b/canny-single.py new file mode 100644 index 0000000..749067a --- /dev/null +++ b/canny-single.py @@ -0,0 +1,36 @@ +import os +from options.test_options import TestOptions +from shutil import move, copyfile +from PIL import Image, ImageOps +from shutil import copyfile, rmtree +import numpy as np +import cv2 + +import subprocess +from time import sleep + +if __name__ == '__main__': + opt = TestOptions().parse() + opt.nThreads = 1 # test code only supports nThreads = 1 + opt.batchSize = 1 # test code only supports batchSize = 1 + opt.serial_batches = True # no shuffle + opt.no_flip = True # no flip + opt.experiment = opt.start_img + + render_dir = opt.results_dir + opt.experiment + "/" + + if os.path.exists(render_dir): + rmtree(render_dir) + mkdirs(render_dir) + i = 0 + for f in sorted(os.listdir(opt.start_img)): + if not os.path.isfile(f): + continue + pil_image = Image.open(f).convert('RGB') + opencv_image = np.array(pil_image) + opencv_image = opencv_image[:, :, ::-1].copy() + opencv_image = cv2.GaussianBlur(opencv_image, (3,3), 1) + opencv_image = cv2.Canny(opencv_image, 100, 200) + cv2.imwrite(render_dir + "frame_{:04d}.png".format(i), opencv_image) + i += 1 + |
