homa 0.24__tar.gz → 0.26__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.

Potentially problematic release.


This version of homa might be problematic. Click here for more details.

Files changed (39) hide show
  1. {homa-0.24 → homa-0.26}/PKG-INFO +1 -1
  2. {homa-0.24 → homa-0.26}/homa/__init__.py +3 -1
  3. {homa-0.24 → homa-0.26}/homa/camera.py +5 -2
  4. homa-0.26/homa/classes/Image.py +19 -0
  5. homa-0.26/homa/classes/Repository.py +35 -0
  6. homa-0.26/homa/classes/Window.py +119 -0
  7. homa-0.26/homa/events.py +40 -0
  8. homa-0.26/homa/helpers/alias.py +18 -0
  9. homa-0.26/homa/helpers/environment.py +9 -0
  10. {homa-0.24 → homa-0.26}/homa/helpers/kernel.py +1 -1
  11. homa-0.26/homa/helpers/string.py +16 -0
  12. homa-0.26/homa/main.py +32 -0
  13. homa-0.26/homa/shapes.py +50 -0
  14. {homa-0.24 → homa-0.26}/homa/spaces.py +20 -1
  15. {homa-0.24 → homa-0.26}/homa.egg-info/PKG-INFO +1 -1
  16. {homa-0.24 → homa-0.26}/homa.egg-info/SOURCES.txt +3 -2
  17. homa-0.24/homa/classes/Repository.py +0 -27
  18. homa-0.24/homa/events.py +0 -70
  19. homa-0.24/homa/filters.py +0 -41
  20. homa-0.24/homa/helpers/alias.py +0 -14
  21. homa-0.24/homa/helpers/environment.py +0 -5
  22. homa-0.24/homa/helpers.py +0 -0
  23. homa-0.24/homa/main.py +0 -74
  24. homa-0.24/homa/shapes.py +0 -9
  25. {homa-0.24 → homa-0.26}/LICENSE +0 -0
  26. {homa-0.24 → homa-0.26}/README.md +0 -0
  27. {homa-0.24 → homa-0.26}/homa/classes/Collection.py +0 -0
  28. {homa-0.24 → homa-0.26}/homa/classes/Logger.py +0 -0
  29. {homa-0.24 → homa-0.26}/homa/classes/__init__.py +0 -0
  30. {homa-0.24 → homa-0.26}/homa/constants.py +0 -0
  31. {homa-0.24 → homa-0.26}/homa/helpers/__init__.py +0 -0
  32. {homa-0.24 → homa-0.26}/homa/orientation.py +0 -0
  33. {homa-0.24 → homa-0.26}/homa.egg-info/dependency_links.txt +0 -0
  34. {homa-0.24 → homa-0.26}/homa.egg-info/requires.txt +0 -0
  35. {homa-0.24 → homa-0.26}/homa.egg-info/top_level.txt +0 -0
  36. {homa-0.24 → homa-0.26}/setup.cfg +0 -0
  37. {homa-0.24 → homa-0.26}/setup.py +0 -0
  38. {homa-0.24 → homa-0.26}/tests/__init__.py +0 -0
  39. {homa-0.24 → homa-0.26}/tests/test_images.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: homa
3
- Version: 0.24
3
+ Version: 0.26
4
4
  Maintainer: Taha Shieenavaz
5
5
  Maintainer-email: tahashieenavaz@gmail.com
6
6
  Description-Content-Type: text/markdown
@@ -1,5 +1,4 @@
1
1
  from .main import *
2
- from .filters import *
3
2
  from .camera import *
4
3
  from .orientation import *
5
4
  from .spaces import *
@@ -7,3 +6,6 @@ from .events import *
7
6
  from .shapes import *
8
7
 
9
8
  from .helpers import *
9
+
10
+ from .classes.Window import Window
11
+ from .classes.Image import Image
@@ -1,15 +1,18 @@
1
1
  import cv2
2
- from .classes.Repository import Repository
3
2
  from typing import Iterator
3
+ from .classes.Repository import Repository
4
+ from .classes.Window import Window
4
5
 
5
6
 
6
7
  def camera(delay: int = 10, exit_on: str = "q") -> Iterator[int]:
8
+ cameraWindow = Window(640, 480)
9
+
7
10
  pressed_key = None
8
11
  capture = cv2.VideoCapture(0)
9
12
  frame_number = 0
10
13
  while pressed_key != ord(exit_on):
