OTVision 0.6.15__py3-none-any.whl → 0.6.17__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.
@@ -1,5 +1,6 @@
1
1
  import logging
2
2
  from dataclasses import dataclass
3
+ from pathlib import Path
3
4
 
4
5
  from OTVision.abstraction.observer import Observer, Subject
5
6
  from OTVision.application.detect.current_object_detector_metadata import (
@@ -21,6 +22,7 @@ class OtdetFileWrittenEvent:
21
22
 
22
23
  otdet_builder_config: OtdetBuilderConfig
23
24
  number_of_frames: int
25
+ save_location: Path
24
26
 
25
27
 
26
28
  class OtdetFileWriter:
@@ -116,12 +118,20 @@ class OtdetFileWriter:
116
118
 
117
119
  finished_msg = "Finished detection"
118
120
  log.info(finished_msg)
119
- self.__notify(num_frames=actual_frames, builder_config=builder_config)
121
+ self.__notify(
122
+ num_frames=actual_frames,
123
+ builder_config=builder_config,
124
+ save_location=detections_file,
125
+ )
120
126
 
121
- def __notify(self, num_frames: int, builder_config: OtdetBuilderConfig) -> None:
127
+ def __notify(
128
+ self, num_frames: int, builder_config: OtdetBuilderConfig, save_location: Path
129
+ ) -> None:
122
130
  self._subject.notify(
123
131
  OtdetFileWrittenEvent(
124
- number_of_frames=num_frames, otdet_builder_config=builder_config
132
+ number_of_frames=num_frames,
133
+ otdet_builder_config=builder_config,
134
+ save_location=save_location,
125
135
  )
126
136
  )
127
137
 
@@ -1,7 +1,7 @@
1
1
  import logging
2
2
  from datetime import datetime
3
3
  from pathlib import Path
4
- from typing import Iterator
4
+ from typing import Iterable, Iterator
5
5
 
6
6
  import av
7
7
  from av.container.input import InputContainer
@@ -84,11 +84,9 @@ class VideoSource(InputSourceDetect):
84
84
  Frame: Processed video frames ready for detection.
85
85
  """
86
86
 
87
- video_files = self.__collect_files_to_detect()
87
+ video_files = self._collect_files_to_detect()
88
88
 
89
- start_msg = f"Start detection of {len(video_files)} video files"
90
- log.info(start_msg)
91
- print(start_msg)
89
+ log.info("Start detection of video files")
92
90
 
93
91
  for video_file in tqdm(video_files, desc="Detected video files", unit=" files"):
94
92
  detections_file = self._save_path_provider.provide(
@@ -138,9 +136,14 @@ class VideoSource(InputSourceDetect):
138
136
  )
139
137
  counter += 1
140
138
  self.notify_flush_event_observers(video_file, video_fps)
139
+ self._on_video_finished(video_file)
141
140
  except Exception as e:
142
141
  log.error(f"Error processing {video_file}", exc_info=e)
143
142
 
143
+ def _on_video_finished(self, video_file: Path) -> None:
144
+ """Hook for handling video processing completion."""
145
+ pass
146
+
144
147
  def _extract_side_data(self, container: InputContainer) -> dict:
145
148
  try:
146
149
  return container.streams.video[0].side_data
@@ -151,7 +154,7 @@ class VideoSource(InputSourceDetect):
151
154
  )
152
155
  return {}
153
156
 
154
- def __collect_files_to_detect(self) -> list[Path]:
157
+ def _collect_files_to_detect(self) -> Iterable[Path]:
155
158
  filetypes = self._current_config.filetypes.video_filetypes.to_list()
156
159
  video_files = get_files(
157
160
  paths=self._current_config.detect.paths, filetypes=filetypes
@@ -1,6 +1,8 @@
1
+ from dataclasses import dataclass
1
2
  from pathlib import Path
2
3
  from typing import Any
3
4
 
5
+ from OTVision.abstraction.observer import Observer, Subject
4
6
  from OTVision.application.buffer import Buffer
5
7
  from OTVision.application.config import Config, TrackConfig
6
8
  from OTVision.application.configure_logger import logger
@@ -17,6 +19,11 @@ from OTVision.helpers.files import write_json
17
19
  STREAMING_FRAME_GROUP_ID = 0
18
20
 
19
21
 
22
+ @dataclass(frozen=True)
23
+ class OttrkFileWrittenEvent:
24
+ save_location: Path
25
+
26
+
20
27
  class StreamOttrkFileWriter(Buffer[TrackedFrame, OtdetFileWrittenEvent]):
21
28
  @property
22
29
  def config(self) -> Config:
@@ -38,12 +45,14 @@ class StreamOttrkFileWriter(Buffer[TrackedFrame, OtdetFileWrittenEvent]):
38
45
 
39
46
  def __init__(
40
47
  self,
48
+ subject: Subject[OttrkFileWrittenEvent],
41
49
  builder: OttrkBuilder,
42
50
  get_current_config: GetCurrentConfig,
43
51
  get_current_tracking_run_id: GetCurrentTrackingRunId,
44
52
  save_path_provider: OtvisionSavePathProvider,
45
53
  ) -> None:
46
54
  Buffer.__init__(self)
55
+ self._subject = subject
47
56
  self._builder = builder
48
57
  self._get_current_config = get_current_config
49
58
  self._current_tracking_run_id = get_current_tracking_run_id
@@ -118,12 +127,20 @@ class StreamOttrkFileWriter(Buffer[TrackedFrame, OtdetFileWrittenEvent]):
118
127
  self._current_output_file = None
119
128
 
120
129
  def write(self, ottrk: dict) -> None:
130
+ current_output_file = self.current_output_file
121
131
  write_json(
122
132
  dict_to_write=ottrk,
123
- file=self.current_output_file,
133
+ file=current_output_file,
124
134
  filetype=self.config.filetypes.track,
125
135
  overwrite=True,
126
136
  )
137
+ self._notify_ottrk_file_written(save_location=current_output_file)
127
138
 
128
139
  def force_flush(self, _: Any) -> None:
129
140
  self._create_ottrk()
141
+
142
+ def register_observers(self, observer: Observer[OttrkFileWrittenEvent]) -> None:
143
+ self._subject.register(observer)
144
+
145
+ def _notify_ottrk_file_written(self, save_location: Path) -> None:
146
+ self._subject.notify(OttrkFileWrittenEvent(save_location=save_location))
OTVision/version.py CHANGED
@@ -1,4 +1,4 @@
1
- __version__ = "v0.6.15"
1
+ __version__ = "v0.6.17"
2
2
 
3
3
 
4
4
  def otdet_version() -> str:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: OTVision
3
- Version: 0.6.15
3
+ Version: 0.6.17
4
4
  Summary: OTVision is a core module of the OpenTrafficCam framework to perform object detection and tracking.
5
5
  Project-URL: Homepage, https://opentrafficcam.org/
6
6
  Project-URL: Documentation, https://opentrafficcam.org/overview/
@@ -1,7 +1,7 @@
1
1
  OTVision/__init__.py,sha256=CLnfgTlVHM4_nzDacvy06Z_Crc3hU6usd0mUyEvBf24,781
2
2
  OTVision/config.py,sha256=D4NIio27JG9hZk7yHI6kNKiMxKeKa_MGfrKNDdEH370,5389
3
3
  OTVision/dataformat.py,sha256=BHF7qHzyNb80hI1EKfwcdJ9bgG_X4bp_hCXzdg7_MSA,1941
4
- OTVision/version.py,sha256=8tgEbcFFDS8lJGj0yPkcvnVArQ1MzgFTHMi_REfjPGw,176
4
+ OTVision/version.py,sha256=Ay8_qdo-wXxrm9e-GbKoT9-hDKLEXS2tzcLHFDgMULk,176
5
5
  OTVision/abstraction/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  OTVision/abstraction/defaults.py,sha256=ftETDe25gmr563RPSbG6flcEiNiHnRb0iXK1Zj_zdNg,442
7
7
  OTVision/abstraction/observer.py,sha256=ZFGxUUjI3wUpf5ogXg2yDe-QjCcXre6SxH5zOogOx2U,1350
@@ -46,12 +46,12 @@ OTVision/detect/detected_frame_producer.py,sha256=thMg5nZNiArUpQI7ctGTQy8A2jxsZs
46
46
  OTVision/detect/detected_frame_producer_factory.py,sha256=HiFAHWTvilwyibDrzMv9skwu901d9QW3zvjc3q4Pp80,1576
47
47
  OTVision/detect/file_based_detect_builder.py,sha256=G72GFhF2BCXO3fwfC9pXkbJPhRFfU6RphLRQs3ugCUQ,2315
48
48
  OTVision/detect/otdet.py,sha256=cIwCBVFYWma7oJynoaT0eyIAZw-M2iH1xkvjy6-TwEM,8475
49
- OTVision/detect/otdet_file_writer.py,sha256=mGygzanR2WwIBBouUQYRVtYwtVAlLJZJtmshVwWTgdY,5164
49
+ OTVision/detect/otdet_file_writer.py,sha256=0FezBon_R-ve0oYMWMCDytNHIMuOEQqFOWVU7Dr9iTo,5388
50
50
  OTVision/detect/pyav_frame_count_provider.py,sha256=w7p9iM3F2fljV8SD7q491gQhIHANbVczqtalcUiKj-E,453
51
51
  OTVision/detect/rtsp_based_detect_builder.py,sha256=P47nKU2C1PJQmokgacv04DzJ-7eG6CUbqqg3bdQhXTQ,2662
52
52
  OTVision/detect/rtsp_input_source.py,sha256=nF7AyRcbZlvYwPghvi3QbRPCHU9KTtcgtWiUdAAR4Jg,10806
53
53
  OTVision/detect/timestamper.py,sha256=VvDTzHu9fTI7qQL9x775Gc27r47R8D5Pb040ffwO04k,5288
54
- OTVision/detect/video_input_source.py,sha256=tyvaku4EIwCjCAQyA3lXKFtzVMF325CbrDdn24mfZl0,10124
54
+ OTVision/detect/video_input_source.py,sha256=yosHCK5e737AmBk-AgF3sL9rs45w0AIwup0-hU3mf1A,10248
55
55
  OTVision/detect/yolo.py,sha256=JDnnPO-YO30tu61sw80K9qJS6_aYqdR2dQHAhtJ3tl0,10551
56
56
  OTVision/detect/plugin_av/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
57
57
  OTVision/detect/plugin_av/rotate_frame.py,sha256=4wJqTYI2HRlfa4p2Ffap33vLmKIzE_EwFvQraEkQ4R8,1055
@@ -82,7 +82,7 @@ OTVision/track/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
82
82
  OTVision/track/builder.py,sha256=iDq9-QxU8c3CQQd5HDPzT2qkXWIyFl0fk658KQ7Soh0,4905
83
83
  OTVision/track/cli.py,sha256=Lzmij9vMuaArB8MerDcGlaefwKMgRWNWov1YLGWA6SI,4294
84
84
  OTVision/track/id_generator.py,sha256=2Lkegjhz8T2FXiK1HaiS_FbNZrJjIWzHi407-IoKAHg,241
85
- OTVision/track/stream_ottrk_file_writer.py,sha256=TvJVumOTYUa10tC9_0-wUon1FKC0uJoh2wctRPX1aXg,4836
85
+ OTVision/track/stream_ottrk_file_writer.py,sha256=4t8O5-DS2LXdgQHM5yn4s2ypdr0ACAsmzg4U6QZW1hU,5495
86
86
  OTVision/track/track.py,sha256=iMOaukcHnPhRiU1eEccaeGEKLzBQoilaUPRVmkmt0rk,2357
87
87
  OTVision/track/exporter/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
88
88
  OTVision/track/exporter/filebased_exporter.py,sha256=sdaWY4CxjawyeEKG329T92Bodf1E8wjnXuXocv0Ppgo,986
@@ -110,7 +110,7 @@ OTVision/view/view_helpers.py,sha256=a5yV_6ZxO5bxsSymOmxdHqzOEv0VFq4wFBopVRGuVRo
110
110
  OTVision/view/view_track.py,sha256=vmfMqpbUfnzg_EsWiL-IIKNOApVF09dzSojHpUfYY6M,5393
111
111
  OTVision/view/view_transform.py,sha256=HvRd8g8geKRy0OoiZUDn_oC3SJC5nuXhZf3uZelfGKg,5473
112
112
  OTVision/view/helpers/OTC.ico,sha256=G9kwlDtgBXmXO3yxW6Z-xVFV2q4nUGuz9E1VPHSu_I8,21662
113
- otvision-0.6.15.dist-info/METADATA,sha256=cgqMMjvpJQPpg_TwDPAq3-dJrnh0W3jg8Q9tOrs1Qpw,6944
114
- otvision-0.6.15.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
115
- otvision-0.6.15.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
116
- otvision-0.6.15.dist-info/RECORD,,
113
+ otvision-0.6.17.dist-info/METADATA,sha256=jHEqrFDQ7_q4medQTUzqTnm_6p_CvI3KvlK8rgi2WKQ,6944
114
+ otvision-0.6.17.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
115
+ otvision-0.6.17.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
116
+ otvision-0.6.17.dist-info/RECORD,,