diff --git a/computer_vision/upload_video_cv b/computer_vision/upload_video_cv new file mode 100644 index 000000000000..b1c8df42884e --- /dev/null +++ b/computer_vision/upload_video_cv @@ -0,0 +1,21 @@ +#this script helps load video into colab environment. You should be asked to upload video. +#recommend to seperate code into cells for testing purposes. +import cv2 +from google.colab import files +from google.colab.patches import cv2_imshow + +# Uploading the video +uploaded = files.upload() +your_video = list(uploaded.keys())[0] + +# Save the uploaded file to Colab's runtime temporary file system +with open(your_video, 'wb') as f: + f.write(uploaded[your_video]) + +# Preparing video for CV2 library +video = cv2.VideoCapture(your_video) + +if not video.isOpened(): + print("Error opening video file") +else: + print("Video successfully loaded and ready")