ImagePRO-Python 0.1.0__tar.gz → 0.1.1__tar.gz

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.
Files changed (29) hide show
  1. {imagepro_python-0.1.0/src/ImagePRO_Python.egg-info → imagepro_python-0.1.1}/PKG-INFO +1 -1
  2. {imagepro_python-0.1.0 → imagepro_python-0.1.1}/pyproject.toml +1 -1
  3. {imagepro_python-0.1.0 → imagepro_python-0.1.1}/src/ImagePRO/human_analysis/body_analysis/body_pose_estimation.py +1 -1
  4. {imagepro_python-0.1.0 → imagepro_python-0.1.1}/src/ImagePRO/human_analysis/body_analysis/hand_tracking.py +1 -1
  5. {imagepro_python-0.1.0 → imagepro_python-0.1.1}/src/ImagePRO/human_analysis/face_analysis/eye_status_analysis.py +1 -1
  6. {imagepro_python-0.1.0 → imagepro_python-0.1.1}/src/ImagePRO/human_analysis/face_analysis/face_detection.py +1 -1
  7. {imagepro_python-0.1.0 → imagepro_python-0.1.1}/src/ImagePRO/human_analysis/face_analysis/face_mesh_analysis.py +1 -1
  8. {imagepro_python-0.1.0 → imagepro_python-0.1.1}/src/ImagePRO/human_analysis/face_analysis/head_pose_estimation.py +1 -1
  9. {imagepro_python-0.1.0 → imagepro_python-0.1.1}/src/ImagePRO/pre_processing/blur.py +1 -1
  10. {imagepro_python-0.1.0 → imagepro_python-0.1.1}/src/ImagePRO/pre_processing/contrast.py +1 -1
  11. {imagepro_python-0.1.0 → imagepro_python-0.1.1}/src/ImagePRO/pre_processing/crop.py +1 -1
  12. {imagepro_python-0.1.0 → imagepro_python-0.1.1}/src/ImagePRO/pre_processing/grayscale.py +1 -1
  13. {imagepro_python-0.1.0 → imagepro_python-0.1.1}/src/ImagePRO/pre_processing/resize.py +1 -1
  14. {imagepro_python-0.1.0 → imagepro_python-0.1.1}/src/ImagePRO/pre_processing/rotate.py +1 -1
  15. {imagepro_python-0.1.0 → imagepro_python-0.1.1}/src/ImagePRO/pre_processing/sharpen.py +2 -2
  16. imagepro_python-0.1.1/src/ImagePRO/utils/__init__.py +0 -0
  17. imagepro_python-0.1.1/src/ImagePRO/utils/io_handler.py +178 -0
  18. {imagepro_python-0.1.0 → imagepro_python-0.1.1/src/ImagePRO_Python.egg-info}/PKG-INFO +1 -1
  19. {imagepro_python-0.1.0 → imagepro_python-0.1.1}/src/ImagePRO_Python.egg-info/SOURCES.txt +2 -0
  20. {imagepro_python-0.1.0 → imagepro_python-0.1.1}/LICENSE +0 -0
  21. {imagepro_python-0.1.0 → imagepro_python-0.1.1}/setup.cfg +0 -0
  22. {imagepro_python-0.1.0 → imagepro_python-0.1.1}/src/ImagePRO/__init__.py +0 -0
  23. {imagepro_python-0.1.0 → imagepro_python-0.1.1}/src/ImagePRO/human_analysis/__init__.py +0 -0
  24. {imagepro_python-0.1.0 → imagepro_python-0.1.1}/src/ImagePRO/human_analysis/body_analysis/__init__.py +0 -0
  25. {imagepro_python-0.1.0 → imagepro_python-0.1.1}/src/ImagePRO/human_analysis/face_analysis/__init__.py +0 -0
  26. {imagepro_python-0.1.0 → imagepro_python-0.1.1}/src/ImagePRO/pre_processing/__init__.py +0 -0
  27. {imagepro_python-0.1.0 → imagepro_python-0.1.1}/src/ImagePRO_Python.egg-info/dependency_links.txt +0 -0
  28. {imagepro_python-0.1.0 → imagepro_python-0.1.1}/src/ImagePRO_Python.egg-info/requires.txt +0 -0
  29. {imagepro_python-0.1.0 → imagepro_python-0.1.1}/src/ImagePRO_Python.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ImagePRO-Python
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: clean, modular, and easy-to-use Python library for image processing tasks.
5
5
  Author-email: Parsa Safaie <parsasafaie.2568@proton.me>