11
14
  _, frame = capture.read()
12
- Repository.images["camera"] = frame
15
+ cameraWindow.update(frame)
13
16
 
14
17
  frame_number += 1
15
18
  yield frame_number
@@ -0,0 +1,19 @@
1
+ from .Window import Window
2
+ from ..helpers.string import randomLowercaseString
3
+ import cv2
4
+
5
+
6
+ class Image(Window):
7
+ def __init__(self, filename: str | Window):
8
+ if isinstance(filename, Window):
9
+ image = filename.getImage()
10
+ title = f"{filename.getTitle()} Cloned"
11
+
12
+ elif isinstance(filename, str):
13
+ image = cv2.imread(filename)
14
+ title = filename
15
+
16
+ super().__init__(
17
+ image=image,
18
+ title=title
19
+ )
@@ -0,0 +1,35 @@
1
+ from ..helpers.environment import isColab
2
+ from ..helpers.string import randomLowercaseString
3
+
4
+
5
+ class RepositoryWrapper:
6
+ def __init__(self):
7
+ self.directory = "./"
8
+
9
+ self.settings = {
10
+ "thickness": 2,
11
+ "color": (0, 0, 0),
12
+ "sigma": [0, 0]
13
+ }
14
+
15
+ if isColab():
16
+ from google.colab.patches import cv2_imshow as imshow
17
+ else:
18
+ from cv2 import imshow
19
+
20
+ def final_imshow(window, image):
21
+ if isColab():
22
+ imshow(image)
23
+ else:
24
+ imshow(window, image)
25
+
26
+ self.imshow = final_imshow
27
+
28
+ def addImageWithRandomKey(self, image):
29
+ self.addImage(randomLowercaseString(), image)
30
+
31
+ def addImage(self, key, image):
32
+ Repository.images[key] = image
33
+
34
+
35
+ Repository = RepositoryWrapper()
@@ -0,0 +1,119 @@
1
+ import numpy
2
+ import cv2
3
+
4
+ from ..helpers.kernel import createKernel
5
+ from ..helpers.string import randomLowercaseString
6
+ from ..helpers.environment import isNotColab
7
+
8
+ from ..classes.Repository import Repository
9
+
10
+ from ..events import createMouseCallback
11
+
12
+ from typing_extensions import Self
13
+ from typing import List
14
+
15
+ from ..shapes import color
16
+ from ..shapes import stroke
17
+
18
+ from ..main import setting
19
+
20
+
21
+ class Window:
22
+ def __init__(self, width: int = 300, height: int = 300, image=None, title: str | None = None, channels: int = 3, dtype="uint8") -> None:
23
+ if title is None:
24
+ title = randomLowercaseString(10)
25
+
26
+ if image is None:
27
+ image = numpy.zeros([height, width, channels], dtype=dtype)
28
+
29
+ self.__title = title
30
+ self.__image = image
31
+ self.__events = {}
32
+
33
+ def show(self):
34
+ if isNotColab():
35
+ cv2.namedWindow(self.__title)
36
+ cv2.setMouseCallback(
37
+ self.__title, createMouseCallback(self.__events))
38
+
39
+ Repository.imshow(self.__title, self.__image)
40
+
41
+ def title(self, newTitle: str) -> Self:
42
+ self.__title = newTitle
43
+ return self
44
+
45
+ def update(self, newImage) -> Self:
46
+ self.__image = newImage
47
+ self.refresh()
48
+ return self
49
+
50
+ def click(self, handler: callable) -> Self:
51
+ self.__events["click"] = (handler, self)
52
+ return self
53
+
54
+ def move(self, handler: callable) -> Self:
55
+ self.__events["mousemove"] = (handler, self)
56
+ return self
57
+
58
+ def white(self) -> Self:
59
+ self.__image = numpy.ones([
60
+ self.__image.shape[0],
61
+ self.__image.shape[1],
62
+ self.__image.shape[2]
63
+ ]) * (2 ** 8 - 1)
64
+ return self
65
+
66
+ def blur(self, kernel: int | List[int] = (7, 7)) -> Self:
67
+ self.update(cv2.blur(
68
+ self.__image,
69
+ createKernel(kernel),
70
+ ))
71
+
72
+ return self
73
+
74
+ def gaussian(self, kernel: int | List[int] = (7, 7)) -> Self:
75
+ self.update(cv2.GaussianBlur(
76
+ self.__image,
77
+ createKernel(kernel),
78
+ setting("sigma")[0],
79
+ setting("sigma")[1],
80
+ ))
81
+
82
+ return self
83
+
84
+ def median(self, kernel: int) -> Self:
85
+ self.update(cv2.medianBlur(
86
+ self.__image, kernel
87
+ ))
88
+
89
+ return self
90
+
91
+ def refresh(self):
92
+ Repository.imshow(self.__title, self.__image)
93
+
94
+ def circle(self, x: int, y: int, radius: int, circleColor: tuple | None = None, thickness: int | None = None):
95
+ if circleColor is not None:
96
+ color(*circleColor)
97
+
98
+ if thickness is not None:
99
+ stroke(thickness)
100
+
101
+ self.update(cv2.circle(
102
+ self.__image,
103
+ (x, y),
104
+ radius,
105
+ setting("color"),
106
+ setting("thickness")
107
+ ))
108
+
109
+ def getImage(self):
110
+ return self.__image
111
+
112
+ def getTitle(self):
113
+ return self.__title
114
+
115
+ def __getattr__(self, key):
116
+ if key == "shape":
117
+ return self.__image.shape
118
+
119
+ return None
@@ -0,0 +1,40 @@
1
+ import cv2
2
+ from inspect import signature
3
+ from .classes.Repository import Repository
4
+
5
+ event_map = {
6
+ "click": cv2.EVENT_LBUTTONDOWN,
7
+ "rclick": cv2.EVENT_RBUTTONDOWN,
8
+ "mclick": cv2.EVENT_MBUTTONDOWN,
9
+ "mouseup": cv2.EVENT_LBUTTONUP,
10
+ "rmouseup": cv2.EVENT_RBUTTONUP,
11
+ "dblclick": cv2.EVENT_LBUTTONDBLCLK,
12
+ "rdblclick": cv2.EVENT_RBUTTONDBLCLK,
13
+ "mousemove": cv2.EVENT_MOUSEMOVE
14
+ }
15
+
16
+
17
+ def createMouseCallback(events: dict):
18
+ def innerMouseCallback(event, x, y, flags, param):
19
+ for e, values in events.items():
20
+ if event != event_map[e]:
21
+ continue
22
+
23
+ handler, context = values
24
+ argumentCount = len(signature(handler).parameters)
25
+ if argumentCount == 2:
26
+ args = (x, y)
27
+ elif argumentCount == 3:
28
+ args = (x, y, context)
29
+ elif argumentCount == 4:
30
+ args = (x, y, context, flags)
31
+ elif argumentCount == 5:
32
+ args = (x, y, context, flags, param)
33
+ elif argumentCount == 1:
34
+ args = (context,)
35
+ elif args == 0:
36
+ args = tuple()
37
+
38
+ handler(*args)
39
+
40
+ return innerMouseCallback
@@ -0,0 +1,18 @@
1
+ from ..classes.Repository import Repository
2
+ from ..classes.Collection import Collection
3
+ from typing import List
4
+
5
+
6
+ def repo(key: str | None = None, value: any = None) -> any:
7
+ if key is None and value is None:
8
+ return Repository.images
9
+
10
+ if key is not None and value is None:
11
+ return Repository.addImage(key, value)
12
+
13
+ Repository.addImage(key, value)
14
+ return True
15
+
16
+
17
+ def collection(items: List[any]):
18
+ return Collection(items)
@@ -0,0 +1,9 @@
1
+ import sys
2
+
3
+
4
+ def isColab() -> bool:
5
+ return 'google.colab' in sys.modules
6
+
7
+
8
+ def isNotColab() -> bool:
9
+ return not isColab()
@@ -1,7 +1,7 @@
1
1
  from typing import Tuple
