homa 0.19__tar.gz → 0.22__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 (37) hide show
  1. homa-0.22/PKG-INFO +108 -0
  2. homa-0.22/README.md +100 -0
  3. homa-0.22/homa/__init__.py +4 -0
  4. homa-0.22/homa/camera.py +21 -0
  5. homa-0.22/homa/classes/Collection.py +11 -0
  6. homa-0.22/homa/classes/Logger.py +4 -0
  7. homa-0.22/homa/classes/Repository.py +32 -0
  8. homa-0.22/homa/classes/__init__.py +0 -0
  9. homa-0.22/homa/constants.py +0 -0
  10. homa-0.22/homa/filters.py +34 -0
  11. homa-0.22/homa/helpers.py +30 -0
  12. homa-0.22/homa/main.py +56 -0
  13. homa-0.22/homa/orientation.py +36 -0
  14. homa-0.22/homa.egg-info/PKG-INFO +108 -0
  15. homa-0.22/homa.egg-info/SOURCES.txt +19 -0
  16. homa-0.22/homa.egg-info/requires.txt +2 -0
  17. {homa-0.19 → homa-0.22}/setup.py +11 -6
  18. homa-0.19/PKG-INFO +0 -43
  19. homa-0.19/README.md +0 -35
  20. homa-0.19/homa/__init__.py +0 -3
  21. homa-0.19/homa/helpers.py +0 -131
  22. homa-0.19/homa/main.py +0 -34
  23. homa-0.19/homa/repositories/RandomDateRepository.py +0 -62
  24. homa-0.19/homa/repositories/RandomImageRepository.py +0 -2
  25. homa-0.19/homa/repositories/RandomNameRepository.py +0 -64
  26. homa-0.19/homa/repositories/RandomTextRepository.py +0 -22
  27. homa-0.19/homa/repositories/__init__.py +0 -4
  28. homa-0.19/homa/wordlists/feminine.txt +0 -100
  29. homa-0.19/homa/wordlists/masculine.txt +0 -100
  30. homa-0.19/homa/wordlists/surnames.txt +0 -100
  31. homa-0.19/homa/wordlists/titles.txt +0 -225
  32. homa-0.19/homa.egg-info/PKG-INFO +0 -43
  33. homa-0.19/homa.egg-info/SOURCES.txt +0 -19
  34. {homa-0.19 → homa-0.22}/LICENSE +0 -0
  35. {homa-0.19 → homa-0.22}/homa.egg-info/dependency_links.txt +0 -0
  36. {homa-0.19 → homa-0.22}/homa.egg-info/top_level.txt +0 -0
  37. {homa-0.19 → homa-0.22}/setup.cfg +0 -0
