nedo-vision-worker-core 0.4.3__py3-none-any.whl → 0.4.4__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.

Potentially problematic release.


This version of nedo-vision-worker-core might be problematic. Click here for more details.

@@ -7,7 +7,7 @@ A library for running AI vision processing and detection in the Nedo Vision plat
7
7
  from .core_service import CoreService
8
8
  from .callbacks import DetectionType, CallbackTrigger, DetectionData, IntervalMetadata
9
9
 
10
- __version__ = "0.4.3"
10
+ __version__ = "0.4.4"
11
11
  __all__ = [
12
12
  "CoreService",
13
13
  "DetectionType",
@@ -202,9 +202,6 @@ class PipelineProcessor:
202
202
  if loop_start - last_preview_check >= self.preview_check_interval:
203
203
  self._check_and_update_rtmp_streaming()
204
204
  last_preview_check = loop_start
205
-
206
- # Only draw frames when actually needed (RTMP active or debug)
207
- should_draw = self.rtmp_streaming_active or self.debug_flag
208
205
 
209
206
  # For RTMP, also check if it's time to send a frame (rate limiting)
210
207
  should_draw_for_rtmp = (
@@ -151,14 +151,15 @@ class PipelineSyncThread(threading.Thread):
151
151
  ])
152
152
 
153
153
  if requires_restart:
154
- logging.info(f"🔄 Restarting pipeline due to significant changes: {pid}")
155
- self.pipeline_manager.stop_pipeline(pid)
156
-
157
154
  # Check if source is connected before restarting
158
155
  if not self.source_repo.is_source_connected(db_pipeline.worker_source_id):
159
156
  logging.warning(f"⚠️ Cannot restart pipeline {pid}: Source {db_pipeline.worker_source_id} is disconnected")
160
157
  return
161
158
 
159
+ logging.info(f"🔄 Restarting pipeline due to significant changes: {pid}")
160
+ self.pipeline_manager.stop_pipeline(pid)
161
+
162
+
162
163
  self.pipeline_manager.start_pipeline(db_pipeline, db_detector)
163
164
  else:
164
165
  # Update config for minor changes that don't require restart
@@ -18,12 +18,14 @@ class WorkerSourcePipelineDetectionRepository(BaseRepository):
18
18
  def save_detection(self, pipeline_id: int, frame, tracked_objects, frame_drawer: FrameDrawer):
19
19
  """
20
20
  Save detection data that need to be sent to database.
21
+ Only saves if there are violations detected.
21
22
  """
22
23
  now = datetime.now(timezone.utc)
23
24
  current_datetime = now.strftime("%Y%m%d_%H%M%S")
24
25
 
25
26
  frame_drawer.draw_polygons(frame)
26
27
  filtered_objects = []
28
+ has_violations = False
27
29
 
28
30
  for tracked_obj in tracked_objects:
29
31
  attributes = tracked_obj["attributes"]
@@ -34,9 +36,17 @@ class WorkerSourcePipelineDetectionRepository(BaseRepository):
34
36
  obj = tracked_obj.copy()
35
37
  obj["attributes"] = [attr for attr in attributes if attr.get("count", 0) >= 5]
36
38
 
39
+ # Check if any attribute is a violation
40
+ for attr in obj["attributes"]:
41
+ attr_label = attr.get("label", "")
42
+ if attr_label in frame_drawer.violation_labels:
43
+ has_violations = True
44
+ break
45
+
37
46
  filtered_objects.append(obj)
38
47
 
39
- if not filtered_objects:
48
+ # Only save and trigger webhook/MQTT if there are actual violations
49
+ if not filtered_objects or not has_violations:
40
50
  return
41
51
 
42
52
  drawn_frame = frame_drawer.draw_frame(frame.copy(), filtered_objects)
@@ -64,7 +74,5 @@ class WorkerSourcePipelineDetectionRepository(BaseRepository):
64
74
  )
65
75
  session.add(new_detection)
66
76
  session.flush()
67
- # Commit happens automatically via context manager
68
- print(f"✅ Inserted detection data for pipeline {pipeline_id}")
69
77
  except Exception as e:
70
78
  print(f"❌ Database error while saving detection: {e}")
@@ -237,6 +237,8 @@ class VideoStream(threading.Thread):
237
237
  def run(self) -> None:
238
238
  """Main capture loop."""
239
239
  failures = 0
240
+ last_frame_time = time.perf_counter()
241
+
240
242
  while self.running:
241
243
  try:
242
244
  if not self.capture or not self.capture.isOpened():
@@ -247,6 +249,18 @@ class VideoStream(threading.Thread):
247
249
  failures = 0
248
250
  self._reconnect_attempts = 0
249
251
  self._current_interval = self.reconnect_interval
