ClarusC64 commited on
Commit
dd2c21c
·
verified ·
1 Parent(s): 3c82d5b

Create How to load in Python

Browse files
Files changed (1) hide show
  1. How to load in Python +31 -0
How to load in Python ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## Load in Python
2
+
3
+ import pandas as pd
4
+ from pathlib import Path
5
+ import cv2
6
+
7
+ # annotations
8
+ csv_path = "annotations.csv"
9
+ df = pd.read_csv(csv_path)
10
+
11
+ # view first rows
12
+ print(df.head())
13
+
14
+ # access a clip
15
+ row = df.iloc[0]
16
+ video_file = Path(row.video_path)
17
+
18
+ # basic frame iterator
19
+ cap = cv2.VideoCapture(str(video_file))
20
+ frames = []
21
+ while True:
22
+ ok, frame = cap.read()
23
+ if not ok:
24
+ break
25
+ frames.append(frame)
26
+ cap.release()
27
+
28
+ print("frames:", len(frames))
29
+ print("object_class:", row.object_class)
30
+ print("container:", row.container_type)
31
+ print("outcome:", row.outcome)