homa-0.22/PKG-INFO ADDED
@@ -0,0 +1,108 @@
1
+ Metadata-Version: 2.1
2
+ Name: homa
3
+ Version: 0.22
4
+ Maintainer: Taha Shieenavaz
5
+ Maintainer-email: tahashieenavaz@gmail.com
6
+ Description-Content-Type: text/markdown
7
+ License-File: LICENSE
8
+
9
+ <p align="center">
10
+ <img
11
+ src="https://raw.githubusercontent.com/tahashieenavaz/homa/main/art/homa.svg"
12
+ width=500
13
+ />
14
+ </p>
15
+
16
+ <hr />
17
+
18
+ Homa is an easy way to start learning Computer Vision with OpenCV.
19
+
20
+ ## Loading Images
21
+
22
+ Images could be loaded with the `image` helper, that accepts the file name and a key for the repository.
23
+
24
+ ```python
25
+ from homa import *
26
+
27
+ image("horse.jpg", "horse")
28
+ ```
29
+
30
+ Alternatively, following code will load the file into the repository with a key of everything before the last in the filename.
31
+
32
+ ```python
33
+ from homa import *
34
+
35
+ image("horse.jpg") # stored as "horse"
36
+ ```
37
+
38
+ ## Smoothing
39
+
40
+ ### Blur
41
+
42
+ ```python
43
+ from homa import *
44
+
45
+ image("horse.jpg")
46
+
47
+ blur("horse", 7) # rewrites "horse" key
48
+ blur("horse", (7, 19)) # rewrites "horse" key
49
+ blur("horse", 9, "blurred horse") # as a new key in the repository
50
+ show("blurred horse")
51
+ ```
52
+
53
+ ### Gaussian Blur
54
+
55
+ ```python
56
+ from homa import *
57
+
58
+ image("horse.jpg")
59
+
60
+ gaussian("horse", 7) # rewrites "horse" key
61
+ gaussian("horse", (7, 19)) # rewrites "horse" key
62
+ gaussian("horse", 9, "gaussian blurred horse") # as a new key in the repository
63
+ show("gaussian blurred horse")
64
+ ```
65
+
66
+ ## Stacking
67
+
68
+ ```python
69
+ from homa import *
70
+
71
+ image("horse.jpg")
72
+ blur("horse", 9, "blurred horse")
73
+
74
+ show(
75
+ vstack("horse", "blurred horse"),
76
+ window="Vstacked"
77
+ )
78
+
79
+ showWait(
80
+ hstack("horse", "blurred horse"),
81
+ window="Hstacked"
82
+ )
83
+ ```
84
+
85
+ ## Camera
86
+
87
+ Camera frames could be access from the repository with a key of `camera`.
88
+
89
+ ```python
90
+ from homa import *
91
+
92
+ for _ in camera():
93
+ show("camera")
94
+ ```
95
+
96
+ You can simply combine camera frames with the supported effects.
97
+
98
+ ```python
99
+ from homa import *
100
+
101
+ for _ in camera():
102
+ blur("camera", 13, "blurred camera")
103
+
104
+ show(
105
+ vstack("camera", "blurred camera"),
106
+ window="Camera Effect"
107
+ )
108
+ ```
homa-0.22/README.md ADDED
@@ -0,0 +1,100 @@
1
+ <p align="center">
2
+ <img
3
+ src="https://raw.githubusercontent.com/tahashieenavaz/homa/main/art/homa.svg"
4
+ width=500
5
+ />
6
+ </p>
7
+
8
+ <hr />
9
+
10
+ Homa is an easy way to start learning Computer Vision with OpenCV.
11
+
12
+ ## Loading Images
13
+
14
+ Images could be loaded with the `image` helper, that accepts the file name and a key for the repository.
15
+
16
+ ```python
17
+ from homa import *
18
+
19
+ image("horse.jpg", "horse")
20
+ ```
21
+
22
+ Alternatively, following code will load the file into the repository with a key of everything before the last in the filename.
23
+
24
+ ```python
25
+ from homa import *
26
+
27
+ image("horse.jpg") # stored as "horse"
28
+ ```
29
+
30
+ ## Smoothing
31
+
32
+ ### Blur
33
+
34
+ ```python
35
+ from homa import *
36
+
37
+ image("horse.jpg")
38
+
39
+ blur("horse", 7) # rewrites "horse" key
40
+ blur("horse", (7, 19)) # rewrites "horse" key
41
+ blur("horse", 9, "blurred horse") # as a new key in the repository
42
+ show("blurred horse")
43
+ ```
44
+
45
+ ### Gaussian Blur
46
+
47
+ ```python
48
+ from homa import *
49
+
50
+ image("horse.jpg")
51
+
52
+ gaussian("horse", 7) # rewrites "horse" key
53
+ gaussian("horse", (7, 19)) # rewrites "horse" key
54
+ gaussian("horse", 9, "gaussian blurred horse") # as a new key in the repository
55
+ show("gaussian blurred horse")
56
+ ```
57
+
58
+ ## Stacking
59
+
60
+ ```python
61
+ from homa import *
62
+
63
+ image("horse.jpg")
64
+ blur("horse", 9, "blurred horse")
65
+
66
+ show(
67
+ vstack("horse", "blurred horse"),
68
+ window="Vstacked"
69
+ )
70
+
71
+ showWait(
72
+ hstack("horse", "blurred horse"),
73
+ window="Hstacked"
74
+ )
75
+ ```
76
+
77
+ ## Camera
78
+
79
+ Camera frames could be access from the repository with a key of `camera`.
80
+
81
+ ```python
82
+ from homa import *
83
+
84
+ for _ in camera():
85
+ show("camera")
86
+ ```
87
+
88
+ You can simply combine camera frames with the supported effects.
89
+
90
+ ```python
91
+ from homa import *
92
+
93
+ for _ in camera():
94
+ blur("camera", 13, "blurred camera")
95
+
96
+ show(
97
+ vstack("camera", "blurred camera"),
98
+ window="Camera Effect"
99
+ )
100
+ ```
@@ -0,0 +1,4 @@
1
+ from .main import *
2
+ from .filters import *
3
+ from .camera import *
4
+ from .orientation import *
@@ -0,0 +1,21 @@
1
+ import cv2
2
+ from .classes.Repository import Repository
3
+
4
+
5
+ def camera(delay=10):
6
+ capture = cv2.VideoCapture(0)
7
+
8
+ pressed_key = None
9
+
10
+ frame_number = 0
11
+
12
+ while pressed_key != ord("q"):
13
+ frame_number += 1
14
+ _, frame = capture.read()
15
+
16
+ Repository.images["camera"] = frame
17
+
18
+ yield frame_number
19
+ pressed_key = cv2.waitKey(delay)
20
+
21
+ capture.release()
@@ -0,0 +1,11 @@
1
+ from typing import List
2
+
3
+
4
+ class Collection:
5
+ def __init__(self, items: List[any]):
6
+ self.value = items
7
+
8
+ def map(self, callback: callable):
9
+ return list(
10
+ map(callback, self.value)
11
+ )
@@ -0,0 +1,4 @@
1
+ class Logger:
2
+ @staticmethod
3
+ def danger(message: str) -> None:
4
+ print(message)
@@ -0,0 +1,32 @@
1
+ from ..helpers import is_colab
2
+
3
+
4
+ class RepositoryWrapper:
5
+ def __init__(self):
6
+ self.sigmaX = 0
7
+ self.sigmaY = 0
8
+
9
+ self.directory = "./"
10
+ self.images = {}
11
+ self.cameras = {}
12
+ self.window_counter = 0
13
+
14
+ if is_colab():
15
+ from google.colab.patches import cv2_imshow as imshow
16
+ else:
17
+ from cv2 import imshow
18
+
19
+ def final_imshow(window, image):
20
+ if is_colab():
21
+ imshow(image)
22
+ else:
23
+ imshow(window, image)
24
+
25
+ self.imshow = final_imshow
26
+
27
+ def get_counter(self):
28
+ self.window_counter += 1
29
+ return self.window_counter
30
+
31
+
32
+ Repository = RepositoryWrapper()
File without changes
File without changes
@@ -0,0 +1,34 @@
1
+ from typing import List
2
+ from .classes.Repository import Repository
3
+ from .helpers import create_kernel
4
+ import cv2
5
+
6
+
7
+ def blur(key: str, kernel: int | List[int] = (7, 7), new_key: str | None = None):
8
+ if new_key is None:
9
+ new_key = key
10
+
11
+ Repository.images[new_key] = cv2.blur(
12
+ Repository.images[key],
13
+ create_kernel(kernel)
14
+ )
15
+
16
+
17
+ def sigma(x: float = 0, y: float = 0):
18
+ Repository.sigmaX = x
19
+ Repository.sigmaY = y
20
+
21
+
22
+ def gaussian(key: str, kernel: None | List[int] = None, new_key: str | None = None):
23
+ if new_key is None:
24
+ new_key = key
25
+
26
+ if isinstance(kernel, int):
27
+ kernel = (kernel, kernel)
28
+
29
+ Repository.images[new_key] = cv2.GaussianBlur(
30
+ Repository.images[key],
31
+ kernel,
32
+ sigmaX=Repository.sigmaX,
33
+ sigmaY=Repository.sigmaY
34
+ )
@@ -0,0 +1,30 @@
1
+ import sys
2
+ from typing import List
3
+ from .classes.Collection import Collection
4
+ from .classes.Logger import Logger
5
+
6
+
7
+ def is_colab() -> bool:
8
+ return 'google.colab' in sys.modules
9
+
10
+
11
+ def collection(items: List[any]):
12
+ return Collection(items)
13
+
14
+
15
+ def danger(message: str) -> None:
16
+ Logger.danger(message)
17
+
18
+
19
+ def create_kernel(value: int | tuple) -> tuple:
20
+ if isinstance(value, tuple):
21
+ x, y = value
22
+
23
+ x = x - 1 if x % 2 == 0 else x
24
+ y = y - 1 if y % 2 == 0 else y
25
+
26
+ return (x, y)
27
+
28
+ value = value - 1 if value % 2 == 0 else value
29
+
30
+ return (value, value)
homa-0.22/homa/main.py ADDED
@@ -0,0 +1,56 @@
1
+ import cv2
2
+ from .helpers import danger
3
+ from .classes.Repository import Repository
4
+
5
+
6
+ def path(directory: str) -> None:
7
+ Repository.directory = directory
8
+
9
+
10
+ def write(key: str, filename: str) -> None:
11
+ cv2.imwrite(
12
+ filename=filename,
13
+ img=Repository.images[key]
14
+ )
15
+
16
+
17
+ def save(*args, **kwargs) -> None:
18
+ write(args, kwargs)
19
+
20
+
21
+ def image(filename: str, key: str | None = None, color: bool = True) -> None:
22
+ # TODO: add no extension in the file
23
+ if key is None:
24
+ key = filename.split(".")[0]
25
+
26
+ Repository.images[key] = cv2.imread(filename, int(color))
27
+ return Repository.images[key]
28
+
29
+
30
+ def wait(delay=0):
31
+ cv2.waitKey(delay)
32
+
33
+
34
+ def showWait(*args, **kwargs):
35
+ kwargs["wait"] = True
36
+ show(*args, **kwargs)
37
+
38
+
39
+ def show(key: any = None, wait: bool = False, window: str = "Homa Window") -> None:
40
+ # TODO: add functionality to distinguish between camera and images
41
+
42
+ if key is not None and not isinstance(key, str):
43
+ Repository.imshow(window, key)
44
+
45
+ elif key is None:
46
+ for key, image in Repository.images.items():
47
+ Repository.imshow(key, image)
48
+
49
+ elif key is not None:
50
+ if key in Repository.images:
51
+ Repository.imshow(key, Repository.images[key])
52
+ else:
53
+ danger(f"No image found with key {key}")
54
+
55
+ if wait:
56
+ cv2.waitKey(0)
@@ -0,0 +1,36 @@
1
+ from typing import List
2
+ from .classes.Repository import Repository
3
+ from .helpers import collection
4
+ import numpy
5
+
6
+
7
+ def stack(*keys, **settings):
8
+ default_settings = {
9
+ "axis": 1,
10
+ "new_key": None
11
+ }
12
+
13
+ settings = {
14
+ **default_settings,
15
+ **settings
16
+ }
17
+
18
+ stacked_image = numpy.concatenate(
19
+ collection(keys).map(lambda key: Repository.images[key]),
20
+ axis=settings["axis"]
21
+ )
22
+
23
+ if settings["new_key"] is not None:
24
+ Repository.images[settings["new_key"]] = stacked_image
25
+
26
+ return stacked_image
27
+
28
+
29
+ def vstack(*keys, **settings):
30
+ settings["axis"] = 1
31
+ return stack(*keys, **settings)
32
+
33
+
34
+ def hstack(*keys, **settings):
35
+ settings["axis"] = 0
36
+ return stack(*keys, **settings)
@@ -0,0 +1,108 @@
1
+ Metadata-Version: 2.1
2
+ Name: homa
3
+ Version: 0.22
4
+ Maintainer: Taha Shieenavaz
5
+ Maintainer-email: tahashieenavaz@gmail.com
6
+ Description-Content-Type: text/markdown
7
+ License-File: LICENSE
8
+
9
+ <p align="center">
10
+ <img
11
+ src="https://raw.githubusercontent.com/tahashieenavaz/homa/main/art/homa.svg"
12
+ width=500
13
+ />
14
+ </p>
15
+
16
+ <hr />
17
+
18
+ Homa is an easy way to start learning Computer Vision with OpenCV.
19
+
20
+ ## Loading Images
21
+
22
+ Images could be loaded with the `image` helper, that accepts the file name and a key for the repository.
23
+
24
+ ```python
25
+ from homa import *
26
+
27
+ image("horse.jpg", "horse")
28
+ ```
29
+
30
+ Alternatively, following code will load the file into the repository with a key of everything before the last in the filename.
31
+
32
+ ```python
33
+ from homa import *
34
+
35
+ image("horse.jpg") # stored as "horse"
36
+ ```
37
+
38
+ ## Smoothing
39
+
40
+ ### Blur
41
+
42
+ ```python
43
+ from homa import *
44
+
45
+ image("horse.jpg")
46
+
47
+ blur("horse", 7) # rewrites "horse" key
48
+ blur("horse", (7, 19)) # rewrites "horse" key
49
+ blur("horse", 9, "blurred horse") # as a new key in the repository
50
+ show("blurred horse")
51
+ ```
52
+
53
+ ### Gaussian Blur
54
+
55
+ ```python
56
+ from homa import *
57
+
58
+ image("horse.jpg")
59
+
60
+ gaussian("horse", 7) # rewrites "horse" key
61
+ gaussian("horse", (7, 19)) # rewrites "horse" key
62
+ gaussian("horse", 9, "gaussian blurred horse") # as a new key in the repository
63
+ show("gaussian blurred horse")
64
+ ```
65
+
66
+ ## Stacking
67
+
68
+ ```python
69
+ from homa import *
70
+
71
+ image("horse.jpg")
72
+ blur("horse", 9, "blurred horse")
73
+
74
+ show(
75
+ vstack("horse", "blurred horse"),
76
+ window="Vstacked"
77
+ )
78
+
79
+ showWait(
80
+ hstack("horse", "blurred horse"),
81
+ window="Hstacked"
82
+ )
83
+ ```
84
+
85
+ ## Camera
86
+
87
+ Camera frames could be access from the repository with a key of `camera`.
88
+
89
+ ```python
90
+ from homa import *
91
+
92
+ for _ in camera():
93
+ show("camera")
94
+ ```
95
+
96
+ You can simply combine camera frames with the supported effects.
97
+
98
+ ```python
99
+ from homa import *
100
+
101
+ for _ in camera():
102
+ blur("camera", 13, "blurred camera")
103
+
104
+ show(
105
+ vstack("camera", "blurred camera"),
106
+ window="Camera Effect"
107
+ )
108
+ ```
@@ -0,0 +1,19 @@
1
+ LICENSE
2
+ README.md
3
+ setup.py
4
+ homa/__init__.py
5
+ homa/camera.py
6
+ homa/constants.py
7
+ homa/filters.py
8
+ homa/helpers.py
9
+ homa/main.py
10
+ homa/orientation.py
11
+ homa.egg-info/PKG-INFO
12
+ homa.egg-info/SOURCES.txt
13
+ homa.egg-info/dependency_links.txt
14
+ homa.egg-info/requires.txt
15
+ homa.egg-info/top_level.txt
16
+ homa/classes/Collection.py
17
+ homa/classes/Logger.py
18
+ homa/classes/Repository.py
19
+ homa/classes/__init__.py
@@ -0,0 +1,2 @@
1
+ opencv-python
2
+ numpy
@@ -1,22 +1,27 @@
1
1
  from setuptools import setup
