import cv2def img_shake (img) :height, wIDth, n= img. shape h1=int (height*0.1)h2=int (height*0.9)wl = int (wIDth*0.1)w2 = int (wIDth*0.9)img2=img[h1:h2,wl:w2]dst = cv2. resize (img2, (wIDth, height) )cv2.imshow("src", img)cv2.imshow ("dst",dst)return dstdef main_shake() :vc=cv2.VIDeoCapture('sample.mp4')c=1cout= 5#抖动帧数fps = vc.get (cv2.CAP_PROP_FPS )fourcc = cv2.VIDeoWriter_fourcc(* 'MJPG')vIDeo_writer = cv2.VIDeoWriter("img_shake.mp4", fourcc, fps, (640, 480))while vc. isOpened() :rval, frame = vc. read ()# 每5帧抖动一次if(c%5==0or 0<cout<5) :dst=img_shake(frame)vIDeo_writer.write (dst)else:# 这里可以控制抖动帧数cout = 5cv2. imshow("dst", frame)vIDeo_writer.write (frame )c=c+1cv2.waitKey(1)vc. release ()总结
以上是内存溢出为你收集整理的opencv-python视频处理之视频抖动特效全部内容,希望文章能够帮你解决opencv-python视频处理之视频抖动特效所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)