matrice 1.0.99302__py3-none-any.whl → 1.0.99304__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.
@@ -261,8 +261,9 @@ class ColorDetectionUseCase(BaseProcessor):
261
261
  cat = det.get('category')
262
262
  color = det.get('main_color')
263
263
  track_id = det.get('track_id')
264
- if cat and color and track_id is not None:
265
- key = f"{cat}:{color}" # Unique key for category-color pair
264
+ if cat and track_id is not None:
265
+ # If color not yet computed at this stage, fall back to category-only key
266
+ key = f"{cat}:{color}" if color else cat
266
267
  self._color_total_track_ids[key].add(track_id)
267
268
  self._color_current_frame_track_ids[key].add(track_id)
268
269
 
@@ -419,10 +420,22 @@ class ColorDetectionUseCase(BaseProcessor):
419
420
  print("-------------------COLOR_ANALYSIS-------------------")
420
421
 
421
422
  # Step 8: Calculate summaries
423
+ # After color extraction, update cumulative color-aware tracking totals
424
+ self._update_color_tracking_state_from_analysis(color_analysis)
422
425
  color_summary = self._calculate_color_summary(color_analysis, config)
426
+ # Ensure total_color_counts is populated even on first frame/session
427
+ totals = self.get_total_color_counts()
428
+ if not totals:
429
+ tmp = defaultdict(set)
430
+ for rec in color_analysis:
431
+ cat = rec.get('category')
432
+ tid = rec.get('track_id') or rec.get('detection_id')
433
+ if cat and tid is not None:
434
+ tmp[cat].add(tid)
435
+ totals = {cat: len(ids) for cat, ids in tmp.items()}
423
436
 
424
437
  general_summary = self._calculate_general_summary(processed_data, config)
425
- color_summary['total_color_counts'] = self.get_total_color_counts()
438
+ color_summary['total_color_counts'] = totals
426
439
  print("-------------------COLOR_SUMMARY-------------------")
427
440
  print(color_summary)
428
441
  print("-------------------COLOR_SUMMARY-------------------")
@@ -511,6 +524,25 @@ class ColorDetectionUseCase(BaseProcessor):
511
524
  return self._analyze_colors_in_video(data, media_bytes, config)
512
525
  else:
513
526
  return self._analyze_colors_in_image(data, media_bytes, config)
527
+
528
+ def _update_color_tracking_state_from_analysis(self, color_analysis: List[Dict[str, Any]]) -> None:
529
+ """Update total tracking store using analyzed color results.
530
+ Ensures totals are populated even if pre-analysis detections lacked colors/track_ids."""
531
+ existing_store = getattr(self, '_color_total_track_ids', None)
532
+ if not isinstance(existing_store, defaultdict):
533
+ existing_store = {} if existing_store is None else dict(existing_store)
534
+ self._color_total_track_ids = defaultdict(set, existing_store)
535
+ else:
536
+ self._color_total_track_ids = existing_store
537
+ for rec in color_analysis:
538
+ cat = rec.get('category')
539
+ color = rec.get('main_color')
540
+ track_id = rec.get('track_id')
541
+ if track_id is None:
542
+ track_id = rec.get('detection_id')
543
+ if cat and track_id is not None:
544
+ key = f"{cat}:{color}" if color else cat
545
+ self._color_total_track_ids[key].add(track_id)
514
546
 
515
547
  def _is_video_bytes(self, media_bytes: bytes) -> bool:
516
548
  """Determine if bytes represent a video file."""
@@ -1276,7 +1308,9 @@ class ColorDetectionUseCase(BaseProcessor):
1276
1308
  frame_key = str(frame_number) if frame_number is not None else "current_frame"
1277
1309
  alerts = []
1278
1310
  total_detections = summary.get("total_count", 0) #CURRENT combined total count of all classes
1279
- total_counts_dict = summary.get("total_count", {}) #TOTAL cumulative counts per class
1311
+ total_counts_dict = summary.get("total_color_counts", {}) #TOTAL cumulative counts per class
1312
+ if isinstance(total_counts_dict, int):
1313
+ total_counts_dict = {}
1280
1314
  cumulative_total = sum(total_counts_dict.values()) if total_counts_dict else 0 #TOTAL combined cumulative count
1281
1315
  per_category_count = summary.get("per_category_count", {}) #CURRENT count per class
1282
1316
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: matrice
3
- Version: 1.0.99302
3
+ Version: 1.0.99304
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=r94P0wlFTswexqllSENZbFAuJtBxlgUCzWtDaeHExcw,71137
173
+ matrice/deploy/utils/post_processing/usecases/color_detection.py,sha256=_HLg4ow1aDi61-ZW4yefNF5zn_netAIwPfvpPhd8BYA,72977
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.99302.dist-info/licenses/LICENSE.txt,sha256=2bm9uFabQZ3Ykb_SaSU_uUbAj2-htc6WJQmS_65qD00,1073
248
- matrice-1.0.99302.dist-info/METADATA,sha256=c66lAc24CgiYHMXa-frCOoZjQHKdZ8uiMu0zmkfzXjA,14624
249
- matrice-1.0.99302.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
250
- matrice-1.0.99302.dist-info/top_level.txt,sha256=P97js8ur6o5ClRqMH3Cjoab_NqbJ6sOQ3rJmVzKBvMc,8
251
- matrice-1.0.99302.dist-info/RECORD,,
247
+ matrice-1.0.99304.dist-info/licenses/LICENSE.txt,sha256=2bm9uFabQZ3Ykb_SaSU_uUbAj2-htc6WJQmS_65qD00,1073
248
+ matrice-1.0.99304.dist-info/METADATA,sha256=iZgoXZczNzjS2LQTGNaHYLAK_Pa8TJZpPWvLbFI0KBE,14624
249
+ matrice-1.0.99304.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
250
+ matrice-1.0.99304.dist-info/top_level.txt,sha256=P97js8ur6o5ClRqMH3Cjoab_NqbJ6sOQ3rJmVzKBvMc,8
251
+ matrice-1.0.99304.dist-info/RECORD,,