Max*_*nge 5 python opencv types cv2
我想知道使用 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
Run Code Online (Sandbox Code Playgroud)
所以我想知道从 'frame' 变量打印出什么样的数据类型?
最后,我想使用这个“帧”数据在 C# 应用程序中将图像重新构建为视频。