matrice 1.0.99253__py3-none-any.whl → 1.0.99255__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.
@@ -1,8 +1,7 @@
1
1
  """
2
- Crop Weed Detection Post-Processing Use Case
3
- ========================================================
4
- This module implements the Crop weed detection use case for crop weed detection.
5
- It processes detection results, applies category mapping, performs bbox smoothing, and generates alerts for detected weeds (yet to be implemented).
2
+ Crop weed detection usecase
3
+ This module provides functionality for detecting crops in images or video streams.
4
+
6
5
  """
7
6
 
8
7
  from typing import Any, Dict, List, Optional
@@ -29,7 +28,7 @@ from ..core.config import BaseConfig, AlertConfig, ZoneConfig
29
28
 
30
29
  @dataclass
31
30
  class CropWeedDetectionConfig(BaseConfig):
32
- """Configuration for crop weed detection use case in crop weed detection."""
31
+ """Configuration for crop weed detection use case."""
33
32
  # Smoothing configuration
34
33
  enable_smoothing: bool = True
35
34
  smoothing_algorithm: str = "observability" # "window" or "observability"
@@ -38,7 +37,7 @@ class CropWeedDetectionConfig(BaseConfig):
38
37
  smoothing_confidence_range_factor: float = 0.5
39
38
 
40
39
  # confidence thresholds
41
- confidence_threshold: float = 0.5
40
+ confidence_threshold: float = 0.4
42
41
 
