From 4ef671bb84f545fe94327df771a98d7abd1f260e Mon Sep 17 00:00:00 2001 From: Farhan Syakir Date: Fri, 16 Oct 2020 22:57:08 +0300 Subject: [PATCH] pixelated for video --- pixel_video.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 pixel_video.py diff --git a/pixel_video.py b/pixel_video.py new file mode 100644 index 0000000..49169d6 --- /dev/null +++ b/pixel_video.py @@ -0,0 +1,28 @@ +import cv2 + + +def pixelate(im): + height, width = frame.shape[:2] + + w, h = (30, 30) + + temp = cv2.resize(im, (w, h), interpolation=cv2.INTER_LINEAR) + output = cv2.resize(temp, (width, height), interpolation=cv2.INTER_NEAREST) + return output + + +cap = cv2.VideoCapture('motion.avi') +out = cv2.VideoWriter('output.avi', -1, 20.0, (640,480)) + + +while(cap.isOpened()): + ret, frame = cap.read() + output = pixelate(frame) + out.write(output) + cv2.imshow('frame',output) + if cv2.waitKey(1) & 0xFF == ord('q'): + break + +cap.release() +out.release() +cv2.destroyAllWindows()