# -*- coding: utf-8 -*-
"""
Created on Tue Sep 11 16:35:29 2018
@author: 车路历程
"""
import cv2
from skimage import io
camera = cv2.VideoCapture("E:/video/7.mp4") # 参数0表示第一个摄像头
# 判断视频是否打开
if (camera.isOpened()):
print('Open')
else:
print('摄像头未打开')
# 测试用,查看视频size
size = (int(camera.get(cv2.CAP_PROP_FRAME_WIDTH)),
int(camera.get(cv2.CAP_PROP_FRAME_HEIGHT)))
print('size:'+repr(size))
# 视频帧图片的起始编号
a = 0
while True:
# 读取视频流
grabbed, frame_lwpCV = camera.read()
# 当从视频中读取不到视频帧就退出
if frame_lwpCV is None:
break
# 将彩色图片转化为灰度图
gray_lwpCV = cv2.cvtColor(frame_lwpCV, cv2.COLOR_BGR2GRAY)
# 进行滤波处理
gray_lwpCV = cv2.GaussianBlur(gray_lwpCV, (21, 21), 0)
# 保存图片
io.imsave("E:/all_picture/final_picture/%s.jpg"%a, frame_lwpCV)
a += 1
# 显示图片
cv2.imshow('contours', frame_lwpCV)
key = cv2.waitKey(1) & 0xFF
# 按'q'健退出循环
if key == ord('q'):
break
# When everything done, release the capture
camera.release()
cv2.destroyAllWindows()