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 )
上一篇:【ACWing】2172. Dinic/ISAP求最大流


下一篇:P4013 数字梯形问题(拆点+最大费最大流)