Commit 0647f29d authored by Mia Fornes's avatar Mia Fornes
Browse files

label session #1

parent 024929e5
%% Cell type:code id: tags:
``` python
import cv2 # for capturing videos
import math # for mathematical operations
import os
```
%% Cell type:code id: tags:
``` python
count = 0
for root, directories, files in os.walk("video-data"):
for file in files:
videoFile = "video-data/" + file
print(videoFile)
cap = cv2.VideoCapture(videoFile) # capturing the video from the given path
frameRate = cap.get(cv2.CAP_PROP_FPS) / 100 # returns frame rate divided by hundred
while cap.isOpened():
frameId = cap.get(1) #current frame number
ret, frame = cap.read()
if (ret != True):
break
if (frameId % math.floor(frameRate) == 0):
filename ="video-frames/frame%d.jpg" % count;count+=1
cv2.imwrite(filename, frame)
cap.release()
print ("Done!")
```
%% Output
video-data/front_regular_1.avi
video-data/front_regular_2.avi
video-data/front_regular_3.avi
video-data/front_regular_4.avi
video-data/ranheim_snow_1.avi
video-data/ranheim_snow_2.avi
video-data/ranheim_snow_3.avi
video-data/ranheim_snow_4.avi
video-data/ranheim_snow_5.avi
video-data/ranheim_snow_rear_1.avi
video-data/ranheim_snow_rear_2.avi
video-data/ranheim_snow_rear_3.avi
video-data/rear_regular_1.avi
video-data/rear_regular_2.avi
video-data/rear_regular_3.avi
video-data/rear_regular_4.avi
Done!
%% Cell type:code id: tags:
``` python
print(frameId)
print(frameRate)
print(math.floor(frameRate))
print(frameId % math.floor(frameRate))
```
%% Output
810.0
6.0
6
0.0
%% Cell type:code id: tags:
``` python
count = 1767
for root, directories, files in os.walk("new-video-data"):
for file in files:
videoFile = "new-video-data/" + file
print(videoFile)
cap = cv2.VideoCapture(videoFile) # capturing the video from the given path
frameRate = cap.get(cv2.CAP_PROP_FPS) / 10 # returns frame rate divided by hundred
while cap.isOpened():
frameId = cap.get(1) #current frame number
ret, frame = cap.read()
if (ret != True):
break
if (frameId % math.floor(frameRate) == 0):
filename ="new-video-frames/frame%d.jpg" % count;count+=1
cv2.imwrite(filename, frame)
cap.release()
print ("Done!")
```
%% Output
new-video-data/front_light-intersection_3_Trim.avi
new-video-data/front_light_intersection_1_Trim.avi
new-video-data/front_light_intersection_2_Trim.avi
new-video-data/front_light_intersection_4_1_Trim.avi
new-video-data/front_light_intersection_4_2_Trim.avi
new-video-data/front_light_intersection_4_Trim.avi
new-video-data/front_regular_5.avi
new-video-data/rear_regular_5_301_Trim.avi
Done!
%% Cell type:code id: tags:
``` python
```
......
0 0.331019 0.541667 0.202160 0.200000
0 0.250772 0.357292 0.140432 0.152083
0 0.168210 0.517708 0.058642 0.102083
0 0.253086 0.361458 0.138889 0.147917
0 0.340278 0.543750 0.214506 0.200000
0 0.168210 0.518750 0.064815 0.100000
0 0.251543 0.355208 0.138889 0.156250
0 0.357253 0.546875 0.220679 0.193750
0 0.172068 0.519792 0.063272 0.097917
0 0.368827 0.554167 0.243827 0.220833
0 0.252315 0.361458 0.143519 0.156250
0 0.172068 0.521875 0.072531 0.102083
0 0.385802 0.562500 0.259259 0.233333
0 0.255401 0.361458 0.137346 0.152083
0 0.174383 0.519792 0.070988 0.106250
0 0.253858 0.358333 0.137346 0.158333
0 0.405093 0.560417 0.270062 0.225000
0 0.175926 0.521875 0.083333 0.106250
0 0.424383 0.573958 0.283951 0.243750
0 0.253858 0.360417 0.143519 0.145833
0 0.180556 0.525000 0.086420 0.108333
0 0.445988 0.577083 0.311728 0.250000
0 0.258488 0.360417 0.149691 0.150000
0 0.182099 0.522917 0.086420 0.108333
0 0.467593 0.583333 0.317901 0.270833
0 0.259259 0.359375 0.141975 0.152083
0 0.185185 0.525000 0.089506 0.112500
0 0.489969 0.600000 0.344136 0.279167
0 0.261574 0.355208 0.143519 0.147917
0 0.193673 0.527083 0.081790 0.112500
0 0.517747 0.606250 0.353395 0.291667
0 0.263889 0.355208 0.148148 0.160417
0 0.194444 0.528125 0.095679 0.127083
0 0.267747 0.355208 0.152778 0.168750
0 0.543210 0.619792 0.382716 0.314583
0 0.196759 0.528125 0.094136 0.118750
0 0.201389 0.533333 0.106481 0.120833
0 0.570216 0.643750 0.399691 0.337500
0 0.270833 0.352083 0.155864 0.162500
0 0.276235 0.351042 0.154321 0.160417
0 0.603395 0.656250 0.407407 0.350000
0 0.203704 0.531250 0.108025 0.133333
0 0.212963 0.536458 0.111111 0.139583
0 0.282407 0.347917 0.166667 0.170833
0 0.633488 0.680208 0.424383 0.377083
0 0.658179 0.686458 0.442901 0.360417
0 0.288580 0.343750 0.169753 0.175000
0 0.216821 0.531250 0.115741 0.137500
0 0.295525 0.339583 0.171296 0.179167
0 0.224537 0.532292 0.118827 0.139583
0 0.687500 0.704167 0.442901 0.400000
0 0.306327 0.340625 0.186728 0.172917
0 0.227623 0.538542 0.128086 0.147917
0 0.725309 0.728125 0.456790 0.427083
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment