matrice 1.0.99303__py3-none-any.whl → 1.0.99305__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.
- matrice/deploy/utils/post_processing/usecases/color_detection.py +42 -9
- {matrice-1.0.99303.dist-info → matrice-1.0.99305.dist-info}/METADATA +1 -1
- {matrice-1.0.99303.dist-info → matrice-1.0.99305.dist-info}/RECORD +6 -6
- {matrice-1.0.99303.dist-info → matrice-1.0.99305.dist-info}/WHEEL +0 -0
- {matrice-1.0.99303.dist-info → matrice-1.0.99305.dist-info}/licenses/LICENSE.txt +0 -0
- {matrice-1.0.99303.dist-info → matrice-1.0.99305.dist-info}/top_level.txt +0 -0
@@ -261,26 +261,28 @@ 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
|
265
|
-
|
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
|
|
269
270
|
def get_total_color_counts(self):
|
270
|
-
"""Return total unique track_id count per
|
271
|
+
"""Return total unique track_id count per color (across all categories)."""
|
271
272
|
store = getattr(self, '_color_total_track_ids', {})
|
272
273
|
if not isinstance(store, dict):
|
273
274
|
return {}
|
274
|
-
|
275
|
+
color_to_ids = defaultdict(set)
|
275
276
|
for key, id_set in store.items():
|
276
277
|
if isinstance(key, str) and ':' in key:
|
277
|
-
|
278
|
+
_, color = key.split(':', 1)
|
278
279
|
else:
|
279
|
-
|
280
|
+
color = None
|
280
281
|
# Support both set and iterable
|
281
282
|
ids = id_set if isinstance(id_set, set) else set(id_set or [])
|
282
|
-
|
283
|
-
|
283
|
+
if color:
|
284
|
+
color_to_ids[color].update(ids)
|
285
|
+
return {color: len(ids) for color, ids in color_to_ids.items()}
|
284
286
|
|
285
287
|
def _get_track_ids_info(self, detections: List[Dict]) -> Dict[str, Any]:
|
286
288
|
"""Get detailed information about track IDs for color detections (per frame)."""
|
@@ -419,10 +421,22 @@ class ColorDetectionUseCase(BaseProcessor):
|
|
419
421
|
print("-------------------COLOR_ANALYSIS-------------------")
|
420
422
|
|
421
423
|
# Step 8: Calculate summaries
|
424
|
+
# After color extraction, update cumulative color-aware tracking totals
|
425
|
+
self._update_color_tracking_state_from_analysis(color_analysis)
|
422
426
|
color_summary = self._calculate_color_summary(color_analysis, config)
|
427
|
+
# Ensure total_color_counts is populated even on first frame/session
|
428
|
+
totals = self.get_total_color_counts()
|
429
|
+
if not totals:
|
430
|
+
tmp = defaultdict(set)
|
431
|
+
for rec in color_analysis:
|
432
|
+
color = rec.get('main_color')
|
433
|
+
tid = rec.get('track_id') or rec.get('detection_id')
|
434
|
+
if color and tid is not None:
|
435
|
+
tmp[color].add(tid)
|
436
|
+
totals = {color: len(ids) for color, ids in tmp.items()}
|
423
437
|
|
424
438
|
general_summary = self._calculate_general_summary(processed_data, config)
|
425
|
-
color_summary['total_color_counts'] =
|
439
|
+
color_summary['total_color_counts'] = totals
|
426
440
|
print("-------------------COLOR_SUMMARY-------------------")
|
427
441
|
print(color_summary)
|
428
442
|
print("-------------------COLOR_SUMMARY-------------------")
|
@@ -511,6 +525,25 @@ class ColorDetectionUseCase(BaseProcessor):
|
|
511
525
|
return self._analyze_colors_in_video(data, media_bytes, config)
|
512
526
|
else:
|
513
527
|
return self._analyze_colors_in_image(data, media_bytes, config)
|
528
|
+
|
529
|
+
def _update_color_tracking_state_from_analysis(self, color_analysis: List[Dict[str, Any]]) -> None:
|
530
|
+
"""Update total tracking store using analyzed color results.
|
531
|
+
Ensures totals are populated even if pre-analysis detections lacked colors/track_ids."""
|
532
|
+
existing_store = getattr(self, '_color_total_track_ids', None)
|
533
|
+
if not isinstance(existing_store, defaultdict):
|
534
|
+
existing_store = {} if existing_store is None else dict(existing_store)
|
535
|
+
self._color_total_track_ids = defaultdict(set, existing_store)
|
536
|
+
else:
|
537
|
+
self._color_total_track_ids = existing_store
|
538
|
+
for rec in color_analysis:
|
539
|
+
cat = rec.get('category')
|
540
|
+
color = rec.get('main_color')
|
541
|
+
track_id = rec.get('track_id')
|
542
|
+
if track_id is None:
|
543
|
+
track_id = rec.get('detection_id')
|
544
|
+
if cat and track_id is not None:
|
545
|
+
key = f"{cat}:{color}" if color else cat
|
546
|
+
self._color_total_track_ids[key].add(track_id)
|
514
547
|
|
515
548
|
def _is_video_bytes(self, media_bytes: bytes) -> bool:
|
516
549
|
"""Determine if bytes represent a video file."""
|
@@ -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=
|
173
|
+
matrice/deploy/utils/post_processing/usecases/color_detection.py,sha256=W_cVLnGKKBmb67DFuuallK-nsyhOF8c05z-hMF2Mj-8,73018
|
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.
|
248
|
-
matrice-1.0.
|
249
|
-
matrice-1.0.
|
250
|
-
matrice-1.0.
|
251
|
-
matrice-1.0.
|
247
|
+
matrice-1.0.99305.dist-info/licenses/LICENSE.txt,sha256=2bm9uFabQZ3Ykb_SaSU_uUbAj2-htc6WJQmS_65qD00,1073
|
248
|
+
matrice-1.0.99305.dist-info/METADATA,sha256=OKlf6AV2qrkiHUdGqg-v_YFowjA4ZQq_osWhHvWtOW0,14624
|
249
|
+
matrice-1.0.99305.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
250
|
+
matrice-1.0.99305.dist-info/top_level.txt,sha256=P97js8ur6o5ClRqMH3Cjoab_NqbJ6sOQ3rJmVzKBvMc,8
|
251
|
+
matrice-1.0.99305.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|