Skip to content

Create upload_video_cv.py #12007

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions computer_vision/upload_video_cv
Original file line number Diff line number Diff line change
@@ -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")