matrice 1.0.99143__py3-none-any.whl → 1.0.99144__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.
@@ -305,6 +305,7 @@ class LaneDetectionUseCase(BaseProcessor):
305
305
 
306
306
  def _generate_tracking_stats(self, counting_summary: Dict, alerts: List, config: LaneDetectionConfig,
307
307
  frame_number: Optional[int] = None, stream_info: Optional[Dict[str, Any]] = None) -> List[Dict]:
308
+ """Generate structured tracking stats matching expected format."""
308
309
  camera_info = self.get_camera_info_from_stream(stream_info)
309
310
  tracking_stats = []
310
311
  total_detections = counting_summary.get("total_count", 0)
@@ -315,8 +316,13 @@ class LaneDetectionUseCase(BaseProcessor):
315
316
  high_precision_start_timestamp = self._get_current_timestamp_str(stream_info, precision=True)
316
317
  high_precision_reset_timestamp = self._get_start_timestamp_str(stream_info, precision=True)
317
318
 
318
- total_counts = [{"category": cat, "count": count} for cat, count in total_counts_dict.items() if count > 0]
319
- current_counts = [{"category": cat, "count": count} for cat, count in per_category_count.items() if count > 0 or total_detections > 0]
319
+ # Build total_counts and current_counts arrays
320
+ total_counts = [{"category": cat, "count": count} for cat, count in total_counts_dict.items()]
321
+ current_counts = [{"category": cat, "count": count} for cat, count in per_category_count.items()]
322
+
323
+ # Log counts for debugging
324
+ self.logger.debug(f"Total counts: {total_counts}")
325
+ self.logger.debug(f"Current counts: {current_counts}")
320
326
 
321
327
  detections = []
322
328
  for detection in counting_summary.get("detections", []):
@@ -343,7 +349,7 @@ class LaneDetectionUseCase(BaseProcessor):
343
349
  "threshold_level": config.alert_config.count_thresholds if hasattr(config.alert_config, 'count_thresholds') else {},
344
350
  "ascending": True,
345
351
  "settings": {t: v for t, v in zip(getattr(config.alert_config, 'alert_type', ['Default']),
346
- getattr(config.alert_config, 'alert_value', ['JSON']))}
352
+ getattr(config.alert_config, 'alert_value', ['JSON']))}
347
353
  })
348
354
 
349
355
  human_text_lines = [f"Tracking Statistics:"]
@@ -352,8 +358,7 @@ class LaneDetectionUseCase(BaseProcessor):
352
358
  human_text_lines.append(f"\t{cat}: {count}")
353
359
  human_text_lines.append(f"TOTAL SINCE {start_timestamp}")
354
360
  for cat, count in total_counts_dict.items():
355
- if count > 0:
356
- human_text_lines.append(f"\t{cat}: {count}")
361
+ human_text_lines.append(f"\t{cat}: {count}")
357
362
  if alerts:
358
363
  for alert in alerts:
359
364
  human_text_lines.append(f"Alerts: {alert.get('settings', {})} sent @ {current_timestamp}")
@@ -501,23 +506,34 @@ class LaneDetectionUseCase(BaseProcessor):
501
506
  return dt.strftime('%Y:%m:%d %H:%M:%S')
502
507
 
503
508
  def _count_categories(self, detections: list, config: LaneDetectionConfig) -> dict:
504
- counts = {}
509
+ """
510
+ Count the number of detections per category and return a summary dict.
511
+ """
512
+ counts = {cat: 0 for cat in self.target_categories} # Initialize with all target categories
513
+ valid_detections = []
514
+
505
515
  for det in detections:
506
516
  cat = det.get('category', 'unknown')
507
- counts[cat] = counts.get(cat, 0) + 1
517
+ # Normalize category to match target_categories
518
+ normalized_cat = cat.replace('-', ' ').title().replace(' ', '-') # e.g., "solid-line" -> "Solid-Line"
519
+ if normalized_cat not in self.target_categories:
520
+ self.logger.debug(f"Skipping detection with category {normalized_cat}, not in target categories")
521
+ continue
522
+ counts[normalized_cat] += 1
523
+ det['category'] = normalized_cat # Update detection with normalized category
524
+ valid_detections.append({
525
+ "bounding_box": det.get("bounding_box"),
526
+ "category": normalized_cat,
527
+ "confidence": det.get("confidence"),
528
+ "track_id": det.get("track_id"),
529
+ "frame_id": det.get("frame_id")
530
+ })
531
+ self.logger.debug(f"Counted detection for category {normalized_cat}, confidence {det.get('confidence')}")
532
+
508
533
  return {
509
534
  "total_count": sum(counts.values()),
510
535
  "per_category_count": counts,
511
- "detections": [
512
- {
513
- "bounding_box": det.get("bounding_box"),
514
- "category": det.get("category"),
515
- "confidence": det.get("confidence"),
516
- "track_id": det.get("track_id"),
517
- "frame_id": det.get("frame_id")
518
- }
519
- for det in detections
520
- ]
536
+ "detections": valid_detections
521
537
  }
