图像的读取与保存
import cv2 as cv
import numpy as np
def get_image_info(image):
print(type(image))
print(image.size)
print(image.shape)
print(image.dtype)
pixel_data=np.array(image)
print(pixel_data)
src1=cv.imread('timg.png')
cv.namedWindow('input image1',cv.WINDOW_AUTOSIZE)
cv.imshow('input image1',src1)
get_image_info(src1)
gray=cv.cvtColor(src1,cv.COLOR_BGR2GRAY)
cv.imwrite('D:/result.jpg',gray)
cv.waitKey(10000)
视频的读入
import cv2 as cv
def video_demo():
capture=cv.VideoCapture(0)
while(True):
ret,frame=capture.read()
cv.imshow("video",frame)
frame=cv.flip(frame, 1)
cv.imshow('video1',frame)
c=cv.waitKey(50)
if c==27:
break
video_demo()
cv.waitKey(0)
cv.destroyAllWindows()