Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

In CV2 everything is returned as NumPy objects: What is different between all these OpenCV Python interfaces?

Using frame directly an it works:

import cv2
cap = cv2.VideoCapture('rain.avi')
cv2.namedWindow('frame',cv2.WINDOW_NORMAL)
cv2.resizeWindow('frame', 800,800)

while(cap.isOpened()):
    ret, frame = cap.read()
    #np_frame = cv2.imread('video', frame) # does not work
    #np_frame = np.asarray(cv2.GetMat(frame)) # does not work
    #print(np_frame.shape)
    print(frame.shape)

    cv2.imshow('frame',frame)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()

In CV2 everything is returned as NumPy objects: What is different between all these OpenCV Python interfaces?

Using frame directly an directly, then it works:

import cv2
cap = cv2.VideoCapture('rain.avi')
cv2.namedWindow('frame',cv2.WINDOW_NORMAL)
cv2.resizeWindow('frame', 800,800)

while(cap.isOpened()):
    ret, frame = cap.read()
    #np_frame = cv2.imread('video', frame) # does not work
    #np_frame = np.asarray(cv2.GetMat(frame)) # does not work
    #print(np_frame.shape)
    print(frame.shape)

    cv2.imshow('frame',frame)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()