用cv2捕获什么数据类型。视频捕获.read()OpenCV中的方法?

2024-10-01 13:26:22 发布

您现在位置:Python中文网/ 问答频道 /正文

我想知道什么样的数据类型是捕捉使用cv2。视频捕获.read()方法。我一直在阅读OpenCV文档,我发现了以下解释:

enter image description here

我学习了OpenCV的几个基本教程,其中网络摄像头可以捕捉数据并输出帧。在下面的图片中显示了帧数据。在

enter image description here

下面是输出这些帧的代码:

import cv2, time, base64

framesCaptured = 0;
video=cv2.VideoCapture(0) <====== Video capture for the webcam

# Save camera frames as movie
fourcc = cv2.VideoWriter_fourcc(*'XVID')
out = cv2.VideoWriter('recording.avi', fourcc, 20.0, (640, 480))

while True:
    framesCaptured += 1

    check, frame = video.read() <====== Grabs and retrieves frames and decode
    # Write video frames
    out.write(frame)

    # Print out statements
    #print(check)
    print(frame) <====== Print out frame data (as shown in the cmd picture below)

    gray=cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

    cv2.imshow("frame", gray)   

    key=cv2.waitKey(1)

    if key == ord('q'):
        break

#print('Frames captured: ' + str(framesCaptured))
video.release()
out.release()
cv2.destroyAllWindows

所以我想知道从'frame'变量打印的是什么类型的数据?在

最后,我想用这个“帧”数据在C应用程序中将图像重新构造成视频。在


Tags: the数据readframes视频asvideoout