diff options
| author | jules@lens <julescarbon@gmail.com> | 2018-05-09 21:24:11 +0200 |
|---|---|---|
| committer | jules@lens <julescarbon@gmail.com> | 2018-05-09 21:24:11 +0200 |
| commit | 0e03791f3f7db3f157bed785ba06d21270b98059 (patch) | |
| tree | e60038d09cbaca58ac742534b352d64383a1ffc2 /canny-single.py | |
| parent | 3ec7af8d74608a44240bac690a0300cd19c92298 (diff) | |
| parent | d6e04496f0a93f97efbf6d67d12a51aa2a298123 (diff) | |
merge
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 + |