6
6
  License: MIT
@@ -7,7 +7,7 @@ where = ["src"]
7
7
 
8
8
  [project]
9
9
  name = "ImagePRO-Python"
10
- version = "0.1.0"
10
+ version = "0.1.1"
11
11
  description = "clean, modular, and easy-to-use Python library for image processing tasks."
12
12
  readme = "README.md"
13
13
  requires-python = "==3.10.*"
@@ -8,7 +8,7 @@ import mediapipe as mp
8
8
  parent_dir = Path(__file__).resolve().parent.parent.parent
9
9
  sys.path.append(str(parent_dir))
10
10
 
11
- from io_handler import IOHandler
11
+ from utils.io_handler import IOHandler
12
12
 
13
13
  mp_pose = mp.solutions.pose
14
14
 
@@ -8,7 +8,7 @@ import mediapipe as mp
8
8
  parent_dir = Path(__file__).resolve().parent.parent.parent
9
9
  sys.path.append(str(parent_dir))
10
10
 
11
- from io_handler import IOHandler
11
+ from utils.io_handler import IOHandler
12
12
 
13
13
  mp_hands = mp.solutions.hands
14
14
 
@@ -8,7 +8,7 @@ import mediapipe as mp
8
8
  parent_dir = Path(__file__).resolve().parent.parent.parent
9
9
  sys.path.append(str(parent_dir))
10
10
 
11
- from io_handler import IOHandler
11
+ from utils.io_handler import IOHandler
12
12
  from human_analysis.face_analysis.face_mesh_analysis import analyze_face_mesh
13
13
 
14
14
  mp_face_mesh = mp.solutions.face_mesh
@@ -8,7 +8,7 @@ import numpy as np
8
8
  parent_dir = Path(__file__).resolve().parent.parent.parent
9
9
  sys.path.append(str(parent_dir))
10
10
 
11
- from io_handler import IOHandler
11
+ from utils.io_handler import IOHandler
12
12
  from human_analysis.face_analysis.face_mesh_analysis import analyze_face_mesh
13
13
 
14
14
 
@@ -8,7 +8,7 @@ import mediapipe as mp
8
8
  parent_dir = Path(__file__).resolve().parent.parent.parent
9
9
  sys.path.append(str(parent_dir))
10
10
 
11
- from io_handler import IOHandler
11
+ from utils.io_handler import IOHandler
12
12
 
13
13
  mp_face_mesh = mp.solutions.face_mesh
14
14
  mp_drawing_utils = mp.solutions.drawing_utils
@@ -8,7 +8,7 @@ import mediapipe as mp
8
8
  parent_dir = Path(__file__).resolve().parent.parent.parent
9
9
  sys.path.append(str(parent_dir))
10
10
 
11
- from io_handler import IOHandler
11
+ from utils.io_handler import IOHandler
12
12
  from human_analysis.face_analysis.face_mesh_analysis import analyze_face_mesh
13
13
 
14
14
  mp_face_mesh = mp.solutions.face_mesh
@@ -8,7 +8,7 @@ import numpy as np
8
8
  parent_dir = Path(__file__).resolve().parent.parent
9
9
  sys.path.append(str(parent_dir))
10
10
 
11
- from io_handler import IOHandler
11
+ from utils.io_handler import IOHandler
12
12
 
13
13
 
14
14
  def apply_average_blur(kernel_size=(5, 5), image_path=None, np_image=None, result_path=None):
@@ -9,7 +9,7 @@ parent_dir = Path(__file__).resolve().parent.parent
9
9
  sys.path.append(str(parent_dir))
10
10
 
11
11
  from pre_processing.grayscale import convert_to_grayscale
12
- from io_handler import IOHandler
12
+ from utils.io_handler import IOHandler
13
13
 
14
14
 
