编程语言
首页 > 编程语言> > opencv-python视频处理之视频慢动作和视频漫画风格

opencv-python视频处理之视频慢动作和视频漫画风格

作者:互联网

def man_action():vc=cv2.VideoCapture("sample.mp4")fps=vc.get(cv2.CAP_PROP_FPS)fps_flow=fps//2fourcc=cv2.VideoWriter_fourcc(*"MJPG")flow_video=cv2.VideoWriter("flow_video.mp4",fourcc,fps_flow,(640,480))while vc.isOpened():su,frame=vc.read()flow_video.write(frame)cv2.waitKey(1)vc.release()import cv2def cartoon(img_rgb):img_color = img_rgb
    img_gray = cv2.cvtColor(img_rgb, cv2.COLOR_RGB2GRAY)img_blur = cv2.medianBlur(img_gray, 7)img_edge = cv2.adaptiveThreshold(img_blur, 255, cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY, blockSize=9, C=2)img_edge = cv2.cvtColor(img_edge, cv2.COLOR_GRAY2RGB)img_cartoon = cv2.bitwise_and(img_color, img_edge)return img_cartoondef main () :vc = cv2.VideoCapture('sample.mp4 ')while vc. isOpened() :rva1, frame = vc.read ()frame=cartoon(frame )cv2. imshow ("img", frame )

标签:视频,vc,img,python,flow,frame,cv2,慢动作,fps
来源: https://blog.51cto.com/u_15177056/2725328