OTVision 0.5.3__py3-none-any.whl
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.
- OTVision/__init__.py +30 -0
- OTVision/application/__init__.py +0 -0
- OTVision/application/configure_logger.py +23 -0
- OTVision/application/detect/__init__.py +0 -0
- OTVision/application/detect/get_detect_cli_args.py +9 -0
- OTVision/application/detect/update_detect_config_with_cli_args.py +95 -0
- OTVision/application/get_config.py +25 -0
- OTVision/config.py +754 -0
- OTVision/convert/__init__.py +0 -0
- OTVision/convert/convert.py +318 -0
- OTVision/dataformat.py +70 -0
- OTVision/detect/__init__.py +0 -0
- OTVision/detect/builder.py +48 -0
- OTVision/detect/cli.py +166 -0
- OTVision/detect/detect.py +296 -0
- OTVision/detect/otdet.py +103 -0
- OTVision/detect/plugin_av/__init__.py +0 -0
- OTVision/detect/plugin_av/rotate_frame.py +37 -0
- OTVision/detect/yolo.py +277 -0
- OTVision/domain/__init__.py +0 -0
- OTVision/domain/cli.py +42 -0
- OTVision/helpers/__init__.py +0 -0
- OTVision/helpers/date.py +26 -0
- OTVision/helpers/files.py +538 -0
- OTVision/helpers/formats.py +139 -0
- OTVision/helpers/log.py +131 -0
- OTVision/helpers/machine.py +71 -0
- OTVision/helpers/video.py +54 -0
- OTVision/track/__init__.py +0 -0
- OTVision/track/iou.py +282 -0
- OTVision/track/iou_util.py +140 -0
- OTVision/track/preprocess.py +451 -0
- OTVision/track/track.py +422 -0
- OTVision/transform/__init__.py +0 -0
- OTVision/transform/get_homography.py +156 -0
- OTVision/transform/reference_points_picker.py +462 -0
- OTVision/transform/transform.py +352 -0
- OTVision/version.py +13 -0
- OTVision/view/__init__.py +0 -0
- OTVision/view/helpers/OTC.ico +0 -0
- OTVision/view/view.py +90 -0
- OTVision/view/view_convert.py +128 -0
- OTVision/view/view_detect.py +146 -0
- OTVision/view/view_helpers.py +417 -0
- OTVision/view/view_track.py +131 -0
- OTVision/view/view_transform.py +140 -0
- otvision-0.5.3.dist-info/METADATA +47 -0
- otvision-0.5.3.dist-info/RECORD +50 -0
- otvision-0.5.3.dist-info/WHEEL +4 -0
- otvision-0.5.3.dist-info/licenses/LICENSE +674 -0
OTVision/__init__.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"""
|
|
2
|
+
OTVision init module
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
# Copyright (C) 2022 OpenTrafficCam Contributors
|
|
6
|
+
# <https://github.com/OpenTrafficCam
|
|
7
|
+
# <team@opentrafficcam.org>
|
|
8
|
+
#
|
|
9
|
+
# This program is free software: you can redistribute it and/or modify
|
|
10
|
+
# it under the terms of the GNU General Public License as published by
|
|
11
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
12
|
+
# (at your option) any later version.
|
|
13
|
+
#
|
|
14
|
+
# This program is distributed in the hope that it will be useful,
|
|
15
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17
|
+
# GNU General Public License for more details.
|
|
18
|
+
#
|
|
19
|
+
# You should have received a copy of the GNU General Public License
|
|
20
|
+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
# TODO: Might need to change this
|
|
24
|
+
from .convert.convert import main as convert
|
|
25
|
+
from .track.track import main as track
|
|
26
|
+
from .transform.transform import main as transform
|
|
27
|
+
|
|
28
|
+
# from .view.view import main as view
|
|
29
|
+
|
|
30
|
+
__all__: list = ["track", "convert", "transform"]
|
|
File without changes
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
from logging import Logger
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
from OTVision.config import Config
|
|
6
|
+
from OTVision.helpers.log import LOGGER_NAME, log
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def logger() -> Logger:
|
|
10
|
+
return logging.getLogger(LOGGER_NAME)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class ConfigureLogger:
|
|
14
|
+
def configure(
|
|
15
|
+
self, config: Config, log_file: Path, logfile_overwrite: bool
|
|
16
|
+
) -> Logger:
|
|
17
|
+
log.add_console_handler(level=config.log.log_level_console)
|
|
18
|
+
log.add_file_handler(
|
|
19
|
+
log_file.expanduser(),
|
|
20
|
+
config.log.log_level_file,
|
|
21
|
+
logfile_overwrite,
|
|
22
|
+
)
|
|
23
|
+
return logging.getLogger(LOGGER_NAME)
|
|
File without changes
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
from OTVision.application.detect.get_detect_cli_args import GetDetectCliArgs
|
|
2
|
+
from OTVision.config import Config, DetectConfig, YoloConfig, _LogConfig
|
|
3
|
+
from OTVision.domain.cli import DetectCliArgs
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class UpdateDetectConfigWithCliArgs:
|
|
7
|
+
def __init__(self, get_detect_cli_args: GetDetectCliArgs) -> None:
|
|
8
|
+
self._get_detect_cli_args = get_detect_cli_args
|
|
9
|
+
|
|
10
|
+
def update(self, config: Config) -> Config:
|
|
11
|
+
cli_args = self._get_detect_cli_args.get()
|
|
12
|
+
return Config(
|
|
13
|
+
log=self._update_log_config(config, cli_args),
|
|
14
|
+
search_subdirs=config.search_subdirs,
|
|
15
|
+
default_filetype=config.default_filetype,
|
|
16
|
+
last_paths=config.last_paths,
|
|
17
|
+
convert=config.convert,
|
|
18
|
+
detect=self._update_detect_config(config.detect, cli_args),
|
|
19
|
+
track=config.track,
|
|
20
|
+
undistort=config.undistort,
|
|
21
|
+
transform=config.transform,
|
|
22
|
+
gui=config.gui,
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
def _update_detect_config(
|
|
26
|
+
self, detect_config: DetectConfig, cli_args: DetectCliArgs
|
|
27
|
+
) -> DetectConfig:
|
|
28
|
+
yolo_config = YoloConfig(
|
|
29
|
+
weights=(
|
|
30
|
+
cli_args.weights
|
|
31
|
+
if cli_args.weights is not None
|
|
32
|
+
else detect_config.yolo_config.weights
|
|
33
|
+
),
|
|
34
|
+
available_weights=detect_config.yolo_config.available_weights,
|
|
35
|
+
conf=(
|
|
36
|
+
cli_args.conf
|
|
37
|
+
if cli_args.conf is not None
|
|
38
|
+
else detect_config.yolo_config.conf
|
|
39
|
+
),
|
|
40
|
+
iou=(
|
|
41
|
+
cli_args.iou
|
|
42
|
+
if cli_args.iou is not None
|
|
43
|
+
else detect_config.yolo_config.iou
|
|
44
|
+
),
|
|
45
|
+
img_size=(
|
|
46
|
+
cli_args.imagesize
|
|
47
|
+
if cli_args.imagesize is not None
|
|
48
|
+
else detect_config.yolo_config.img_size
|
|
49
|
+
),
|
|
50
|
+
chunk_size=detect_config.yolo_config.chunk_size,
|
|
51
|
+
normalized=detect_config.yolo_config.normalized,
|
|
52
|
+
)
|
|
53
|
+
return DetectConfig(
|
|
54
|
+
paths=cli_args.paths if cli_args.paths is not None else detect_config.paths,
|
|
55
|
+
yolo_config=yolo_config,
|
|
56
|
+
expected_duration=(
|
|
57
|
+
cli_args.expected_duration
|
|
58
|
+
if cli_args.expected_duration is not None
|
|
59
|
+
else detect_config.expected_duration
|
|
60
|
+
),
|
|
61
|
+
overwrite=(
|
|
62
|
+
cli_args.overwrite
|
|
63
|
+
if cli_args.overwrite is not None
|
|
64
|
+
else detect_config.overwrite
|
|
65
|
+
),
|
|
66
|
+
half_precision=(
|
|
67
|
+
cli_args.half
|
|
68
|
+
if cli_args.half is not None
|
|
69
|
+
else detect_config.half_precision
|
|
70
|
+
),
|
|
71
|
+
detect_start=(
|
|
72
|
+
cli_args.detect_start
|
|
73
|
+
if cli_args.detect_start is not None
|
|
74
|
+
else detect_config.detect_start
|
|
75
|
+
),
|
|
76
|
+
detect_end=(
|
|
77
|
+
cli_args.detect_end
|
|
78
|
+
if cli_args.detect_end is not None
|
|
79
|
+
else detect_config.detect_end
|
|
80
|
+
),
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
def _update_log_config(self, config: Config, cli_args: DetectCliArgs) -> _LogConfig:
|
|
84
|
+
return _LogConfig(
|
|
85
|
+
log_level_console=(
|
|
86
|
+
cli_args.log_level_console
|
|
87
|
+
if cli_args.log_level_console is not None
|
|
88
|
+
else config.log.log_level_console
|
|
89
|
+
),
|
|
90
|
+
log_level_file=(
|
|
91
|
+
cli_args.log_level_file
|
|
92
|
+
if cli_args.log_level_file is not None
|
|
93
|
+
else config.log.log_level_file
|
|
94
|
+
),
|
|
95
|
+
)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
from OTVision.config import Config, ConfigParser
|
|
4
|
+
from OTVision.domain.cli import CliArgs
|
|
5
|
+
|
|
6
|
+
DEFAULT_USER_CONFIG = "user_config.otvision.yaml"
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class GetConfig:
|
|
10
|
+
def __init__(self, config_parser: ConfigParser) -> None:
|
|
11
|
+
self._config_parser = config_parser
|
|
12
|
+
|
|
13
|
+
def get(self, args: CliArgs) -> Config:
|
|
14
|
+
config = self._get_config(args)
|
|
15
|
+
return config
|
|
16
|
+
|
|
17
|
+
def _get_config(self, args: CliArgs) -> Config:
|
|
18
|
+
if config_file := args.get_config_file():
|
|
19
|
+
return self._config_parser.parse(config_file)
|
|
20
|
+
else:
|
|
21
|
+
user_config_cwd = Path.cwd() / DEFAULT_USER_CONFIG
|
|
22
|
+
|
|
23
|
+
if user_config_cwd.exists():
|
|
24
|
+
return self._config_parser.parse(user_config_cwd)
|
|
25
|
+
return Config()
|