@camera.ui/camera-ui-opencv 0.0.1 → 0.0.3
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.
- package/package.json +2 -2
- package/requirements.txt +2 -2
- package/src/camera_detector.py +27 -27
- package/src/defaults.py +13 -0
- package/src/types.py +28 -0
- package/requirements-lock.txt +0 -6
- package/ruff.toml +0 -90
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "OpenCV",
|
|
3
3
|
"name": "@camera.ui/camera-ui-opencv",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.3",
|
|
5
5
|
"description": "camera.ui opencv plugin",
|
|
6
6
|
"author": "seydx (https://github.com/seydx/camera.ui)",
|
|
7
7
|
"main": "./src/main.py",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"updates": "^16.
|
|
18
|
+
"updates": "^16.4.0"
|
|
19
19
|
},
|
|
20
20
|
"bugs": {
|
|
21
21
|
"url": "https://github.com/seydx/camera.ui/issues"
|
package/requirements.txt
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
numpy==1.26.4
|
|
2
|
-
opencv-python==4.10.0.84
|
|
3
|
-
camera-ui-python-types==0.1.
|
|
2
|
+
opencv-python-headless==4.10.0.84
|
|
3
|
+
camera-ui-python-types==0.1.78
|
package/src/camera_detector.py
CHANGED
|
@@ -14,22 +14,20 @@ from camera_ui_python_types import (
|
|
|
14
14
|
)
|
|
15
15
|
from opencv_utils import get_detections, get_detections_bs, get_detections_fd
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
defaultAreaFd
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
defaultReferenceFrameFrequency = 5
|
|
17
|
+
from .defaults import (
|
|
18
|
+
available_models,
|
|
19
|
+
defaultArea,
|
|
20
|
+
defaultAreaBs,
|
|
21
|
+
defaultAreaFd,
|
|
22
|
+
defaultBlur,
|
|
23
|
+
defaultDilt,
|
|
24
|
+
defaultReferenceFrameFrequency,
|
|
25
|
+
defaultThreshold,
|
|
26
|
+
defaultThresholdBs,
|
|
27
|
+
)
|
|
28
|
+
from .types import CameraStorageValues
|
|
31
29
|
|
|
32
|
-
|
|
30
|
+
background_tasks = set[asyncio.Task[Any]]()
|
|
33
31
|
|
|
34
32
|
|
|
35
33
|
class CameraDetector:
|
|
@@ -45,7 +43,7 @@ class CameraDetector:
|
|
|
45
43
|
self.frame_generation_task = None
|
|
46
44
|
self.executor = None
|
|
47
45
|
|
|
48
|
-
self.camera_storage = self.__create_camera_storage()
|
|
46
|
+
self.camera_storage: CameraStorage[CameraStorageValues] = self.__create_camera_storage()
|
|
49
47
|
self.camera.on_connected.subscribe(lambda connected: self.start() if connected else self.close())
|
|
50
48
|
|
|
51
49
|
def start(self) -> None:
|
|
@@ -201,8 +199,10 @@ class CameraDetector:
|
|
|
201
199
|
def __detector_model(self) -> Literal["Frame Difference", "Background Substraction", "Default"]:
|
|
202
200
|
return self.camera_storage.values["motion_detector"]
|
|
203
201
|
|
|
204
|
-
def __create_camera_storage(self) -> CameraStorage:
|
|
205
|
-
camera_storage =
|
|
202
|
+
def __create_camera_storage(self) -> CameraStorage[CameraStorageValues]:
|
|
203
|
+
camera_storage: Optional[CameraStorage[CameraStorageValues]] = (
|
|
204
|
+
self.api.storage_controller.get_camera_storage(self.camera.id)
|
|
205
|
+
)
|
|
206
206
|
|
|
207
207
|
if camera_storage is not None:
|
|
208
208
|
return camera_storage
|
|
@@ -402,11 +402,11 @@ class CameraDetector:
|
|
|
402
402
|
current_model_schema = None
|
|
403
403
|
|
|
404
404
|
if current_model == "Default":
|
|
405
|
-
current_model_schema = camera_storage.
|
|
405
|
+
current_model_schema = camera_storage.getSchema("default")
|
|
406
406
|
elif current_model == "Background Substraction":
|
|
407
|
-
current_model_schema = camera_storage.
|
|
407
|
+
current_model_schema = camera_storage.getSchema("background_substraction")
|
|
408
408
|
elif current_model == "Frame Difference":
|
|
409
|
-
current_model_schema = camera_storage.
|
|
409
|
+
current_model_schema = camera_storage.getSchema("frame_difference")
|
|
410
410
|
|
|
411
411
|
if current_model_schema:
|
|
412
412
|
current_model_schema["hidden"] = False
|
|
@@ -420,18 +420,18 @@ class CameraDetector:
|
|
|
420
420
|
new_schema = None
|
|
421
421
|
|
|
422
422
|
if old_model == "Default":
|
|
423
|
-
old_schema = self.camera_storage.
|
|
423
|
+
old_schema = self.camera_storage.getSchema("default")
|
|
424
424
|
elif old_model == "Background Substraction":
|
|
425
|
-
old_schema = self.camera_storage.
|
|
425
|
+
old_schema = self.camera_storage.getSchema("background_substraction")
|
|
426
426
|
elif old_model == "Frame Difference":
|
|
427
|
-
old_schema = self.camera_storage.
|
|
427
|
+
old_schema = self.camera_storage.getSchema("frame_difference")
|
|
428
428
|
|
|
429
429
|
if new_model == "Default":
|
|
430
|
-
new_schema = self.camera_storage.
|
|
430
|
+
new_schema = self.camera_storage.getSchema("default")
|
|
431
431
|
elif new_model == "Background Substraction":
|
|
432
|
-
new_schema = self.camera_storage.
|
|
432
|
+
new_schema = self.camera_storage.getSchema("background_substraction")
|
|
433
433
|
elif new_model == "Frame Difference":
|
|
434
|
-
new_schema = self.camera_storage.
|
|
434
|
+
new_schema = self.camera_storage.getSchema("frame_difference")
|
|
435
435
|
|
|
436
436
|
if old_schema:
|
|
437
437
|
old_schema["hidden"] = True
|
package/src/defaults.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
defaultArea = 250
|
|
2
|
+
defaultAreaFd = 500
|
|
3
|
+
defaultAreaBs = 500
|
|
4
|
+
|
|
5
|
+
defaultThreshold = 50
|
|
6
|
+
defaultThresholdBs = 200
|
|
7
|
+
|
|
8
|
+
defaultBlur = 9
|
|
9
|
+
defaultDilt = 3
|
|
10
|
+
|
|
11
|
+
defaultReferenceFrameFrequency = 5
|
|
12
|
+
|
|
13
|
+
available_models = ["Frame Difference", "Background Substraction", "Default"]
|
package/src/types.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
from typing import Literal, TypedDict
|
|
2
|
+
|
|
3
|
+
Detectors = Literal["Frame Difference", "Background Substraction", "Default"]
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class DefaultModelValues(TypedDict):
|
|
7
|
+
area: int
|
|
8
|
+
threshold: int
|
|
9
|
+
blur: int
|
|
10
|
+
dilation: int
|
|
11
|
+
reference_frame_frequency: int
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class BackgroundSubstractionValues(TypedDict):
|
|
15
|
+
area: int
|
|
16
|
+
threshold: int
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class FrameDifferenceValues(TypedDict):
|
|
20
|
+
area: int
|
|
21
|
+
reference_frame_frequency: int
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class CameraStorageValues(TypedDict):
|
|
25
|
+
motion_detector: Detectors
|
|
26
|
+
default: DefaultModelValues
|
|
27
|
+
background_substraction: BackgroundSubstractionValues
|
|
28
|
+
frame_difference: FrameDifferenceValues
|
package/requirements-lock.txt
DELETED
package/ruff.toml
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
# Exclude a variety of commonly ignored directories.
|
|
2
|
-
exclude = [
|
|
3
|
-
".bzr",
|
|
4
|
-
".direnv",
|
|
5
|
-
".eggs",
|
|
6
|
-
".git",
|
|
7
|
-
".git-rewrite",
|
|
8
|
-
".hg",
|
|
9
|
-
".ipynb_checkpoints",
|
|
10
|
-
".mypy_cache",
|
|
11
|
-
".nox",
|
|
12
|
-
".pants.d",
|
|
13
|
-
".pyenv",
|
|
14
|
-
".pytest_cache",
|
|
15
|
-
".pytype",
|
|
16
|
-
".ruff_cache",
|
|
17
|
-
".svn",
|
|
18
|
-
".tox",
|
|
19
|
-
".venv",
|
|
20
|
-
".vscode",
|
|
21
|
-
"__pypackages__",
|
|
22
|
-
"_build",
|
|
23
|
-
"buck-out",
|
|
24
|
-
"build",
|
|
25
|
-
"dist",
|
|
26
|
-
"node_modules",
|
|
27
|
-
"site-packages",
|
|
28
|
-
"venv",
|
|
29
|
-
]
|
|
30
|
-
|
|
31
|
-
# Same as Black.
|
|
32
|
-
line-length = 110
|
|
33
|
-
indent-width = 4
|
|
34
|
-
|
|
35
|
-
# Assume Python 3.8
|
|
36
|
-
target-version = "py39"
|
|
37
|
-
|
|
38
|
-
[lint]
|
|
39
|
-
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
|
|
40
|
-
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
|
|
41
|
-
# McCabe complexity (`C901`) by default.
|
|
42
|
-
select = [
|
|
43
|
-
# pycodestyle
|
|
44
|
-
"E",
|
|
45
|
-
# Pyflakes
|
|
46
|
-
"F",
|
|
47
|
-
# pyupgrade
|
|
48
|
-
"UP",
|
|
49
|
-
# flake8-bugbear
|
|
50
|
-
"B",
|
|
51
|
-
# flake8-simplify
|
|
52
|
-
"SIM",
|
|
53
|
-
# isort
|
|
54
|
-
"I",
|
|
55
|
-
]
|
|
56
|
-
ignore = ["E501", "B023", "B006"]
|
|
57
|
-
|
|
58
|
-
# Allow fix for all enabled rules (when `--fix`) is provided.
|
|
59
|
-
fixable = ["ALL"]
|
|
60
|
-
unfixable = []
|
|
61
|
-
|
|
62
|
-
# Allow unused variables when underscore-prefixed.
|
|
63
|
-
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
|
|
64
|
-
|
|
65
|
-
[format]
|
|
66
|
-
# Like Black, use double quotes for strings.
|
|
67
|
-
quote-style = "double"
|
|
68
|
-
|
|
69
|
-
# Like Black, indent with spaces, rather than tabs.
|
|
70
|
-
indent-style = "space"
|
|
71
|
-
|
|
72
|
-
# Like Black, respect magic trailing commas.
|
|
73
|
-
skip-magic-trailing-comma = false
|
|
74
|
-
|
|
75
|
-
# Like Black, automatically detect the appropriate line ending.
|
|
76
|
-
line-ending = "auto"
|
|
77
|
-
|
|
78
|
-
# Enable auto-formatting of code examples in docstrings. Markdown,
|
|
79
|
-
# reStructuredText code/literal blocks and doctests are all supported.
|
|
80
|
-
#
|
|
81
|
-
# This is currently disabled by default, but it is planned for this
|
|
82
|
-
# to be opt-out in the future.
|
|
83
|
-
docstring-code-format = true
|
|
84
|
-
|
|
85
|
-
# Set the line length limit used when formatting code snippets in
|
|
86
|
-
# docstrings.
|
|
87
|
-
#
|
|
88
|
-
# This only has an effect when the `docstring-code-format` setting is
|
|
89
|
-
# enabled.
|
|
90
|
-
docstring-code-line-length = "dynamic"
|