252
+ last_frame_time = time.perf_counter()
253
+
254
+ # For video files, respect the FPS to avoid playing too fast
255
+ if self.is_file:
256
+ target_fps = self.target_fps if self.target_fps else self.fps
257
+ if target_fps > 0:
258
+ frame_interval = 1.0 / target_fps
259
+ elapsed = time.perf_counter() - last_frame_time
260
+ if elapsed < frame_interval:
261
+ sleep_time = frame_interval - elapsed
262
+ time.sleep(sleep_time)
263
+ last_frame_time = time.perf_counter()
250
264
 
251
265
  ret, frame = self.capture.read()
252
266
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nedo-vision-worker-core
3
- Version: 0.4.3
3
+ Version: 0.4.4
4
4
  Summary: Nedo Vision Worker Core Library for AI Vision Processing
5
5
  Author-email: Willy Achmat Fauzi <willy.achmat@gmail.com>
6
6
  Maintainer-email: Willy Achmat Fauzi <willy.achmat@gmail.com>
@@ -1,4 +1,4 @@
1
- nedo_vision_worker_core/__init__.py,sha256=65HOyr4VnCAkUlmbf0yGE_zIL4hLNL1IOY8zh_rnl8E,1923
1
+ nedo_vision_worker_core/__init__.py,sha256=ZlpHZZ54eVsepVdpBxhuJHhyEpKF8OqZAP9UvfFjMa4,1923
2
2
  nedo_vision_worker_core/cli.py,sha256=8YuKWsIgICUYXE_QtwyU3WzGhVjTWiAo5uzpFOmjNc8,5766
3
3
  nedo_vision_worker_core/core_service.py,sha256=q8-GuGW_l5l6wTWQDqc7BDdhM7zKC-mMLZ5wIHu9xV0,11628
4
4
  nedo_vision_worker_core/doctor.py,sha256=K_-hVV2-mdEefZ4Cfu5hMCiOxBiI1aXY8VtkkpK80Lc,10651
@@ -61,8 +61,8 @@ nedo_vision_worker_core/pipeline/ModelManager.py,sha256=2DoQiIdF-PAqU7nT_u6bj-DY
61
61
  nedo_vision_worker_core/pipeline/PipelineConfigManager.py,sha256=X55i9GyXcW9ylO6cj2UMAZFSxxPViacL4H4DZl60CAY,1157
62
62
  nedo_vision_worker_core/pipeline/PipelineManager.py,sha256=AlDwBYYRPeAeh2ilmC8n-A_2gYPqAzeSSVpR1Tc0ipE,8366
63
63
  nedo_vision_worker_core/pipeline/PipelinePrepocessor.py,sha256=cCiVSHHqsKCtKYURdYoEjHJX2GnT6zd8kQ6ZukjQ3V0,1271
64
- nedo_vision_worker_core/pipeline/PipelineProcessor.py,sha256=XITn3d8la37sCYEI_ZQzBoYYK6nrY9hAg6CaLKbxBF0,35305
65
- nedo_vision_worker_core/pipeline/PipelineSyncThread.py,sha256=UmjME7b1UYABVXKzYvlYBhVIyDcrsL5JDMxNt9G-0yk,9504
64
+ nedo_vision_worker_core/pipeline/PipelineProcessor.py,sha256=5j0FvGwBw5hgJ-FzI493cLpZomfYiG-bmUZZyklmahI,35149
65
+ nedo_vision_worker_core/pipeline/PipelineSyncThread.py,sha256=8HOVdeWO0dAXY9rMAk4VlX-bIhWrkhSzyJwlJobUnvw,9517
66
66
  nedo_vision_worker_core/pipeline/__init__.py,sha256=Nqnn8clbgv-5l0PgxcTOldg8mkMKrFn4TvPL-rYUUGg,1
67
67
  nedo_vision_worker_core/preprocessing/ImageResizer.py,sha256=RvOazxe6dJQuiy0ZH4lIGbdFfiu0FLUVCHoMvxkDNT4,1324
68
68
  nedo_vision_worker_core/preprocessing/ImageRoi.py,sha256=iO7oQ-SdUSA_kTIVBuq_mdycXsiJNfiFD3J7-VTxiQ4,2141
@@ -73,7 +73,7 @@ nedo_vision_worker_core/repositories/BaseRepository.py,sha256=FvdcD8I8_4_6TMZa8X
73
73
  nedo_vision_worker_core/repositories/PPEDetectionRepository.py,sha256=dIOPUU7xOCJ8A5v6AnBVKwtKPVlc5M5cUhLCWumTXyo,6882
74
74
  nedo_vision_worker_core/repositories/RestrictedAreaRepository.py,sha256=a5Vc8WLTtAa6Tn-ZSKkBEw4-cM29VW8WUwhbH7YfM9E,4416
75
75
  nedo_vision_worker_core/repositories/WorkerSourcePipelineDebugRepository.py,sha256=lN_yip6woya9YUA5sYKbTyDQz2qSfgqkr3YP2hSd9ws,3211
