如果有没理解的地方,点个关注,私信我就行哈~~,看到了会及时回复
废话不多说,代码如下
import cv2 as cv import numpy as np from numpy.lib.type_check import imag def video_demo(): # VideoCapture()中参数是0,表示打开笔记本的内置摄像头,参数是视频文件路径则打开视频,如capture = cv.VideoCapture(“../testVideo.avi”) capture = cv.VideoCapture(0) while True: ret, frame = capture.read() # 这里做了个镜面水平反转,如果想要上下颠倒,就填 -1 frame = cv.flip(frame, 1) cv.imshow("video", frame) c = cv.waitKey(50) # c得到的是键盘输入的ASCII码,esc键对应的ASCII码是27 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 = cv.imread('C:\\Users\\a1625\\Desktop\\1620697720.jpg') # cv.namedWindow("myImage", cv.WINDOW_AUTOSIZE) # cv.imshow("myImage", src) video_demo() # cv.waitKey(0) # cv.destroyAllWindows()