matrice 1.0.99301__py3-none-any.whl → 1.0.99303__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.
@@ -127,8 +127,8 @@ class ColorDetectionUseCase(BaseProcessor):
127
127
  self.smoothing_tracker = None # BBoxSmoothingTracker instance
128
128
  self._total_frame_counter = 0 # Total frames processed
129
129
  self._global_frame_offset = 0 # Frame offset for new sessions
130
- self._color_total_track_ids = {} # Cumulative track IDs per category and color
131
- self._color_current_frame_track_ids = {} # Per-frame track IDs per category and color
130
+ self._color_total_track_ids = defaultdict(set) # Cumulative track IDs per category-color
131
+ self._color_current_frame_track_ids = defaultdict(set) # Per-frame track IDs per category-color
132
132
 
133
133
  self._tracking_start_time = None
134
134
 
@@ -149,8 +149,8 @@ class ColorDetectionUseCase(BaseProcessor):
149
149
 
150
150
  def reset_color_tracking(self) -> None:
151
151
  """Reset color tracking state."""
152
- self._color_total_track_ids = {}
153
- self._color_current_frame_track_ids = {}
152
+ self._color_total_track_ids = defaultdict(set)
153
+ self._color_current_frame_track_ids = defaultdict(set)
154
154
  self._total_frame_counter = 0
155
155
  self._global_frame_offset = 0
156
156
  self.logger.info("Color tracking state reset")
@@ -249,7 +249,13 @@ class ColorDetectionUseCase(BaseProcessor):
249
249
 
250
250
  def _update_color_tracking_state(self, detections: List[Dict]):
251
251
  """Track unique track_ids per category and color for total count."""
252
- self._color_total_track_ids = getattr(self, '_color_total_track_ids', defaultdict(set))
252
+ # Ensure storage is a defaultdict(set) to allow safe .add()
253
+ existing_store = getattr(self, '_color_total_track_ids', None)
254
+ if not isinstance(existing_store, defaultdict):
255
+ existing_store = {} if existing_store is None else dict(existing_store)
256
+ self._color_total_track_ids = defaultdict(set, existing_store)
257
+ else:
258
+ self._color_total_track_ids = existing_store
253
259
  self._color_current_frame_track_ids = defaultdict(set)
254
260
  for det in detections:
255
261
  cat = det.get('category')
@@ -261,8 +267,20 @@ class ColorDetectionUseCase(BaseProcessor):
261
267
  self._color_current_frame_track_ids[key].add(track_id)
262
268
 
263
269
  def get_total_color_counts(self):
264
- """Return total unique track_id count for each category-color pair."""
265
- return {key: len(ids) for key, ids in getattr(self, '_color_total_track_ids', {}).items()}
270
+ """Return total unique track_id count per category (across all colors)."""
271
+ store = getattr(self, '_color_total_track_ids', {})
272
+ if not isinstance(store, dict):
273
+ return {}
274
+ category_to_ids = defaultdict(set)
275
+ for key, id_set in store.items():
276
+ if isinstance(key, str) and ':' in key:
277
+ cat, _ = key.split(':', 1)
278
+ else:
279
+ cat = key
280
+ # Support both set and iterable
281
+ ids = id_set if isinstance(id_set, set) else set(id_set or [])
282
+ category_to_ids[cat].update(ids)
283
+ return {cat: len(ids) for cat, ids in category_to_ids.items()}
266
284
 
267
285
  def _get_track_ids_info(self, detections: List[Dict]) -> Dict[str, Any]:
268
286
  """Get detailed information about track IDs for color detections (per frame)."""
@@ -335,9 +353,9 @@ class ColorDetectionUseCase(BaseProcessor):
335
353
  if config.target_categories:
336
354
  color_processed_data = [d for d in processed_data if d.get('category') in self.target_categories]
337
355
  self.logger.debug("Applied category filtering")
338
- print("-------------------COLOR_PROCESSED_DATA-------------------")
339
- print(color_processed_data)
340
- print("-------------------COLOR_PROCESSED_DATA-------------------")
356
+ print("-------------------COLOR_PROCESSED_DATA-------------------")
357
+ print(color_processed_data)
358
+ print("-------------------COLOR_PROCESSED_DATA-------------------")
341
359
 
342
360
  # Step 2.5: Filter to only include target categories
343
361
  # color_processed_data = filter_by_categories(processed_data.copy(), config.target_categories)
@@ -927,7 +945,7 @@ class ColorDetectionUseCase(BaseProcessor):
927
945
  # frame_tracking_stats = tracking_stats[0][frame_key]
928
946
  tracking_stats = []
929
947
 
930
- total_detections = counting_summary.get("total_detections", 0)
948
+ total_detections = counting_summary.get("total_count", 0)
931
949
  total_counts = counting_summary.get("total_color_counts", {})
932
950
  cumulative_total = sum(total_counts.values()) if total_counts else 0
933
951
  per_category_count = counting_summary.get("per_category_count", {})
@@ -1149,7 +1167,7 @@ class ColorDetectionUseCase(BaseProcessor):
1149
1167
  # Use frame number as key, fallback to 'current_frame' if not available
1150
1168
  frame_key = str(frame_number) if frame_number is not None else "current_frame"
1151
1169
  incidents=[]
1152
- total_detections = counting_summary.get("total_detections", 0)
1170
+ total_detections = counting_summary.get("total_count", 0)
1153
1171
  current_timestamp = self._get_current_timestamp_str(stream_info)
1154
1172
  camera_info = self.get_camera_info_from_stream(stream_info)
