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

Viewed 11498

I am wondering what kind of data type is being captured using the cv2.VideoCapture.read() method. I have been reading the OpenCV documents and I found this explanation:

enter image description here

I have followed a couple of basic tutorials with OpenCV where a webcam can capture data and outputs the frames. In the picture below the frame data is being shown.

enter image description here

And here follows the code that outputs these frames:

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

So I am wondering what kind of data type is being printed from the 'frame' variable?

In the end I want to use this 'frame' data to re-construct the images to a video in a C# application.

1 Answers

You can check type of frame yourself by adding print(type(frame)).
When I execute script with print(type(frame)), numpy.ndarray is printed.

Related