I am attempting to migrate some OpenCV image analysis (using Python3) from a local Jupyter notebook to Google Colab.
My original Jupyter Notebook code works fine, and the video renders fine (in its own Window) (see a subset of the code below). This code uses cv2.imshow() to render the video. When using the same "cv2.imshow()" code in Colab, the video doesn't render.
Based on this suggestion - I switched to using cv2_imshow()in Colab. However, this change leads to a vertical series of 470 images (1 for each frame), rather than the video being played.
Here is a link to the colab file.
Can anyone outline how to render the video processed by OpenCV within Colab?
import numpy as np
import cv2
cap = cv2.VideoCapture(r"C:\.....Blocks.mp4")
counter = 0
while(True):
# Capture frame-by-frame
ret, frame = cap.read()
cv2.imshow(frame)
print("Frame number: " + str(counter))
counter = counter+1
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()