在 OpenCV 中使用 cv2.VideoCapture.read() 方法捕获什么数据类型?

What datatype is captured with cv2.VideoCapture.read() method in OpenCV?

我想知道使用 cv2.VideoCapture.read() 方法捕获的是哪种数据类型。我一直在阅读 OpenCV 文档,我发现了这个解释:

我已经学习了一些 OpenCV 基础教程,其中网络摄像头可以捕获数据并输出帧。下图显示的是帧数据。

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

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' 变量打印的是哪种数据类型?

最后我想使用这个 'frame' 数据在 C# 应用程序中将图像重新构建为视频。

您可以通过添加 print(type(frame)).
自行检查框架类型 当我使用 print(type(frame)) 执行脚本时,会打印 numpy.ndarray