python 去除水印
pip install opencv-python 可以安装 cv2 组件import mathimport cv2capture=cv2.VideoCapture('星辰大海.mp4')height=capture.get(cv2.CAP_PROP_FRAME_HEIGHT)width=capture.get(cv2.CAP_PROP_FRAME_WIDTH)count=capture.get(
·
pip install opencv-python 可以安装 cv2 组件
import math
import cv2
capture=cv2.VideoCapture('星辰大海.mp4')
height=capture.get(cv2.CAP_PROP_FRAME_HEIGHT)
width=capture.get(cv2.CAP_PROP_FRAME_WIDTH)
count=capture.get(cv2.CAP_PROP_FRAME_COUNT)
fps=capture.get(cv2.CAP_PROP_FPS)
fourcc=cv2.VideoWriter_fourcc('m','p','4','v')
outVideo=cv2.VideoWriter()
outVideo.open('out.mp4',fourcc,fps,(int(width),int(height)),True)
def process_video(image):
# 需要注意的是第一个范围是y轴坐标的范围,第二个是x轴坐标的范围
img=image[80:130, 1070:1270]
img=cv2.GaussianBlur(img,(5,5),1.5)
image[30:80, 1040:1240] = img
return image
for i in range(int(count)):
ret,frame=capture.read()
if ret is True:
result=process_video(frame)
outVideo.write(result)
else:
break
print('进度:',str(math.ceil(i/count*100))+'%')
outVideo.release()
更多推荐
所有评论(0)