import cv2
import numpy as np
def get_image_info(image):
print("图像类型:", type(image))
print("图像长x宽x通道数:", image.shape)
print("图像长宽通道数相乘所得值:", image.size)
print("图像像素值类型:", image.dtype)
pixel_data = np.array(image) # 将图片转换成数组
print("像素大小:", pixel_data)
print("像素大小:", pixel_data.tolist())
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(1)
if c == 27:
break
if __name__ == '__main__':
# src = cv2.imread('../images/lena.jpg')
# cv2.namedWindow('input images', cv2.WINDOW_AUTOSIZE)
# cv2.imshow('input images', src)
# cv2.waitKey(0)
# cv2.destroyAllWindows()
# 获取图图片信息
# get_image_info(src)
# 调用摄像头c
video_demo()
python opencv 调用摄像头
最新推荐文章于 2023-02-28 09:39:02 发布