-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
28 lines (22 loc) · 979 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import cv2 as cv
import numpy as np
from datamoshing_with_optical_flow import *
# video = cv.VideoCapture("A Self driving truck on a Chinese highway [g8pyetqmqece1].mp4")
video = cv.VideoCapture("DSCF6216.mp4")
# video = cv.VideoCapture("Explosion croma key green screen [RMvMYYRDpKM].webm")
frame_rate = video.get(cv.CAP_PROP_FPS)
width = video.get(cv.CAP_PROP_FRAME_WIDTH)
height = video.get(cv.CAP_PROP_FRAME_HEIGHT)
# image = cv.imread("test_image.png")
image = cv.imread("test_image_2.png")
iheight, iwidth, _ = np.shape(image)
# image = cv.imread("test_image_3.png")
# https://docs.opencv.org/4.x/dd/d43/tutorial_py_video_display.html
fourcc = cv.VideoWriter_fourcc(*'XVID') # type: ignore
writer = cv.VideoWriter('output.avi', fourcc, frame_rate, (int(width), int(height)))
datamosh(video, image, writer)
# writer = cv.VideoWriter('output.avi', fourcc, 24, (iwidth, iheight))
# well(24, image, writer, fps=24)
# TODO: Use contextlib
video.release()
writer.release()