15
15
  def apply_clahe_contrast(
@@ -5,7 +5,7 @@ from pathlib import Path
5
5
  parent_dir = Path(__file__).resolve().parent.parent
6
6
  sys.path.append(str(parent_dir))
7
7
 
8
- from io_handler import IOHandler
8
+ from utils.io_handler import IOHandler
9
9
 
10
10
 
11
11
  def crop_image(start_point, end_point, image_path=None, np_image=None, result_path=None):
@@ -7,7 +7,7 @@ import cv2
7
7
  parent_dir = Path(__file__).resolve().parent.parent
8
8
  sys.path.append(str(parent_dir))
9
9
 
10
- from io_handler import IOHandler
10
+ from utils.io_handler import IOHandler
11
11
 
12
12
 
13
13
  def convert_to_grayscale(image_path=None, np_image=None, result_path=None):
@@ -7,7 +7,7 @@ import cv2
7
7
  parent_dir = Path(__file__).resolve().parent.parent
8
8
  sys.path.append(str(parent_dir))
9
9
 
10
- from io_handler import IOHandler
10
+ from utils.io_handler import IOHandler
11
11
 
12
12
 
13
13
  def resize_image(new_size, image_path=None, np_image=None, result_path=None):
@@ -7,7 +7,7 @@ import cv2
7
7
  parent_dir = Path(__file__).resolve().parent.parent
8
8
  sys.path.append(str(parent_dir))
9
9
 
10
- from io_handler import IOHandler
10
+ from utils.io_handler import IOHandler
11
11
 
12
12
 
13
13
  def rotate_image_90(image_path=None, np_image=None, result_path=None):
@@ -8,8 +8,8 @@ import numpy as np
8
8
  parent_dir = Path(__file__).resolve().parent.parent
9
9
  sys.path.append(str(parent_dir))
10
10
 
11
- from io_handler import IOHandler
12
- from blur import apply_average_blur
11
+ from utils.io_handler import IOHandler
12
+ from pre_processing.blur import apply_average_blur
13
13
 
14
14
 
15
15
  def apply_laplacian_sharpening(
File without changes
@@ -0,0 +1,178 @@
1
+ # io_handler.py
2
+
3
+ import os
4
+ import json
5
+ import csv
6
+ from pathlib import Path
7
+
8
+ import cv2
9
+ import numpy as np
10
+
11
+
12
+ class IOHandler:
13
+ @staticmethod
14
+ def load_image(image_path=None, np_image=None):
15
+ """
16
+ Load an image from disk or use an existing NumPy array.
17
+
18
+ Args:
19
+ image_path (str, optional): Path to the image file.
20
+ np_image (np.ndarray, optional): Image as a NumPy array.
21
+
22
+ Returns:
23
+ np.ndarray: Loaded image.
24
+
25
+ Raises:
26
+ TypeError: Invalid input types.
27
+ FileNotFoundError: File not found.
28
+ ValueError: Both inputs are None or image loading failed.
29
+ """
30
+ if image_path is not None:
31
+ if not isinstance(image_path, str):
32
+ raise TypeError("'image_path' must be a string.")
33
+ if not os.path.isfile(image_path):
34
+ raise FileNotFoundError(f"File not found: {image_path}")
35
+ img = cv2.imread(image_path)
36
+ if img is None:
37
+ raise ValueError(f"Unable to load image: {image_path}")
38
+ return img
39
+
40
+ if np_image is not None:
41
+ if not isinstance(np_image, np.ndarray):
42
+ raise TypeError("'np_image' must be a NumPy array.")
43
+ return np_image
44
+
45
+ raise ValueError("Provide at least 'image_path' or 'np_image'.")
46
+
47
+ @staticmethod
48
+ def save_image(np_image, result_path=None):
49
+ """
50
+ Save a NumPy image array (or list of arrays) to disk or return it.
51
+
52
+ Args:
53
+ np_image (np.ndarray or list[np.ndarray]): Image(s) to save.
54
+ result_path (str, optional): Save path.
55
+
56
+ Returns:
57
+ str or np.ndarray or list[np.ndarray]:
58
+ Save message if path given, otherwise returns input.
59
+
60
+ Raises:
61
+ TypeError: Invalid input types.
62
+ IOError: Saving failed.
63
+ """
64
+ if not isinstance(np_image, (np.ndarray, list)):
65
+ raise TypeError("'np_image' must be a NumPy array or list of arrays.")
66
+
67
+ if isinstance(np_image, list) and not all(isinstance(i, np.ndarray) for i in np_image):
68
+ raise TypeError("All items in the list must be NumPy arrays.")
69
+
70
+ if result_path is not None and not isinstance(result_path, str):
71
+ raise TypeError("'result_path' must be a string or None.")
72
+
73
+ if result_path:
74
+ if isinstance(np_image, np.ndarray):
75
+ if not cv2.imwrite(result_path, np_image):
76
+ raise IOError(f"Failed to save image: {result_path}")
77
+ return f"Image saved at {result_path}"
78
+
79
+ for i, img in enumerate(np_image):
80
+ suffix = f"_{i}" if i > 0 else ""
81
+ path = result_path.replace(".jpg", f"{suffix}.jpg")
82
+ if not cv2.imwrite(path, img):
83
+ raise IOError(f"Failed to save image: {path}")
84
+ return f"Images saved using base path {result_path}"
85
+
86
+ return np_image
87
+
88
+ @staticmethod
89
+ def save_csv(data, result_path=None):
90
+ """
91
+ Save a list of lists as a CSV file or return it.
92
+
93
+ Args:
94
+ data (list[list]): Tabular data.
95
+ result_path (str, optional): Save path.
96
+
97
+ Returns:
98
+ str or list[list]: Save message or original data.
99
+
100
+ Raises:
101
+ TypeError: Invalid input types.
102
+ """
103
+ if not isinstance(data, list) or not all(isinstance(row, list) for row in data):
104
+ raise TypeError("'data' must be a list of lists.")
105
+
106
+ if result_path:
107
+ if not isinstance(result_path, str):
108
+ raise TypeError("'result_path' must be a string or None.")
109
+ with open(result_path, "w", newline='') as f:
110
+ writer = csv.writer(f)
111
+ writer.writerows(data)
112
+ return f"CSV saved at {result_path}"
113
+
114
+ return data
115
+
116
+ @staticmethod
117
+ def save_json(data, result_path=None):
118
+ """
119
+ Save data as a JSON file or return it.
120
+
121
+ Args:
122
+ data (Any): JSON-serializable data.
123
+ result_path (str, optional): Save path.
124
+
125
+ Returns:
126
+ str or Any: Save message or original data.
127
+
128
+ Raises:
129
+ TypeError: Invalid path type.
130
+ """
131
+ if result_path:
132
+ if not isinstance(result_path, str):
133
+ raise TypeError("'result_path' must be a string or None.")
134
+ with open(result_path, "w") as f:
135
+ json.dump(data, f, indent=4)
136
+ return f"JSON saved at {result_path}"
137
+
138
+ return data
139
+
140
+ @staticmethod
141
+ def save(data, result_path=None, file_type=None):
142
+ """
143
+ Save data to disk automatically based on file type or extension.
144
+
145
+ Args:
146
+ data (Any): Data to save.
147
+ result_path (str, optional): Save path.
148
+ file_type (str, optional): 'image', 'csv', or 'json'.
149
+
150
+ Returns:
151
+ str or Any: Save message or original data.
152
+
153
+ Raises:
154
+ ValueError: Unsupported file type or extension.
155
+ TypeError: Invalid input types.
156
+ """
157
+ if file_type is None:
158
+ if result_path is None:
159
+ return data
160
+
161
+ ext = Path(result_path).suffix.lower()
162
+ if ext in [".jpg", ".jpeg", ".png"]:
163
+ file_type = "image"
164
+ elif ext == ".csv":
165
+ file_type = "csv"
166
+ elif ext == ".json":
167
+ file_type = "json"
168
+ else:
169
+ raise ValueError(f"Unsupported file extension: {ext}")
170
+
171
+ if file_type == "image":
172
+ return IOHandler.save_image(data, result_path)
173
+ elif file_type == "csv":
174
+ return IOHandler.save_csv(data, result_path)
175
+ elif file_type == "json":
176
+ return IOHandler.save_json(data, result_path)
177
+
178
+ raise ValueError(f"Unsupported file type: {file_type}")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ImagePRO-Python
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: clean, modular, and easy-to-use Python library for image processing tasks.
5
5
  Author-email: Parsa Safaie <parsasafaie.2568@proton.me>
6
6
  License: MIT
@@ -18,6 +18,8 @@ src/ImagePRO/pre_processing/grayscale.py
18
18
  src/ImagePRO/pre_processing/resize.py
19
19
  src/ImagePRO/pre_processing/rotate.py
20
20
  src/ImagePRO/pre_processing/sharpen.py
21
+ src/ImagePRO/utils/__init__.py
22
+ src/ImagePRO/utils/io_handler.py
21
23
  src/ImagePRO_Python.egg-info/PKG-INFO
22
24
  src/ImagePRO_Python.egg-info/SOURCES.txt
23
25
  src/ImagePRO_Python.egg-info/dependency_links.txt
File without changes