我想知道什么样的数据类型是捕捉使用cv2。视频捕获.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'变量打印的是什么类型的数据?在
最后,我想用这个“帧”数据在C应用程序中将图像重新构造成视频。在
您可以通过添加
print(type(frame))
来检查帧的类型。当我用
print(type(frame))
执行脚本时,numpy.ndarray
被打印出来。在相关问题 更多 >
编程相关推荐