2
2
  from setuptools import find_packages
3
+ from sys import argv
3
4
 
4
5
  with open("README.md") as fh:
5
6
  description = fh.read()
6
7
 
8
+ with open("version.txt", "r") as fh:
9
+ current_version = float(fh.readline())
10
+
11
+ with open("version.txt", "w") as fh:
12
+ next_version = round(current_version + 0.01, 2)
13
+ fh.write(str(next_version))
14
+
7
15
  setup(
8
16
  name="homa",
9
17
  maintainer="Taha Shieenavaz",
10
18
  maintainer_email="tahashieenavaz@gmail.com",
11
- version="0.19",
19
+ version=next_version,
12
20
  packages=find_packages(),
13
21
  install_requires=[
14
- #
22
+ "opencv-python",
23
+ "numpy"
15
24
  ],
16
25
  long_description=description,
17
26
  long_description_content_type="text/markdown",
18
- include_package_data=True,
19
- package_data={
20
- "": ["wordlists/*"]
21
- }
22
27
  )
homa-0.19/PKG-INFO DELETED
@@ -1,43 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: homa
3
- Version: 0.19
4
- Maintainer: Taha Shieenavaz
5
- Maintainer-email: tahashieenavaz@gmail.com
6
- Description-Content-Type: text/markdown
7
- License-File: LICENSE
8
-
9
- <p align="center">
10
- <img
11
- src="https://raw.githubusercontent.com/tahashieenavaz/homa/main/art/homa.svg"
12
- width=400
13
- />
14
- </p>
15
-
16
- <hr />
17
-
18
- Homa is a library to generate random data that provides more productivity for developers.
19
-
20
- In loving memory of [Saber Rastikerdar](https://rastikerdar.github.io/), who introduced Persian (Farsi) to the digital world. 🖤💚
21
-
22
- ## Names
23
-
24
- ```python
25
- from homa import fake
26
-
27
- fake().fullname() # Julia Briwn
28
- fake().prefix() # Ms.
29
- fake().firstname() # Joe
30
- fake().surname() # Lewos
31
-
32
- fake().fullname("girl") # Ms. Heather Willaoms
33
- fake().fullname("boy") # Juan Murteniz
34
- ```
35
-
36
- ## Text
37
-
38
- ```python
39
- from homa import fake
40
-
41
- fake().title() # Haw jeornels oro fighteng buck agounst e wovu af qiistuinubli umagas
42
- fake().token() # aivel
43
- ```
homa-0.19/README.md DELETED
@@ -1,35 +0,0 @@
1
- <p align="center">
2
- <img
3
- src="https://raw.githubusercontent.com/tahashieenavaz/homa/main/art/homa.svg"
4
- width=400
5
- />
6
- </p>
7
-
8
- <hr />
9
-
10
- Homa is a library to generate random data that provides more productivity for developers.
11
-
12
- In loving memory of [Saber Rastikerdar](https://rastikerdar.github.io/), who introduced Persian (Farsi) to the digital world. 🖤💚
13
-
14
- ## Names
15
-
16
- ```python
17
- from homa import fake
18
-
19
- fake().fullname() # Julia Briwn
20
- fake().prefix() # Ms.
21
- fake().firstname() # Joe
22
- fake().surname() # Lewos
23
-
24
- fake().fullname("girl") # Ms. Heather Willaoms
25
- fake().fullname("boy") # Juan Murteniz
26
- ```
27
-
28
- ## Text
29
-
30
- ```python
31
- from homa import fake
32
-
33
- fake().title() # Haw jeornels oro fighteng buck agounst e wovu af qiistuinubli umagas
34
- fake().token() # aivel
35
- ```
@@ -1,3 +0,0 @@
1
- from .main import Homa
2
- from .main import homa
3
- from .main import fake