76
- nedo_vision_worker_core/repositories/WorkerSourcePipelineDetectionRepository.py,sha256=5m4lvmIETJSGDH1T1EHuUDWC-13t5I860UbN_uzEj9A,2641
76
+ nedo_vision_worker_core/repositories/WorkerSourcePipelineDetectionRepository.py,sha256=AVmrpeu6YziX2255_ZhK-5X5snxVMlr8xzb4ymAe5SA,2954
77
77
  nedo_vision_worker_core/repositories/WorkerSourcePipelineRepository.py,sha256=vwwRA1INuK66siOHNZxSBX8CE9uEW8VVcCIA7dmshKo,4714
78
78
  nedo_vision_worker_core/repositories/WorkerSourceRepository.py,sha256=YFevfYhAsYd7Eho1iagzjk67tKAQfqmoIExyxvR2Bzc,1760
79
79
  nedo_vision_worker_core/repositories/__init__.py,sha256=Nqnn8clbgv-5l0PgxcTOldg8mkMKrFn4TvPL-rYUUGg,1
@@ -83,7 +83,7 @@ nedo_vision_worker_core/services/VideoSharingDaemonManager.py,sha256=sc8VZo5iwoO
83
83
  nedo_vision_worker_core/streams/RTMPStreamer.py,sha256=7vg2as_TtmZavLnzhEUOv6HhjoGH5X3JO9HUI74meNs,18789
84
84
  nedo_vision_worker_core/streams/SharedVideoDeviceManager.py,sha256=vSslwxbhKH6FPndR1HcSFIVWtF-iiOQMlSa4VvFa6M4,16265
85
85
  nedo_vision_worker_core/streams/StreamSyncThread.py,sha256=ETT0N_P90ksn6Q5pb7NvMadqCuoicz_g52lcDkHIp88,5382
86
- nedo_vision_worker_core/streams/VideoStream.py,sha256=nGtJ4FAZ1Ek-8hVRopEt0bLWLpa10OtyUwdDEuXLObQ,13343
86
+ nedo_vision_worker_core/streams/VideoStream.py,sha256=Xg3gxa9JZfCkwqD5OnvNmvf_iKmlEpjTlk4_YS2f2xU,14046
87
87
  nedo_vision_worker_core/streams/VideoStreamManager.py,sha256=g5cz-YXPewSubBXxCg4mfzsuGKoOHXu-SrMxaGjYPHw,14956
88
88
  nedo_vision_worker_core/streams/__init__.py,sha256=Nqnn8clbgv-5l0PgxcTOldg8mkMKrFn4TvPL-rYUUGg,1
89
89
  nedo_vision_worker_core/tracker/SFSORT.py,sha256=0kggw0l4yPZ55AKHdqVX6mu9ehHmJed7jcJ3JQoC4sk,14061
@@ -98,8 +98,8 @@ nedo_vision_worker_core/util/PipelinePreviewChecker.py,sha256=XxlSMlrDlRrzfV8_Y-
98
98
  nedo_vision_worker_core/util/PlatformDetector.py,sha256=GGL8UfeMQITR22EMYIRWnuOEnSqo7Dr5mb0PaFrl8AM,3006
99
99
  nedo_vision_worker_core/util/TablePrinter.py,sha256=wzLGgb1GFMeIbAP6HmKcZD33j4D-IlyqlyeR7C5yD7w,1137
100
100
  nedo_vision_worker_core/util/__init__.py,sha256=Nqnn8clbgv-5l0PgxcTOldg8mkMKrFn4TvPL-rYUUGg,1
101
- nedo_vision_worker_core-0.4.3.dist-info/METADATA,sha256=niAjMl89ByK-mEOVchjKAZ2s52xyctOOIS-lLK7_QkU,14426
102
- nedo_vision_worker_core-0.4.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
103
- nedo_vision_worker_core-0.4.3.dist-info/entry_points.txt,sha256=pIPafsvPnBw-fpBKBmc1NQCQ6PQY3ad8mZ6mn8_p5FI,70
104
- nedo_vision_worker_core-0.4.3.dist-info/top_level.txt,sha256=y8kusXjVYqtG8MSHYWTrk8bRrvjOrphKXYyzu943TTQ,24
105
- nedo_vision_worker_core-0.4.3.dist-info/RECORD,,
101
+ nedo_vision_worker_core-0.4.4.dist-info/METADATA,sha256=NeX_eRQ8lbk8z9HYN0ERFouzwjnbdc_xLXytxzvrQtw,14426
102
+ nedo_vision_worker_core-0.4.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
103
+ nedo_vision_worker_core-0.4.4.dist-info/entry_points.txt,sha256=pIPafsvPnBw-fpBKBmc1NQCQ6PQY3ad8mZ6mn8_p5FI,70
104
+ nedo_vision_worker_core-0.4.4.dist-info/top_level.txt,sha256=y8kusXjVYqtG8MSHYWTrk8bRrvjOrphKXYyzu943TTQ,24
105
+ nedo_vision_worker_core-0.4.4.dist-info/RECORD,,