2
2
 
3
3
 
4
- def create_kernel(value: int | Tuple[int, int]) -> Tuple[int, int]:
4
+ def createKernel(value: int | Tuple[int, int]) -> Tuple[int, int]:
5
5
  if isinstance(value, tuple):
6
6
  x, y = value
7
7
 
@@ -0,0 +1,16 @@
1
+ import numpy
2
+ import string
3
+
4
+
5
+ def randomLowercaseString(length: int = 10):
6
+ return randomString(length, string.ascii_lowercase)
7
+
8
+
9
+ def randomUppercaseString(length: int = 10):
10
+ return randomString(length, string.ascii_uppercase)
11
+
12
+
13
+ def randomString(length: int = 10, letters: str = string.ascii_letters):
14
+ return "".join(
15
+ numpy.random.choice(list(letters), length)
16
+ )
homa-0.26/homa/main.py ADDED
@@ -0,0 +1,32 @@
1
+ import cv2
2
+ from .classes.Repository import Repository
3
+
4
+
5
+ def destroy(key: str | None = None) -> None:
6
+ if key is not None:
7
+ cv2.destroyWindow(key)
8
+ return
9
+
10
+ cv2.destroyAllWindows()
11
+
12
+
13
+ def show(*windows, **settings):
14
+ for window in windows:
15
+ window.show()
16
+
17
+ if settings["wait"] == True:
18
+ cv2.waitKey()
19
+
20
+
21
+ def showWait(*args, **kwargs):
22
+ kwargs["wait"] = True
23
+ show(*args, **kwargs)
24
+
25
+
26
+ def setting(key: str, value: any = None) -> any:
27
+ if value is not None:
28
+ Repository.settings[key] = value
29
+ return True
30
+
31
+ setting_value = Repository.settings[key]
32
+ return setting_value if setting_value else None
@@ -0,0 +1,50 @@
1
+ import cv2
2
+ from .main import setting
3
+ from .helpers.alias import repo
4
+ from typing import Tuple
5
+ import numpy
6
+
7
+
8
+ def stroke(value: int = 1):
9
+ setting("thickness", value)
10
+
11
+
12
+ def fill(*args):
13
+ setting("thickness", -1)
14
+
15
+ if len(args) == 3:
16
+ color(*args)
17
+
18
+
19
+ def randomColor() -> Tuple[int, int, int]:
20
+ r = numpy.random.randint(0, 255)
21
+ g = numpy.random.randint(0, 255)
22
+ b = numpy.random.randint(0, 255)
23
+
24
+ return (b, g, r)
25
+
26
+
27
+ def color(*args):
28
+ if len(args) == 1 and isinstance(args[0], str) and args[0] in ["random", "rand"]:
29
+ args = randomColor()
30
+
31
+ setting("color", args)
32
+
33
+
34
+ def circle(key: str, x: int, y: int, radius: int = 1):
35
+ cv2.circle(
36
+ repo(key),
37
+ (x, y),
38
+ radius,
39
+ setting("color"),
40
+ setting("thickness")
41
+ )
42
+
43
+
44
+ def rect(key: str, x: int, y: int, width: int, height: int):
45
+ cv2.rectangle(
46
+ repo(key),
47
+ (x - width // 2, y - height // 2), (x + width // 2, y + height // 2),
48
+ thickness=setting("thickness"),
49
+ color=setting("color")
50
+ )
@@ -1,8 +1,24 @@
1
1
  from typing import Tuple
2
2
  from .helpers.alias import repo
3
+ import cv2
3
4
 
4
5
 
5
- def rgb(key: str) -> Tuple[int, int, int]:
6
+ def hsv(key: str):
7
+ image = repo(key)
8
+ cv2.cvtColor(image, cv2.COLOR_BGR2HSV)
9
+
10
+ h = image[:, :, 0]
11
+ s = image[:, :, 1]
12
+ v = image[:, :, 2]
13
+
14
+ return (h, s, v)
15
+
16
+
17
+ def bgr(key: str) -> Tuple[int, int, int]:
18
+ return rgb(key, bgr_flag=True)
19
+
20
+
21
+ def rgb(key: str, bgr_flag: bool = False) -> Tuple[int, int, int]:
6
22
  image = repo(key)
7
23
 
8
24
  if image.shape[2] == 3:
@@ -13,6 +29,9 @@ def rgb(key: str) -> Tuple[int, int, int]:
13
29
  g = image[:, :, 0]
14
30
  r = image[:, :, 0]
15
31
 
32
+ if bgr_flag:
33
+ return (b, g, r)
34
+
16
35
  return (r, g, b)
17
36
 
18
37
  if image.shape[2] == 1:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: homa
3
- Version: 0.24
3
+ Version: 0.26
4
4
  Maintainer: Taha Shieenavaz
5
5
  Maintainer-email: tahashieenavaz@gmail.com
6
6
  Description-Content-Type: text/markdown
@@ -5,8 +5,6 @@ homa/__init__.py
5
5
  homa/camera.py
6
6
  homa/constants.py
7
7
  homa/events.py
8
- homa/filters.py
9
- homa/helpers.py
10
8
  homa/main.py
11
9
  homa/orientation.py
12
10
  homa/shapes.py
@@ -17,12 +15,15 @@ homa.egg-info/dependency_links.txt
17
15
  homa.egg-info/requires.txt
18
16
  homa.egg-info/top_level.txt
19
17
  homa/classes/Collection.py
18
+ homa/classes/Image.py
20
19
  homa/classes/Logger.py
21
20
  homa/classes/Repository.py
21
+ homa/classes/Window.py
22
22
  homa/classes/__init__.py
23
23
  homa/helpers/__init__.py
24
24
  homa/helpers/alias.py
25
25
  homa/helpers/environment.py
26
26
  homa/helpers/kernel.py
27
+ homa/helpers/string.py
27
28
  tests/__init__.py
28
29
  tests/test_images.py
@@ -1,27 +0,0 @@
1
- from ..helpers.environment 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.windows = {}
12
-
13
- if is_colab():
14
- from google.colab.patches import cv2_imshow as imshow
15
- else:
16
- from cv2 import imshow
17
-
18
- def final_imshow(window, image):
19
- if is_colab():
20
- imshow(image)
21
- else:
22
- imshow(window, image)
23
-
24
- self.imshow = final_imshow
25
-
26
-
27
- Repository = RepositoryWrapper()
homa-0.24/homa/events.py DELETED
@@ -1,70 +0,0 @@
1
- # enum MouseEventTypes
2
- # {
3
- # EVENT_MOUSEMOVE = 0,
4
- # EVENT_LBUTTONDOWN = 1,
5
- # EVENT_RBUTTONDOWN = 2,
6
- # EVENT_MBUTTONDOWN = 3,
7
- # EVENT_LBUTTONUP = 4,
8
- # EVENT_RBUTTONUP = 5,
9
- # EVENT_MBUTTONUP = 6,
10
- # EVENT_LBUTTONDBLCLK = 7,
11
- # EVENT_RBUTTONDBLCLK = 8,
12
- # EVENT_MBUTTONDBLCLK = 9,
13
- # EVENT_MOUSEWHEEL = 10,
14
- # EVENT_MOUSEHWHEEL = 11,
15
- # };
16
- import cv2
17
- from .main import win
18
- from inspect import signature
19
-
20
- event_map = {
21
- "click": cv2.EVENT_LBUTTONDOWN,
22
- "rclick": cv2.EVENT_RBUTTONDOWN,
23
- "mclick": cv2.EVENT_MBUTTONDOWN,
24
- "mouseup": cv2.EVENT_LBUTTONUP,
25
- "rmouseup": cv2.EVENT_RBUTTONUP,
26
- "dblclick": cv2.EVENT_LBUTTONDBLCLK,
27
- "rdblclick": cv2.EVENT_RBUTTONDBLCLK,
28
- "move": cv2.EVENT_MOUSEMOVE
29
- }
30
-
31
-
32
- def create_wrapper_function(event_name: str, handler: callable):
33
- def wrapper_function(event, x, y, flags, param):
34
- if event != event_map[event_name]:
35
- return
36
-
37
- argument_count = len(signature(handler).parameters)
38
- if argument_count == 2:
39
- handler(x, y)
40
- elif argument_count == 3:
41
- handler(x, y, flags)
42
- elif argument_count == 4:
43
- handler(x, y, flags, param)
44
-
45
- return wrapper_function
46
-
47
-
48
- def onClick(key: str, handler: callable):
49
- win(key)
50
- cv2.setMouseCallback(key, create_wrapper_function("click", handler))
51
-
52
-
53
- def onRightClick(key: str, handler: callable):
54
- win(key)
55
- cv2.setMouseCallback(key, create_wrapper_function("rclick", handler))
56
-
57
-
58
- def onMouseUp(key: str, handler: callable):
59
- win(key)
60
- cv2.setMouseCallback(key, create_wrapper_function("mouseup", handler))
61
-
62
-
63
- def onMove(key: str, handler: callable):
64
- win(key)
65
- cv2.setMouseCallback(key, create_wrapper_function("mousemove", handler))
66
-
67
-
68
- def onDoubleClick(key: str, handler: callable):
69
- win(key)
70
- cv2.setMouseCallback(key, create_wrapper_function("dblclick", handler))
homa-0.24/homa/filters.py DELETED
@@ -1,41 +0,0 @@
1
- from typing import List
2
- from .classes.Repository import Repository
3
- from .helpers.kernel import create_kernel
4
- import cv2
5
-
6
-
7
- def blur(key: str, kernel: int | List[int] = (7, 7), new_key: str | None = 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 median(key: str, kernel: int | List[int] = (7, 7), new_key: str | None = None) -> None:
18
- if new_key is None:
19
- new_key = key
20
-
21
- Repository.images[new_key] = cv2.medianBlur(
22
- Repository.images[key],
23
- create_kernel(kernel)
24
- )
25
-
26
-
27
- def sigma(x: float = 0, y: float = 0) -> None:
28
- Repository.sigmaX = x
29
- Repository.sigmaY = y
30
-
31
-
32
- def gaussian(key: str, kernel: None | List[int] = None, new_key: str | None = None) -> None:
33
- if new_key is None:
34
- new_key = key
35
-
36
- Repository.images[new_key] = cv2.GaussianBlur(
37
- Repository.images[key],
38
- create_kernel(kernel),
39
- sigmaX=Repository.sigmaX,
40
- sigmaY=Repository.sigmaY
41
- )
@@ -1,14 +0,0 @@
1
- from ..classes.Repository import Repository
2
- from ..classes.Collection import Collection
3
- from typing import List
4
-
5
-
6
- def repo(key: str | None = None):
7
- if key is None:
8
- return Repository.images
9
-
10
- return Repository.images[key]
11
-
12
-
13
- def collection(items: List[any]):
14
- return Collection(items)
@@ -1,5 +0,0 @@
1
- import sys
2
-
3
-
4
- def is_colab() -> bool:
5
- return 'google.colab' in sys.modules
homa-0.24/homa/helpers.py DELETED
File without changes
homa-0.24/homa/main.py DELETED
@@ -1,74 +0,0 @@
1
- import cv2
2
- from .classes.Logger import Logger
3
- from .classes.Repository import Repository
4
-
5
-
6
- def destroy(key: str | None = None) -> None:
7
- if key is not None:
8
- cv2.destroyWindow(key)
9
- return
10
-
11
- cv2.destroyAllWindows()
12
-
13
-
14
- def win(key: str):
15
- cv2.namedWindow(key)
16
-
17
-
18
- def path(directory: str) -> None:
19
- Repository.directory = directory
20
-
21
-
22
- def write(key: str, filename: str) -> None:
23
- cv2.imwrite(
24
- filename=filename,
25
- img=Repository.images[key]
26
- )
27
-
28
-
29
- def save(*args, **kwargs) -> None:
30
- write(args, kwargs)
31
-
32
-
33
- def image(filename: str, key: str | None = None, color: bool = True) -> None:
34
- # TODO: add no extension in the file
35
- if key is None:
36
- key = filename.split(".")[0]
37
-
38
- Repository.images[key] = cv2.imread(filename, int(color))
39
- return Repository.images[key]
40
-
41
-
42
- def wait(delay=0):
43
- cv2.waitKey(delay)
44
-
45
-
46
- def showWait(*args, **kwargs):
47
- kwargs["wait"] = True
48
- show(*args, **kwargs)
49
-
50
-
51
- def show(key: any = None, wait: bool = False, window: str = "Homa Window") -> None:
52
- # TODO: add functionality to distinguish between camera and images
53
-
54
- if key is not None and not isinstance(key, str):
55
- Repository.imshow(window, key)
56
-
57
- elif key is None:
58
- for key, image in Repository.images.items():
59
- Repository.imshow(key, image)
60
- Repository.windows[key] = key
61
-
62
- elif key is not None:
63
- if key in Repository.images:
64
- Repository.imshow(key, Repository.images[key])
65
- Repository.windows[key] = key
66
- else:
67
- Logger.danger(f"No image found with key {key}")
68
-
69
- if wait:
70
- cv2.waitKey(0)
71
-
72
-
73
- def refresh(key: str) -> None:
74
- cv2.imshow(Repository.windows[key], Repository.images[key])
homa-0.24/homa/shapes.py DELETED
@@ -1,9 +0,0 @@
1
- import cv2
2
- from .main import refresh
3
- from .helpers.alias import repo
4
- from .classes.Repository import Repository
5
-
6
-
7
- def circle(key: str, x: int = 0, y: int = 0, r: int = 1, color=(0, 0, 255), thickness: int = 1):
8
- cv2.circle(repo(key), (x, y), r, color, thickness)
9
- refresh(key)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes