Generation

generate functionFri, 07 Apr 2023

videobokeh function ,its input is the source video and the depth map, output is the videobokeh

import cv2 import numpy as np from matplotlib import pyplot as plt import math def videoBokeh(source_video, depth_map): cap = cv2.VideoCapture(source_video) if (cap.isOpened()== False): print("Error opening video stream or file") frame_width = int(cap.get(3)) frame_height = int(cap.get(4)) length = int(cap.get(cv2.CAP_PROP_FRAME_COUNT)) fps = cap.get(cv2.CAP_PROP_FPS) #fourcc = cv2.VideoWriter_fourcc(*'XVID') out = cv2.VideoWriter('bokeh_result.avi',cv2.VideoWriter_fourcc('M','J','P','G'), fps, (frame_width,frame_height)) print(frame_width) print(frame_height) for k in range(0,length-1

Questions about programming?Chat with your personal AI assistant