homa 0.24__tar.gz → 0.25__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.
- {homa-0.24 → homa-0.25}/PKG-INFO +1 -1
- {homa-0.24 → homa-0.25}/homa/__init__.py +3 -1
- {homa-0.24 → homa-0.25}/homa/camera.py +5 -2
- homa-0.25/homa/classes/Image.py +19 -0
- {homa-0.24 → homa-0.25}/homa/classes/Repository.py +13 -5
- homa-0.25/homa/classes/Window.py +115 -0
- homa-0.25/homa/events.py +40 -0
- homa-0.25/homa/helpers/alias.py +18 -0
- {homa-0.24 → homa-0.25}/homa/helpers/kernel.py +1 -1
- homa-0.25/homa/helpers/string.py +16 -0
- homa-0.25/homa/main.py +32 -0
- homa-0.25/homa/shapes.py +50 -0
- {homa-0.24 → homa-0.25}/homa/spaces.py +20 -1
- {homa-0.24 → homa-0.25}/homa.egg-info/PKG-INFO +1 -1
- {homa-0.24 → homa-0.25}/homa.egg-info/SOURCES.txt +3 -2
- homa-0.24/homa/events.py +0 -70
- homa-0.24/homa/filters.py +0 -41
- homa-0.24/homa/helpers/alias.py +0 -14
- homa-0.24/homa/helpers.py +0 -0
- homa-0.24/homa/main.py +0 -74
- homa-0.24/homa/shapes.py +0 -9
- {homa-0.24 → homa-0.25}/LICENSE +0 -0
- {homa-0.24 → homa-0.25}/README.md +0 -0
- {homa-0.24 → homa-0.25}/homa/classes/Collection.py +0 -0
- {homa-0.24 → homa-0.25}/homa/classes/Logger.py +0 -0
- {homa-0.24 → homa-0.25}/homa/classes/__init__.py +0 -0
- {homa-0.24 → homa-0.25}/homa/constants.py +0 -0
- {homa-0.24 → homa-0.25}/homa/helpers/__init__.py +0 -0
- {homa-0.24 → homa-0.25}/homa/helpers/environment.py +0 -0
- {homa-0.24 → homa-0.25}/homa/orientation.py +0 -0
- {homa-0.24 → homa-0.25}/homa.egg-info/dependency_links.txt +0 -0
- {homa-0.24 → homa-0.25}/homa.egg-info/requires.txt +0 -0
- {homa-0.24 → homa-0.25}/homa.egg-info/top_level.txt +0 -0
- {homa-0.24 → homa-0.25}/setup.cfg +0 -0
- {homa-0.24 → homa-0.25}/setup.py +0 -0
- {homa-0.24 → homa-0.25}/tests/__init__.py +0 -0
- {homa-0.24 → homa-0.25}/tests/test_images.py +0 -0
{homa-0.24 → homa-0.25}/PKG-INFO
RENAMED
|
@@ -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
|
-
|
|
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
|
+
)
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
from ..helpers.environment import is_colab
|
|
2
|
+
from ..helpers.string import randomLowercaseString
|
|
2
3
|
|
|
3
4
|
|
|
4
5
|
class RepositoryWrapper:
|
|
5
6
|
def __init__(self):
|
|
6
|
-
self.sigmaX = 0
|
|
7
|
-
self.sigmaY = 0
|
|
8
|
-
|
|
9
7
|
self.directory = "./"
|
|
10
|
-
|
|
11
|
-
self.
|
|
8
|
+
|
|
9
|
+
self.settings = {
|
|
10
|
+
"thickness": 2,
|
|
11
|
+
"color": (0, 0, 0),
|
|
12
|
+
"sigma": [0, 0]
|
|
13
|
+
}
|
|
12
14
|
|
|
13
15
|
if is_colab():
|
|
14
16
|
from google.colab.patches import cv2_imshow as imshow
|
|
@@ -23,5 +25,11 @@ class RepositoryWrapper:
|
|
|
23
25
|
|
|
24
26
|
self.imshow = final_imshow
|
|
25
27
|
|
|
28
|
+
def addImageWithRandomKey(self, image):
|
|
29
|
+
self.addImage(randomLowercaseString(), image)
|
|
30
|
+
|
|
31
|
+
def addImage(self, key, image):
|
|
32
|
+
Repository.images[key] = image
|
|
33
|
+
|
|
26
34
|
|
|
27
35
|
Repository = RepositoryWrapper()
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import numpy
|
|
2
|
+
import cv2
|
|
3
|
+
|
|
4
|
+
from ..helpers.kernel import createKernel
|
|
5
|
+
from ..helpers.string import randomLowercaseString
|
|
6
|
+
|
|
7
|
+
from ..classes.Repository import Repository
|
|
8
|
+
|
|
9
|
+
from ..events import createMouseCallback
|
|
10
|
+
|
|
11
|
+
from typing_extensions import Self
|
|
12
|
+
from typing import List
|
|
13
|
+
|
|
14
|
+
from ..shapes import color
|
|
15
|
+
from ..shapes import stroke
|
|
16
|
+
|
|
17
|
+
from ..main import setting
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class Window:
|
|
21
|
+
def __init__(self, width: int = 300, height: int = 300, image=None, title: str | None = None, channels: int = 3, dtype="uint8") -> None:
|
|
22
|
+
if title is None:
|
|
23
|
+
title = randomLowercaseString(10)
|
|
24
|
+
|
|
25
|
+
if image is None:
|
|
26
|
+
image = numpy.zeros([height, width, channels], dtype=dtype)
|
|
27
|
+
|
|
28
|
+
self.__title = title
|
|
29
|
+
self.__image = image
|
|
30
|
+
self.__events = {}
|
|
31
|
+
|
|
32
|
+
def show(self):
|
|
33
|
+
cv2.namedWindow(self.__title)
|
|
34
|
+
cv2.setMouseCallback(self.__title, createMouseCallback(self.__events))
|
|
35
|
+
Repository.imshow(self.__title, self.__image)
|
|
36
|
+
|
|
37
|
+
def title(self, newTitle: str) -> Self:
|
|
38
|
+
self.__title = newTitle
|
|
39
|
+
return self
|
|
40
|
+
|
|
41
|
+
def update(self, newImage) -> Self:
|
|
42
|
+
self.__image = newImage
|
|
43
|
+
self.refresh()
|
|
44
|
+
return self
|
|
45
|
+
|
|
46
|
+
def click(self, handler: callable) -> Self:
|
|
47
|
+
self.__events["click"] = (handler, self)
|
|
48
|
+
return self
|
|
49
|
+
|
|
50
|
+
def move(self, handler: callable) -> Self:
|
|
51
|
+
self.__events["mousemove"] = (handler, self)
|
|
52
|
+
return self
|
|
53
|
+
|
|
54
|
+
def white(self) -> Self:
|
|
55
|
+
self.__image = numpy.ones([
|
|
56
|
+
self.__image.shape[0],
|
|
57
|
+
self.__image.shape[1],
|
|
58
|
+
self.__image.shape[2]
|
|
59
|
+
]) * (2 ** 8 - 1)
|
|
60
|
+
return self
|
|
61
|
+
|
|
62
|
+
def blur(self, kernel: int | List[int] = (7, 7)) -> Self:
|
|
63
|
+
self.update(cv2.blur(
|
|
64
|
+
self.__image,
|
|
65
|
+
createKernel(kernel),
|
|
66
|
+
))
|
|
67
|
+
|
|
68
|
+
return self
|
|
69
|
+
|
|
70
|
+
def gaussian(self, kernel: int | List[int] = (7, 7)) -> Self:
|
|
71
|
+
self.update(cv2.GaussianBlur(
|
|
72
|
+
self.__image,
|
|
73
|
+
createKernel(kernel),
|
|
74
|
+
setting("sigma")[0],
|
|
75
|
+
setting("sigma")[1],
|
|
76
|
+
))
|
|
77
|
+
|
|
78
|
+
return self
|
|
79
|
+
|
|
80
|
+
def median(self, kernel: int) -> Self:
|
|
81
|
+
self.update(cv2.medianBlur(
|
|
82
|
+
self.__image, kernel
|
|
83
|
+
))
|
|
84
|
+
|
|
85
|
+
return self
|
|
86
|
+
|
|
87
|
+
def refresh(self):
|
|
88
|
+
Repository.imshow(self.__title, self.__image)
|
|
89
|
+
|
|
90
|
+
def circle(self, x: int, y: int, radius: int, circleColor: tuple | None = None, thickness: int | None = None):
|
|
91
|
+
if circleColor is not None:
|
|
92
|
+
color(*circleColor)
|
|
93
|
+
|
|
94
|
+
if thickness is not None:
|
|
95
|
+
stroke(thickness)
|
|
96
|
+
|
|
97
|
+
self.update(cv2.circle(
|
|
98
|
+
self.__image,
|
|
99
|
+
(x, y),
|
|
100
|
+
radius,
|
|
101
|
+
setting("color"),
|
|
102
|
+
setting("thickness")
|
|
103
|
+
))
|
|
104
|
+
|
|
105
|
+
def getImage(self):
|
|
106
|
+
return self.__image
|
|
107
|
+
|
|
108
|
+
def getTitle(self):
|
|
109
|
+
return self.__title
|
|
110
|
+
|
|
111
|
+
def __getattr__(self, key):
|
|
112
|
+
if key == "shape":
|
|
113
|
+
return self.__image.shape
|
|
114
|
+
|
|
115
|
+
return None
|
homa-0.25/homa/events.py
ADDED
|
@@ -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,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.25/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
|
homa-0.25/homa/shapes.py
ADDED
|
@@ -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
|
|
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:
|
|
@@ -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
|
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
|
-
)
|
homa-0.24/homa/helpers/alias.py
DELETED
|
@@ -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)
|
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)
|
{homa-0.24 → homa-0.25}/LICENSE
RENAMED
|
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
|
{homa-0.24 → homa-0.25}/setup.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|