以代码为基础的opencv-python学习 图片的加载以及视频展示

import cv2
import numpy as np

#视频读取
def video_demo():
capture = cv2.VideoCapture(0)
while(True):
ret, frame = capture.read()
#frame = cv2.flip(frame,1) #镜像变换
cv2.imshow("video",frame)
c = cv2.waitKey(50) #按ESC退出摄像头
if c == 27:
break

#图片信息展示
def get_image_info(image):
print(type(image))
print(image.shape)
print(image.size)
print(image.dtype)
pixel_data = np.array(image)
print(pixel_data)



src = cv2.imread("woman.jpg") #读取图片
cv2.namedWindow("input image",cv2.WINDOW_AUTOSIZE)
cv2.imshow('input image',src) #展示图片
#get_image_info(src)
video_demo()
cv2.waitKey(0)

cv2.destroyAllWindows()

猜你喜欢

转载自www.cnblogs.com/August2019/p/12547605.html