File tree 1 file changed +39
-0
lines changed
1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change
1
+ """
2
+ Uploading a video in CoLab and getting it ready for CV
3
+
4
+ Objective : upload a video and prepare for detection
5
+
6
+ Resources Google Colab Video Upload
7
+ https://colab.research.google.com/drive/1VFIMF7mKJPFR0lMRlXt5VisMRTIgxjwd?usp=sharing
8
+
9
+ Download dataset from :
10
+ free videos from: https://www.pexels.com/search/videos/detection/ OR
11
+ use your own. For this demo, I used my own using the upload function.
12
+
13
+ 1. Download a video
14
+ 2. Upload that video after running upload function
15
+ 3. prepare video with CV
16
+
17
+ Those new to CV are challenged with the first step, how to upload the video and process for object detection. This code will help you do just that.
18
+
19
+ """
20
+
21
+ import cv2
22
+ from google .colab import files
23
+ from google .colab .patches import cv2_imshow
24
+
25
+ # Uploading the video
26
+ uploaded = files .upload ()
27
+ your_video = list (uploaded .keys ())[0 ]
28
+
29
+ # Save the uploaded file to Colab's runtime temporary file system
30
+ with open (your_video , 'wb' ) as f :
31
+ f .write (uploaded [your_video ])
32
+
33
+ # Preparing video for CV2 library
34
+ video = cv2 .VideoCapture (your_video )
35
+
36
+ if not video .isOpened ():
37
+ print ("Error opening video file" )
38
+ else :
39
+ print ("Video successfully loaded and ready" )
You can’t perform that action at this time.
0 commit comments