Skip to content

Commit f069069

Browse files
authored
Create upload_video_cv
this will help you upload a video for object detection and prepare video with CV2
1 parent e9e7c96 commit f069069

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

computer_vision/upload_video_cv

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#this script helps load video into colab environment. You should be asked to upload video.
2+
#recommend to seperate code into cells for testing purposes.
3+
import cv2
4+
from google.colab import files
5+
from google.colab.patches import cv2_imshow
6+
7+
# Uploading the video
8+
uploaded = files.upload()
9+
your_video = list(uploaded.keys())[0]
10+
11+
# Save the uploaded file to Colab's runtime temporary file system
12+
with open(your_video, 'wb') as f:
13+
f.write(uploaded[your_video])
14+
15+
# Preparing video for CV2 library
16+
video = cv2.VideoCapture(your_video)
17+
18+
if not video.isOpened():
19+
print("Error opening video file")
20+
else:
21+
print("Video successfully loaded and ready")

0 commit comments

Comments
 (0)