1155
1173
 
@@ -1257,15 +1275,17 @@ class ColorDetectionUseCase(BaseProcessor):
1257
1275
 
1258
1276
  frame_key = str(frame_number) if frame_number is not None else "current_frame"
1259
1277
  alerts = []
1260
- total_detections = summary.get("total_detections", 0) #CURRENT combined total count of all classes
1278
+ total_detections = summary.get("total_count", 0) #CURRENT combined total count of all classes
1261
1279
  total_counts_dict = summary.get("total_color_counts", {}) #TOTAL cumulative counts per class
1280
+ if isinstance(total_counts_dict, int):
1281
+ total_counts_dict = {}
1262
1282
  cumulative_total = sum(total_counts_dict.values()) if total_counts_dict else 0 #TOTAL combined cumulative count
1263
1283
  per_category_count = summary.get("per_category_count", {}) #CURRENT count per class
1264
1284
 
1265
1285
  if not config.alert_config:
1266
1286
  return alerts
1267
1287
 
1268
- total = summary.get("total_detections", 0)
1288
+ total = summary.get("total_count", 0)
1269
1289
  #self._ascending_alert_list
1270
1290
  if hasattr(config.alert_config, 'count_thresholds') and config.alert_config.count_thresholds:
1271
1291
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: matrice
3
- Version: 1.0.99301
3
+ Version: 1.0.99303
4
4
  Summary: SDK for connecting to matrice.ai services
5
5
  Home-page: https://github.com/matrice-ai/python-sdk
6
6
  Author: Matrice.ai
@@ -170,7 +170,7 @@ matrice/deploy/utils/post_processing/usecases/car_part_segmentation.py,sha256=Jb
170
170
  matrice/deploy/utils/post_processing/usecases/cardiomegaly_classification.py,sha256=1P6DyOU6R1XKmQ-55BbKMU8CSsm4-wR5wS827UJG2JU,41244
171
171
  matrice/deploy/utils/post_processing/usecases/chicken_pose_detection.py,sha256=-e8di7Am-E-FCQFrSY8qJTO1aWtdRAVJoE-VKBgcyyI,29291
172
172
  matrice/deploy/utils/post_processing/usecases/child_monitoring.py,sha256=z3oymoqq4hDGwA8MkdEONZW_Vx5CAZmvzZaNLsqmCfw,39380
173
- matrice/deploy/utils/post_processing/usecases/color_detection.py,sha256=YsY1EDx7Lq1es9-Jg1DJYyHPB4u0NskqaXwFovL2zn8,70289
173
+ matrice/deploy/utils/post_processing/usecases/color_detection.py,sha256=jK8Vy_3MJfijpqezvpvHn6yDGtpilX_1Q0CvSKcKM0U,71226
174
174
  matrice/deploy/utils/post_processing/usecases/color_map_utils.py,sha256=SP-AEVcjLmL8rxblu-ixqUJC2fqlcr7ab4hWo4Fcr_k,2677
175
175
  matrice/deploy/utils/post_processing/usecases/concrete_crack_detection.py,sha256=pxhOH_hG4hq9yytNepbGMdk2W_lTG8D1_2RAagaPBkg,40252
176
176
  matrice/deploy/utils/post_processing/usecases/crop_weed_detection.py,sha256=Ao1k5fJDYU_f6yZ8VO-jW8-esECV0-zY5Q570c_fako,35674
@@ -244,8 +244,8 @@ matrice/deployment/camera_manager.py,sha256=e1Lc81RJP5wUWRdTgHO6tMWF9BkBdHOSVyx3
244
244
  matrice/deployment/deployment.py,sha256=HFt151eWq6iqIAMsQvurpV2WNxW6Cx_gIUVfnVy5SWE,48093
245
245
  matrice/deployment/inference_pipeline.py,sha256=6b4Mm3-qt-Zy0BeiJfFQdImOn3FzdNCY-7ET7Rp8PMk,37911
246
246
  matrice/deployment/streaming_gateway_manager.py,sha256=ifYGl3g25wyU39HwhPQyI2OgF3M6oIqKMWt8RXtMxY8,21401
247
- matrice-1.0.99301.dist-info/licenses/LICENSE.txt,sha256=2bm9uFabQZ3Ykb_SaSU_uUbAj2-htc6WJQmS_65qD00,1073
248
- matrice-1.0.99301.dist-info/METADATA,sha256=Yie8iz9jzoz34X3E_TxfIZ0YnCZXW6vOw2-xx1vzuIw,14624
249
- matrice-1.0.99301.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
250
- matrice-1.0.99301.dist-info/top_level.txt,sha256=P97js8ur6o5ClRqMH3Cjoab_NqbJ6sOQ3rJmVzKBvMc,8
251
- matrice-1.0.99301.dist-info/RECORD,,
247
+ matrice-1.0.99303.dist-info/licenses/LICENSE.txt,sha256=2bm9uFabQZ3Ykb_SaSU_uUbAj2-htc6WJQmS_65qD00,1073
248
+ matrice-1.0.99303.dist-info/METADATA,sha256=DE5H_2ihQtvIU36jRs2tOr6KvFZgleQO1825yqXrXlI,14624
249
+ matrice-1.0.99303.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
250
+ matrice-1.0.99303.dist-info/top_level.txt,sha256=P97js8ur6o5ClRqMH3Cjoab_NqbJ6sOQ3rJmVzKBvMc,8
251
+ matrice-1.0.99303.dist-info/RECORD,,