halib 0.1.59__py3-none-any.whl → 0.1.60__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- halib/utils/dataclass_util.py +1 -0
- halib/utils/video.py +62 -0
- {halib-0.1.59.dist-info → halib-0.1.60.dist-info}/METADATA +5 -1
- {halib-0.1.59.dist-info → halib-0.1.60.dist-info}/RECORD +7 -6
- {halib-0.1.59.dist-info → halib-0.1.60.dist-info}/LICENSE.txt +0 -0
- {halib-0.1.59.dist-info → halib-0.1.60.dist-info}/WHEEL +0 -0
- {halib-0.1.59.dist-info → halib-0.1.60.dist-info}/top_level.txt +0 -0
halib/utils/dataclass_util.py
CHANGED
@@ -26,6 +26,7 @@ def yaml_to_dataclass(name: str, yaml_str: str):
|
|
26
26
|
data = yaml.safe_load(yaml_str)
|
27
27
|
return dict_to_dataclass(name, data)
|
28
28
|
|
29
|
+
|
29
30
|
def yamlfile_to_dataclass(name: str, file_path: str):
|
30
31
|
data_dict = yamlfile.load_yaml(file_path, to_dict=True)
|
31
32
|
if "__base__" in data_dict:
|
halib/utils/video.py
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
import os
|
2
|
+
import cv2
|
3
|
+
from ..filetype import csvfile
|
4
|
+
from ..system import filesys as fs
|
5
|
+
|
6
|
+
|
7
|
+
class VideoUtils:
|
8
|
+
@staticmethod
|
9
|
+
def get_video_meta_dict(video_path):
|
10
|
+
# Open the video file
|
11
|
+
cap = cv2.VideoCapture(video_path)
|
12
|
+
|
13
|
+
# Check if the video was opened successfully
|
14
|
+
if not cap.isOpened():
|
15
|
+
print(f"Error: Could not open video file {video_path}")
|
16
|
+
return None, None
|
17
|
+
|
18
|
+
# Get the frame count
|
19
|
+
frame_count = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
|
20
|
+
|
21
|
+
# Get the FPS
|
22
|
+
fps = cap.get(cv2.CAP_PROP_FPS)
|
23
|
+
|
24
|
+
# Release the video capture object
|
25
|
+
cap.release()
|
26
|
+
meta_dict = {
|
27
|
+
"video_path": video_path,
|
28
|
+
"frame_count": frame_count,
|
29
|
+
"fps": fps
|
30
|
+
}
|
31
|
+
return meta_dict
|
32
|
+
|
33
|
+
@staticmethod
|
34
|
+
def get_video_dir_meta_df(video_dir, video_exts=['.mp4', '.avi', '.mov', '.mkv'], search_recursive=False, csv_outfile=None):
|
35
|
+
assert os.path.exists(video_dir), f"Video directory {video_dir} does not exist"
|
36
|
+
video_files = fs.filter_files_by_extension(video_dir, video_exts, recursive=search_recursive)
|
37
|
+
assert len(video_files) > 0, f"No video files found in {video_dir} with extensions {video_exts}"
|
38
|
+
video_meta_list = []
|
39
|
+
for vfile in video_files:
|
40
|
+
meta_dict = VideoUtils.get_video_meta_dict(vfile)
|
41
|
+
if meta_dict:
|
42
|
+
video_meta_list.append(meta_dict)
|
43
|
+
dfmk = csvfile.DFCreator()
|
44
|
+
columns = list(video_meta_list[0].keys())
|
45
|
+
assert len(columns) > 0, "No video metadata found"
|
46
|
+
assert 'video_path' in columns, "video_path column not found in video metadata"
|
47
|
+
# move video_path to the first column
|
48
|
+
columns.remove('video_path')
|
49
|
+
columns.insert(0, 'video_path')
|
50
|
+
dfmk.create_table("video_meta", columns)
|
51
|
+
rows = [[meta[col] for col in columns] for meta in video_meta_list]
|
52
|
+
dfmk.insert_rows("video_meta", rows)
|
53
|
+
dfmk.fill_table_from_row_pool("video_meta")
|
54
|
+
|
55
|
+
if csv_outfile:
|
56
|
+
dfmk["video_meta"].to_csv(csv_outfile, index=False, sep=";")
|
57
|
+
return dfmk["video_meta"].copy()
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: halib
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.60
|
4
4
|
Summary: Small library for common tasks
|
5
5
|
Author: Hoang Van Ha
|
6
6
|
Author-email: hoangvanhauit@gmail.com
|
@@ -45,6 +45,10 @@ Requires-Dist: dataclass-wizard
|
|
45
45
|
|
46
46
|
Helper package for coding and automation
|
47
47
|
|
48
|
+
**Version 0.1.60**
|
49
|
+
|
50
|
+
+ add `util/video`: add `VideoUtils` class to handle common video-related tasks
|
51
|
+
|
48
52
|
**Version 0.1.59**
|
49
53
|
|
50
54
|
+ add `util/perfcalc`: abstract class for performance calculation. This class need to be inherited and implemented with specific performance calculation logic.
|
@@ -42,12 +42,13 @@ halib/system/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
42
42
|
halib/system/cmd.py,sha256=b2x7JPcNnFjLGheIESVYvqAb-w2UwBM1PAwYxMZ5YjA,228
|
43
43
|
halib/system/filesys.py,sha256=ERpnELLDKJoTIIKf-AajgkY62nID4qmqmX5TkE95APU,2931
|
44
44
|
halib/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
45
|
-
halib/utils/dataclass_util.py,sha256=
|
45
|
+
halib/utils/dataclass_util.py,sha256=rj2IMLlUzbm2OlF5_B2dRTk9njZOaF7tTjYkOsq8uLY,1416
|
46
46
|
halib/utils/dict_op.py,sha256=wYE6Iw-_CnCWdMg9tpJ2Y2-e2ESkW9FxmdBkZkbUh80,299
|
47
47
|
halib/utils/listop.py,sha256=Vpa8_2fI0wySpB2-8sfTBkyi_A4FhoFVVvFiuvW8N64,339
|
48
48
|
halib/utils/tele_noti.py,sha256=-4WXZelCA4W9BroapkRyIdUu9cUVrcJJhegnMs_WpGU,5928
|
49
|
-
halib
|
50
|
-
halib-0.1.
|
51
|
-
halib-0.1.
|
52
|
-
halib-0.1.
|
53
|
-
halib-0.1.
|
49
|
+
halib/utils/video.py,sha256=mJQFHFbijmu3lo0NZk4Ed64Tfa1u5KxNJpd_TuckpPU,2228
|
50
|
+
halib-0.1.60.dist-info/LICENSE.txt,sha256=qZssdna4aETiR8znYsShUjidu-U4jUT9Q-EWNlZ9yBQ,1100
|
51
|
+
halib-0.1.60.dist-info/METADATA,sha256=QMs6mroREHr6qCcrUJwOCwL86Rbu0_bQvf8sLiRsYFk,4957
|
52
|
+
halib-0.1.60.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
|
53
|
+
halib-0.1.60.dist-info/top_level.txt,sha256=7AD6PLaQTreE0Fn44mdZsoHBe_Zdd7GUmjsWPyQ7I-k,6
|
54
|
+
halib-0.1.60.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|