43
42
  usecase_categories: List[str] = field(
44
43
  default_factory=lambda: ['plants', 'BroWeed', 'Maize', 'NarWeed']
@@ -52,20 +51,21 @@ class CropWeedDetectionConfig(BaseConfig):
52
51
 
53
52
  index_to_category: Optional[Dict[int, str]] = field(
54
53
  default_factory=lambda: {
55
- 0: 'plants',
56
- 1: 'BroWeed',
57
- 2: 'Maize',
54
+ 0: 'plants',
55
+ 1: 'BroWeed',
56
+ 2: 'Maize',
58
57
  3: 'NarWeed'
59
58
  }
60
59
  )
61
60
 
61
+
62
62
  class CropWeedDetectionUseCase(BaseProcessor):
63
63
  # Human-friendly display names for categories
64
64
  CATEGORY_DISPLAY = {
65
- "weed": "weed",
66
- "BroWeed": "BroWeed",
65
+ "plants": "Plants",
66
+ "BroWeed": "Bro Weed",
67
67
  "Maize": "Maize",
68
- "NarWeed": "NarWeed"
68
+ "NarWeed": "Nar Weed"
69
69
  }
70
70
  def __init__(self):
71
71
  super().__init__("crop_weed_detection")
@@ -77,6 +77,7 @@ class CropWeedDetectionUseCase(BaseProcessor):
77
77
  # List of categories to track
78
78
  self.target_categories = ['plants', 'BroWeed', 'Maize', 'NarWeed']
79
79
 
80
+
80
81
  # Initialize smoothing tracker
81
82
  self.smoothing_tracker = None
82
83
 
@@ -99,6 +100,7 @@ class CropWeedDetectionUseCase(BaseProcessor):
99
100
  self._ascending_alert_list: List[int] = []
100
101
  self.current_incident_end_timestamp: str = "N/A"
101
102
 
103
+
102
104
  def process(self, data: Any, config: ConfigProtocol, context: Optional[ProcessingContext] = None,
103
105
  stream_info: Optional[Dict[str, Any]] = None) -> ProcessingResult:
104
106
  """
@@ -124,7 +126,6 @@ class CropWeedDetectionUseCase(BaseProcessor):
124
126
  self.logger.debug(f"Applied confidence filtering with threshold {config.confidence_threshold}")
125
127
  else:
126
128
  processed_data = data
127
-
128
129
  self.logger.debug(f"Did not apply confidence filtering with threshold since nothing was provided")
129
130
 
130
131
  # Step 2: Apply category mapping if provided
@@ -150,11 +151,13 @@ class CropWeedDetectionUseCase(BaseProcessor):
150
151
  self.smoothing_tracker = BBoxSmoothingTracker(smoothing_config)
151
152
  processed_data = bbox_smoothing(processed_data, self.smoothing_tracker.config, self.smoothing_tracker)
152
153
 
154
+
153
155
  # Advanced tracking (BYTETracker-like)
154
156
  try:
155
157
  from ..advanced_tracker import AdvancedTracker
156
158
  from ..advanced_tracker.config import TrackerConfig
157
159
 
160
+ # Create tracker instance if it doesn't exist (preserves state across frames)
158
161
 
159
162
  if self.tracker is None:
160
163
  if config.confidence_threshold is not None:
@@ -445,22 +448,20 @@ class CropWeedDetectionUseCase(BaseProcessor):
445
448
 
446
449
  # Prepare detections without confidence scores (as per eg.json)
447
450
  detections = []
451
+
448
452
  for detection in counting_summary.get("detections", []):
449
- bbox = detection.get("bounding_box", {})
450
- category = detection.get("category", "person")
453
+ detection_data = {
454
+ "category": detection.get("category"),
455
+ "bounding_box": detection.get("bounding_box", {})
456
+ }
451
457
  # Include segmentation if available (like in eg.json)
452
458
  if detection.get("masks"):
453
- segmentation= detection.get("masks", [])
454
- detection_obj = self.create_detection_object(category, bbox, segmentation=segmentation)
455
- elif detection.get("segmentation"):
456
- segmentation= detection.get("segmentation")
457
- detection_obj = self.create_detection_object(category, bbox, segmentation=segmentation)
458
- elif detection.get("mask"):
459
- segmentation= detection.get("mask")
460
- detection_obj = self.create_detection_object(category, bbox, segmentation=segmentation)
461
- else:
462
- detection_obj = self.create_detection_object(category, bbox)
463
- detections.append(detection_obj)
459
+ detection_data["masks"] = detection.get("masks", [])
460
+ if detection.get("segmentation"):
461
+ detection_data["segmentation"] = detection.get("segmentation")
462
+ if detection.get("mask"):
463
+ detection_data["mask"] = detection.get("mask")
464
+ detections.append(detection_data)
464
465
 
465
466
  # Build alert_settings array in expected format
466
467
  alert_settings = []
@@ -511,7 +512,7 @@ class CropWeedDetectionUseCase(BaseProcessor):
511
512
 
512
513
  tracking_stats.append(tracking_stat)
513
514
  return tracking_stats
514
-
515
+
515
516
  def _generate_business_analytics(self, counting_summary: Dict, alerts:Any, config: CropWeedDetectionConfig, stream_info: Optional[Dict[str, Any]] = None, is_empty=False) -> List[Dict]:
516
517
  """Generate standardized business analytics for the agg_summary structure."""
517
518
  if is_empty:
@@ -596,7 +597,7 @@ class CropWeedDetectionUseCase(BaseProcessor):
596
597
  """
597
598
  return {cat: len(ids) for cat, ids in getattr(self, '_per_category_total_track_ids', {}).items()}
598
599
 
599
-
600
+
600
601
  def _format_timestamp_for_stream(self, timestamp: float) -> str:
601
602
  """Format timestamp for streams (YYYY:MM:DD HH:MM:SS format)."""
602
603
  dt = datetime.fromtimestamp(timestamp, tz=timezone.utc)
@@ -683,8 +684,7 @@ class CropWeedDetectionUseCase(BaseProcessor):
683
684
  # Reset minutes and seconds to 00:00 for "TOTAL SINCE" format
684
685
  dt = dt.replace(minute=0, second=0, microsecond=0)
685
686
  return dt.strftime('%Y:%m:%d %H:%M:%S')
686
-
687
-
687
+
688
688
  def _count_categories(self, detections: list, config: CropWeedDetectionConfig) -> dict:
689
689
  """
690
690
  Count the number of detections per category and return a summary dict.
@@ -711,6 +711,7 @@ class CropWeedDetectionUseCase(BaseProcessor):
711
711
  ]
712
712
  }
713
713
 
714
+
714
715
  def _extract_predictions(self, detections: list) -> List[Dict[str, Any]]:
715
716
  """
716
717
  Extract prediction details for output (category, confidence, bounding box).
@@ -422,7 +422,7 @@ class IntrusionUseCase(BaseProcessor):
422
422
  self._ascending_alert_list.append(0)
423
423
 
424
424
  human_text_lines.append(f"\t\t- Zone name: {zone_name}")
425
- human_text_lines.append(f"\t\t\t- Total count in Prohibited Boarding Gate: {zone_total}")
425
+ human_text_lines.append(f"\t\t\t- Total count in Prohibited Boarding Gate: {zone_total-1}")
426
426
  # Main people counting incident
427
427
  human_text = "\n".join(human_text_lines)
428
428
  event = self.create_incident(incident_id=self.CASE_TYPE+'_'+'zone_'+zone_name+str(frame_id), incident_type=self.CASE_TYPE,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: matrice
3
- Version: 1.0.99253
3
+ Version: 1.0.99255
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
@@ -172,7 +172,7 @@ matrice/deploy/utils/post_processing/usecases/child_monitoring.py,sha256=z3oymoq
172
172
  matrice/deploy/utils/post_processing/usecases/color_detection.py,sha256=Z8-akjy8a7f8YyiOzXu_Zi1Km30v-TRrymDqQOPpJ_8,43277
173
173
  matrice/deploy/utils/post_processing/usecases/color_map_utils.py,sha256=SP-AEVcjLmL8rxblu-ixqUJC2fqlcr7ab4hWo4Fcr_k,2677
174
174
  matrice/deploy/utils/post_processing/usecases/concrete_crack_detection.py,sha256=pxhOH_hG4hq9yytNepbGMdk2W_lTG8D1_2RAagaPBkg,40252
175
- matrice/deploy/utils/post_processing/usecases/crop_weed_detection.py,sha256=RtKEDbkejHYeNcsSR8hCzqYinBtlGYtBsEdqaR6Kw0s,40518
175
+ matrice/deploy/utils/post_processing/usecases/crop_weed_detection.py,sha256=YIbUYkphDtCZl6u1nFpPc8rdzgoufBAtaeHYzraZw4Q,40051
176
176
  matrice/deploy/utils/post_processing/usecases/customer_service.py,sha256=UWS83qxguyAyhh8a0JF5QH9DtKxO8I-gI2BPOjLPxBw,44642
177
177
  matrice/deploy/utils/post_processing/usecases/defect_detection_products.py,sha256=blvo4wmak-wlvPSZOcmRsV1FoZSeGX_dUAX5A1WheBE,45949
178
178
  matrice/deploy/utils/post_processing/usecases/distracted_driver_detection.py,sha256=rkyYHbmcYUAfKbmmKyKxHlk47vJ_fogHWKhQjrERsok,40316
@@ -188,7 +188,7 @@ matrice/deploy/utils/post_processing/usecases/flower_segmentation.py,sha256=4I7q
188
188
  matrice/deploy/utils/post_processing/usecases/gas_leak_detection.py,sha256=KL2ft7fXvjTas-65-QgcJm3W8KBsrwF44qibSXjfaLc,40557
189
189
  matrice/deploy/utils/post_processing/usecases/gender_detection.py,sha256=DEnCTRew6B7DtPcBQVCTtpd_IQMvMusBcu6nadUg2oM,40107
190
190
  matrice/deploy/utils/post_processing/usecases/human_activity_recognition.py,sha256=SLyvbw1y_nEQ0AlT-ErpeSydjA8U5yfRPrjMx1t3Yz0,42226
191
- matrice/deploy/utils/post_processing/usecases/intrusion_detection.py,sha256=Aa2wX-rq_S5aC5JDh7O_hCFPyHGPxWRDG2LIvOKZeHY,77439
191
+ matrice/deploy/utils/post_processing/usecases/intrusion_detection.py,sha256=_n9K1RKFWTm9hBqtu1VfXlW_CV7M2rNhoj3ZRH9o7CY,77441
192
192
  matrice/deploy/utils/post_processing/usecases/leaf.py,sha256=cwgB1ZNxkQFtkk-thSJrkXOGou1ghJr1kqtopb3sLD4,37036
193
193
  matrice/deploy/utils/post_processing/usecases/leaf_disease.py,sha256=bkiLccTdf4KUq3he4eCpBlKXb5exr-WBhQ_oWQ7os68,36225
194
194
  matrice/deploy/utils/post_processing/usecases/leak_detection.py,sha256=oOCLLVMuXVeXPHyN8FUrD3U9JYJJwIz-5fcEMgvLdls,40531
@@ -243,8 +243,8 @@ matrice/deployment/camera_manager.py,sha256=e1Lc81RJP5wUWRdTgHO6tMWF9BkBdHOSVyx3
243
243
  matrice/deployment/deployment.py,sha256=HFt151eWq6iqIAMsQvurpV2WNxW6Cx_gIUVfnVy5SWE,48093
244
244
  matrice/deployment/inference_pipeline.py,sha256=6b4Mm3-qt-Zy0BeiJfFQdImOn3FzdNCY-7ET7Rp8PMk,37911
245
245
  matrice/deployment/streaming_gateway_manager.py,sha256=ifYGl3g25wyU39HwhPQyI2OgF3M6oIqKMWt8RXtMxY8,21401
246
- matrice-1.0.99253.dist-info/licenses/LICENSE.txt,sha256=2bm9uFabQZ3Ykb_SaSU_uUbAj2-htc6WJQmS_65qD00,1073
247
- matrice-1.0.99253.dist-info/METADATA,sha256=9FdVZ2DcVsy7GKrVOFax7xL9qx3PJr8wZoEw-1D6FrY,14624
248
- matrice-1.0.99253.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
249
- matrice-1.0.99253.dist-info/top_level.txt,sha256=P97js8ur6o5ClRqMH3Cjoab_NqbJ6sOQ3rJmVzKBvMc,8
250
- matrice-1.0.99253.dist-info/RECORD,,
246
+ matrice-1.0.99255.dist-info/licenses/LICENSE.txt,sha256=2bm9uFabQZ3Ykb_SaSU_uUbAj2-htc6WJQmS_65qD00,1073
247
+ matrice-1.0.99255.dist-info/METADATA,sha256=v_yQ2u8YKOtrf4yaRhJeymi4iWu6uqPSh5I9IrF8vlw,14624
248
+ matrice-1.0.99255.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
249
+ matrice-1.0.99255.dist-info/top_level.txt,sha256=P97js8ur6o5ClRqMH3Cjoab_NqbJ6sOQ3rJmVzKBvMc,8
250
+ matrice-1.0.99255.dist-info/RECORD,,