522
538
 
523
539
  def _extract_predictions(self, detections: list) -> List[Dict[str, Any]]:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: matrice
3
- Version: 1.0.99143
3
+ Version: 1.0.99144
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
@@ -191,7 +191,7 @@ matrice/deploy/utils/post_processing/usecases/plaque_segmentation_img.py,sha256=
191
191
  matrice/deploy/utils/post_processing/usecases/pothole_segmentation.py,sha256=6Mv8SoEE5CGItY7S0g-SY5Lb3DV-WWVMlpEp04a86a8,43197
192
192
  matrice/deploy/utils/post_processing/usecases/ppe_compliance.py,sha256=G9P9j9E9nfNJInHJxmK1Lb4daFBlG5hq0aqotTLvFFE,30146
193
193
  matrice/deploy/utils/post_processing/usecases/price_tag_detection.py,sha256=Sn_Dvwf5f_dcfaiPIl-pqckgP8z96CeNIJ4hfeab3FM,39880
194
- matrice/deploy/utils/post_processing/usecases/road_lane_detection.py,sha256=VTPGU1Z2dnOo5x_bwsLY5VczJc_tLApptahxBcEASyo,30186
194
+ matrice/deploy/utils/post_processing/usecases/road_lane_detection.py,sha256=ljWoDeFJb0IJJPClYaZrNnBZd87JqKI64jE_I79GAYo,31146
195
195
  matrice/deploy/utils/post_processing/usecases/shelf_inventory_detection.py,sha256=1juloltHnCj3U499Aps0ggE0nEI37x3iKe4DgfP4RCw,29140
196
196
  matrice/deploy/utils/post_processing/usecases/shoplifting_detection.py,sha256=zqeV_ARV5gJqMY2sJGBjlU6UOb0SthGGbC8UNj_mycs,34701
197
197
  matrice/deploy/utils/post_processing/usecases/shopping_cart_analysis.py,sha256=9Ej2xiZM7yq5sOBcSXIllou_z0rSZDJ_QHyYz6HxZSY,43957
@@ -225,8 +225,8 @@ matrice/deployment/camera_manager.py,sha256=ReBZqm1CNXRImKcbcZ4uWAT3TUWkof1D28oB
225
225
  matrice/deployment/deployment.py,sha256=PLIUD-PxTaC2Zxb3Y12wUddsryV-OJetjCjLoSUh7S4,48103
226
226
  matrice/deployment/inference_pipeline.py,sha256=bXLgd29ViA7o0c7YWLFJl1otBUQfTPb61jS6VawQB0Y,37918
227
227
  matrice/deployment/streaming_gateway_manager.py,sha256=w5swGsuFVfZIdOm2ZuBHRHlRdYYJMLopLsf2gb91lQ8,20946
228
- matrice-1.0.99143.dist-info/licenses/LICENSE.txt,sha256=2bm9uFabQZ3Ykb_SaSU_uUbAj2-htc6WJQmS_65qD00,1073
229
- matrice-1.0.99143.dist-info/METADATA,sha256=PIYKGvaWzfWG2FSrUkwNmHpR4gNBQtlUg13zcFGtgN0,14624
230
- matrice-1.0.99143.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
231
- matrice-1.0.99143.dist-info/top_level.txt,sha256=P97js8ur6o5ClRqMH3Cjoab_NqbJ6sOQ3rJmVzKBvMc,8
232
- matrice-1.0.99143.dist-info/RECORD,,
228
+ matrice-1.0.99144.dist-info/licenses/LICENSE.txt,sha256=2bm9uFabQZ3Ykb_SaSU_uUbAj2-htc6WJQmS_65qD00,1073
229
+ matrice-1.0.99144.dist-info/METADATA,sha256=xF8gj0tJeJ-JY50BNsnZfd9LLxRif6dtncWMdvo1pE4,14624
230
+ matrice-1.0.99144.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
231
+ matrice-1.0.99144.dist-info/top_level.txt,sha256=P97js8ur6o5ClRqMH3Cjoab_NqbJ6sOQ3rJmVzKBvMc,8
232
+ matrice-1.0.99144.dist-info/RECORD,,