matrice-analytics 0.1.60__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.
Files changed (196) hide show
  1. matrice_analytics/__init__.py +28 -0
  2. matrice_analytics/boundary_drawing_internal/README.md +305 -0
  3. matrice_analytics/boundary_drawing_internal/__init__.py +45 -0
  4. matrice_analytics/boundary_drawing_internal/boundary_drawing_internal.py +1207 -0
  5. matrice_analytics/boundary_drawing_internal/boundary_drawing_tool.py +429 -0
  6. matrice_analytics/boundary_drawing_internal/boundary_tool_template.html +1036 -0
  7. matrice_analytics/boundary_drawing_internal/data/.gitignore +12 -0
  8. matrice_analytics/boundary_drawing_internal/example_usage.py +206 -0
  9. matrice_analytics/boundary_drawing_internal/usage/README.md +110 -0
  10. matrice_analytics/boundary_drawing_internal/usage/boundary_drawer_launcher.py +102 -0
  11. matrice_analytics/boundary_drawing_internal/usage/simple_boundary_launcher.py +107 -0
  12. matrice_analytics/post_processing/README.md +455 -0
  13. matrice_analytics/post_processing/__init__.py +732 -0
  14. matrice_analytics/post_processing/advanced_tracker/README.md +650 -0
  15. matrice_analytics/post_processing/advanced_tracker/__init__.py +17 -0
  16. matrice_analytics/post_processing/advanced_tracker/base.py +99 -0
  17. matrice_analytics/post_processing/advanced_tracker/config.py +77 -0
  18. matrice_analytics/post_processing/advanced_tracker/kalman_filter.py +370 -0
  19. matrice_analytics/post_processing/advanced_tracker/matching.py +195 -0
  20. matrice_analytics/post_processing/advanced_tracker/strack.py +230 -0
  21. matrice_analytics/post_processing/advanced_tracker/tracker.py +367 -0
  22. matrice_analytics/post_processing/config.py +146 -0
  23. matrice_analytics/post_processing/core/__init__.py +63 -0
  24. matrice_analytics/post_processing/core/base.py +704 -0
  25. matrice_analytics/post_processing/core/config.py +3291 -0
  26. matrice_analytics/post_processing/core/config_utils.py +925 -0
  27. matrice_analytics/post_processing/face_reg/__init__.py +43 -0
  28. matrice_analytics/post_processing/face_reg/compare_similarity.py +556 -0
  29. matrice_analytics/post_processing/face_reg/embedding_manager.py +950 -0
  30. matrice_analytics/post_processing/face_reg/face_recognition.py +2234 -0
  31. matrice_analytics/post_processing/face_reg/face_recognition_client.py +606 -0
  32. matrice_analytics/post_processing/face_reg/people_activity_logging.py +321 -0
  33. matrice_analytics/post_processing/ocr/__init__.py +0 -0
  34. matrice_analytics/post_processing/ocr/easyocr_extractor.py +250 -0
  35. matrice_analytics/post_processing/ocr/fast_plate_ocr_py38/__init__.py +9 -0
  36. matrice_analytics/post_processing/ocr/fast_plate_ocr_py38/cli/__init__.py +4 -0
  37. matrice_analytics/post_processing/ocr/fast_plate_ocr_py38/cli/cli.py +33 -0
  38. matrice_analytics/post_processing/ocr/fast_plate_ocr_py38/cli/dataset_stats.py +139 -0
  39. matrice_analytics/post_processing/ocr/fast_plate_ocr_py38/cli/export.py +398 -0
  40. matrice_analytics/post_processing/ocr/fast_plate_ocr_py38/cli/train.py +447 -0
  41. matrice_analytics/post_processing/ocr/fast_plate_ocr_py38/cli/utils.py +129 -0
  42. matrice_analytics/post_processing/ocr/fast_plate_ocr_py38/cli/valid.py +93 -0
  43. matrice_analytics/post_processing/ocr/fast_plate_ocr_py38/cli/validate_dataset.py +240 -0
  44. matrice_analytics/post_processing/ocr/fast_plate_ocr_py38/cli/visualize_augmentation.py +176 -0
  45. matrice_analytics/post_processing/ocr/fast_plate_ocr_py38/cli/visualize_predictions.py +96 -0
  46. matrice_analytics/post_processing/ocr/fast_plate_ocr_py38/core/__init__.py +3 -0
  47. matrice_analytics/post_processing/ocr/fast_plate_ocr_py38/core/process.py +246 -0
  48. matrice_analytics/post_processing/ocr/fast_plate_ocr_py38/core/types.py +60 -0
  49. matrice_analytics/post_processing/ocr/fast_plate_ocr_py38/core/utils.py +87 -0
  50. matrice_analytics/post_processing/ocr/fast_plate_ocr_py38/inference/__init__.py +3 -0
  51. matrice_analytics/post_processing/ocr/fast_plate_ocr_py38/inference/config.py +82 -0
  52. matrice_analytics/post_processing/ocr/fast_plate_ocr_py38/inference/hub.py +141 -0
  53. matrice_analytics/post_processing/ocr/fast_plate_ocr_py38/inference/plate_recognizer.py +323 -0
  54. matrice_analytics/post_processing/ocr/fast_plate_ocr_py38/py.typed +0 -0
  55. matrice_analytics/post_processing/ocr/fast_plate_ocr_py38/train/__init__.py +0 -0
  56. matrice_analytics/post_processing/ocr/fast_plate_ocr_py38/train/data/__init__.py +0 -0
  57. matrice_analytics/post_processing/ocr/fast_plate_ocr_py38/train/data/augmentation.py +101 -0
  58. matrice_analytics/post_processing/ocr/fast_plate_ocr_py38/train/data/dataset.py +97 -0
  59. matrice_analytics/post_processing/ocr/fast_plate_ocr_py38/train/model/__init__.py +0 -0
  60. matrice_analytics/post_processing/ocr/fast_plate_ocr_py38/train/model/config.py +114 -0
  61. matrice_analytics/post_processing/ocr/fast_plate_ocr_py38/train/model/layers.py +553 -0
  62. matrice_analytics/post_processing/ocr/fast_plate_ocr_py38/train/model/loss.py +55 -0
  63. matrice_analytics/post_processing/ocr/fast_plate_ocr_py38/train/model/metric.py +86 -0
  64. matrice_analytics/post_processing/ocr/fast_plate_ocr_py38/train/model/model_builders.py +95 -0
  65. matrice_analytics/post_processing/ocr/fast_plate_ocr_py38/train/model/model_schema.py +395 -0
  66. matrice_analytics/post_processing/ocr/fast_plate_ocr_py38/train/utilities/__init__.py +0 -0
  67. matrice_analytics/post_processing/ocr/fast_plate_ocr_py38/train/utilities/backend_utils.py +38 -0
  68. matrice_analytics/post_processing/ocr/fast_plate_ocr_py38/train/utilities/utils.py +214 -0
  69. matrice_analytics/post_processing/ocr/postprocessing.py +270 -0
  70. matrice_analytics/post_processing/ocr/preprocessing.py +52 -0
  71. matrice_analytics/post_processing/post_processor.py +1175 -0
  72. matrice_analytics/post_processing/test_cases/__init__.py +1 -0
  73. matrice_analytics/post_processing/test_cases/run_tests.py +143 -0
  74. matrice_analytics/post_processing/test_cases/test_advanced_customer_service.py +841 -0
  75. matrice_analytics/post_processing/test_cases/test_basic_counting_tracking.py +523 -0
  76. matrice_analytics/post_processing/test_cases/test_comprehensive.py +531 -0
  77. matrice_analytics/post_processing/test_cases/test_config.py +852 -0
  78. matrice_analytics/post_processing/test_cases/test_customer_service.py +585 -0
  79. matrice_analytics/post_processing/test_cases/test_data_generators.py +583 -0
  80. matrice_analytics/post_processing/test_cases/test_people_counting.py +510 -0
  81. matrice_analytics/post_processing/test_cases/test_processor.py +524 -0
  82. matrice_analytics/post_processing/test_cases/test_usecases.py +165 -0
  83. matrice_analytics/post_processing/test_cases/test_utilities.py +356 -0
  84. matrice_analytics/post_processing/test_cases/test_utils.py +743 -0
  85. matrice_analytics/post_processing/usecases/Histopathological_Cancer_Detection_img.py +604 -0
  86. matrice_analytics/post_processing/usecases/__init__.py +267 -0
  87. matrice_analytics/post_processing/usecases/abandoned_object_detection.py +797 -0
  88. matrice_analytics/post_processing/usecases/advanced_customer_service.py +1601 -0
  89. matrice_analytics/post_processing/usecases/age_detection.py +842 -0
  90. matrice_analytics/post_processing/usecases/age_gender_detection.py +1085 -0
  91. matrice_analytics/post_processing/usecases/anti_spoofing_detection.py +656 -0
  92. matrice_analytics/post_processing/usecases/assembly_line_detection.py +841 -0
  93. matrice_analytics/post_processing/usecases/banana_defect_detection.py +624 -0
  94. matrice_analytics/post_processing/usecases/basic_counting_tracking.py +667 -0
  95. matrice_analytics/post_processing/usecases/blood_cancer_detection_img.py +881 -0
  96. matrice_analytics/post_processing/usecases/car_damage_detection.py +834 -0
  97. matrice_analytics/post_processing/usecases/car_part_segmentation.py +946 -0
  98. matrice_analytics/post_processing/usecases/car_service.py +1601 -0
  99. matrice_analytics/post_processing/usecases/cardiomegaly_classification.py +864 -0
  100. matrice_analytics/post_processing/usecases/cell_microscopy_segmentation.py +897 -0
  101. matrice_analytics/post_processing/usecases/chicken_pose_detection.py +648 -0
  102. matrice_analytics/post_processing/usecases/child_monitoring.py +814 -0
  103. matrice_analytics/post_processing/usecases/color/clip.py +660 -0
  104. matrice_analytics/post_processing/usecases/color/clip_processor/merges.txt +48895 -0
  105. matrice_analytics/post_processing/usecases/color/clip_processor/preprocessor_config.json +28 -0
  106. matrice_analytics/post_processing/usecases/color/clip_processor/special_tokens_map.json +30 -0
  107. matrice_analytics/post_processing/usecases/color/clip_processor/tokenizer.json +245079 -0
  108. matrice_analytics/post_processing/usecases/color/clip_processor/tokenizer_config.json +32 -0
  109. matrice_analytics/post_processing/usecases/color/clip_processor/vocab.json +1 -0
  110. matrice_analytics/post_processing/usecases/color/color_map_utils.py +70 -0
  111. matrice_analytics/post_processing/usecases/color/color_mapper.py +468 -0
  112. matrice_analytics/post_processing/usecases/color_detection.py +1936 -0
  113. matrice_analytics/post_processing/usecases/color_map_utils.py +70 -0
  114. matrice_analytics/post_processing/usecases/concrete_crack_detection.py +827 -0
  115. matrice_analytics/post_processing/usecases/crop_weed_detection.py +781 -0
  116. matrice_analytics/post_processing/usecases/customer_service.py +1008 -0
  117. matrice_analytics/post_processing/usecases/defect_detection_products.py +936 -0
  118. matrice_analytics/post_processing/usecases/distracted_driver_detection.py +822 -0
  119. matrice_analytics/post_processing/usecases/drone_traffic_monitoring.py +585 -0
  120. matrice_analytics/post_processing/usecases/drowsy_driver_detection.py +829 -0
  121. matrice_analytics/post_processing/usecases/dwell_detection.py +829 -0
  122. matrice_analytics/post_processing/usecases/emergency_vehicle_detection.py +827 -0
  123. matrice_analytics/post_processing/usecases/face_emotion.py +813 -0
  124. matrice_analytics/post_processing/usecases/face_recognition.py +827 -0
  125. matrice_analytics/post_processing/usecases/fashion_detection.py +835 -0
  126. matrice_analytics/post_processing/usecases/field_mapping.py +902 -0
  127. matrice_analytics/post_processing/usecases/fire_detection.py +1146 -0
  128. matrice_analytics/post_processing/usecases/flare_analysis.py +836 -0
  129. matrice_analytics/post_processing/usecases/flower_segmentation.py +1006 -0
  130. matrice_analytics/post_processing/usecases/gas_leak_detection.py +837 -0
  131. matrice_analytics/post_processing/usecases/gender_detection.py +832 -0
  132. matrice_analytics/post_processing/usecases/human_activity_recognition.py +871 -0
  133. matrice_analytics/post_processing/usecases/intrusion_detection.py +1672 -0
  134. matrice_analytics/post_processing/usecases/leaf.py +821 -0
  135. matrice_analytics/post_processing/usecases/leaf_disease.py +840 -0
  136. matrice_analytics/post_processing/usecases/leak_detection.py +837 -0
  137. matrice_analytics/post_processing/usecases/license_plate_detection.py +1188 -0
  138. matrice_analytics/post_processing/usecases/license_plate_monitoring.py +1781 -0
  139. matrice_analytics/post_processing/usecases/litter_monitoring.py +717 -0
  140. matrice_analytics/post_processing/usecases/mask_detection.py +869 -0
  141. matrice_analytics/post_processing/usecases/natural_disaster.py +907 -0
  142. matrice_analytics/post_processing/usecases/parking.py +787 -0
  143. matrice_analytics/post_processing/usecases/parking_space_detection.py +822 -0
  144. matrice_analytics/post_processing/usecases/pcb_defect_detection.py +888 -0
  145. matrice_analytics/post_processing/usecases/pedestrian_detection.py +808 -0
  146. matrice_analytics/post_processing/usecases/people_counting.py +706 -0
  147. matrice_analytics/post_processing/usecases/people_counting_bckp.py +1683 -0
  148. matrice_analytics/post_processing/usecases/people_tracking.py +1842 -0
  149. matrice_analytics/post_processing/usecases/pipeline_detection.py +605 -0
  150. matrice_analytics/post_processing/usecases/plaque_segmentation_img.py +874 -0
  151. matrice_analytics/post_processing/usecases/pothole_segmentation.py +915 -0
  152. matrice_analytics/post_processing/usecases/ppe_compliance.py +645 -0
  153. matrice_analytics/post_processing/usecases/price_tag_detection.py +822 -0
  154. matrice_analytics/post_processing/usecases/proximity_detection.py +1901 -0
  155. matrice_analytics/post_processing/usecases/road_lane_detection.py +623 -0
  156. matrice_analytics/post_processing/usecases/road_traffic_density.py +832 -0
  157. matrice_analytics/post_processing/usecases/road_view_segmentation.py +915 -0
  158. matrice_analytics/post_processing/usecases/shelf_inventory_detection.py +583 -0
  159. matrice_analytics/post_processing/usecases/shoplifting_detection.py +822 -0
  160. matrice_analytics/post_processing/usecases/shopping_cart_analysis.py +899 -0
  161. matrice_analytics/post_processing/usecases/skin_cancer_classification_img.py +864 -0
  162. matrice_analytics/post_processing/usecases/smoker_detection.py +833 -0
  163. matrice_analytics/post_processing/usecases/solar_panel.py +810 -0
  164. matrice_analytics/post_processing/usecases/suspicious_activity_detection.py +1030 -0
  165. matrice_analytics/post_processing/usecases/template_usecase.py +380 -0
  166. matrice_analytics/post_processing/usecases/theft_detection.py +648 -0
  167. matrice_analytics/post_processing/usecases/traffic_sign_monitoring.py +724 -0
  168. matrice_analytics/post_processing/usecases/underground_pipeline_defect_detection.py +775 -0
  169. matrice_analytics/post_processing/usecases/underwater_pollution_detection.py +842 -0
  170. matrice_analytics/post_processing/usecases/vehicle_monitoring.py +1029 -0
  171. matrice_analytics/post_processing/usecases/warehouse_object_segmentation.py +899 -0
  172. matrice_analytics/post_processing/usecases/waterbody_segmentation.py +923 -0
  173. matrice_analytics/post_processing/usecases/weapon_detection.py +771 -0
  174. matrice_analytics/post_processing/usecases/weld_defect_detection.py +615 -0
  175. matrice_analytics/post_processing/usecases/wildlife_monitoring.py +898 -0
  176. matrice_analytics/post_processing/usecases/windmill_maintenance.py +834 -0
  177. matrice_analytics/post_processing/usecases/wound_segmentation.py +856 -0
  178. matrice_analytics/post_processing/utils/__init__.py +150 -0
  179. matrice_analytics/post_processing/utils/advanced_counting_utils.py +400 -0
  180. matrice_analytics/post_processing/utils/advanced_helper_utils.py +317 -0
  181. matrice_analytics/post_processing/utils/advanced_tracking_utils.py +461 -0
  182. matrice_analytics/post_processing/utils/alerting_utils.py +213 -0
  183. matrice_analytics/post_processing/utils/category_mapping_utils.py +94 -0
  184. matrice_analytics/post_processing/utils/color_utils.py +592 -0
  185. matrice_analytics/post_processing/utils/counting_utils.py +182 -0
  186. matrice_analytics/post_processing/utils/filter_utils.py +261 -0
  187. matrice_analytics/post_processing/utils/format_utils.py +293 -0
  188. matrice_analytics/post_processing/utils/geometry_utils.py +300 -0
  189. matrice_analytics/post_processing/utils/smoothing_utils.py +358 -0
  190. matrice_analytics/post_processing/utils/tracking_utils.py +234 -0
  191. matrice_analytics/py.typed +0 -0
  192. matrice_analytics-0.1.60.dist-info/METADATA +481 -0
  193. matrice_analytics-0.1.60.dist-info/RECORD +196 -0
  194. matrice_analytics-0.1.60.dist-info/WHEEL +5 -0
  195. matrice_analytics-0.1.60.dist-info/licenses/LICENSE.txt +21 -0
  196. matrice_analytics-0.1.60.dist-info/top_level.txt +1 -0
@@ -0,0 +1,925 @@
1
+ """
2
+ Configuration utilities for easy post-processing setup.
3
+
4
+ This module provides convenient functions for creating common post-processing configurations
5
+ without needing to understand the complex configuration structure.
6
+ """
7
+
8
+ from typing import Dict, List, Any, Tuple, Optional, Union
9
+ from pathlib import Path
10
+ import json
11
+
12
+ from .config import (
13
+ PeopleCountingConfig,
14
+ CustomerServiceConfig,
15
+ IntrusionConfig,
16
+ ProximityConfig,
17
+ ZoneConfig,
18
+ TrackingConfig,
19
+ AlertConfig,
20
+ config_manager,
21
+ PeopleTrackingConfig,
22
+ LineConfig,
23
+
24
+ )
25
+
26
+ # Note: BasicCountingTrackingConfig import moved to function level to avoid circular imports
27
+
28
+
29
+ def create_people_counting_config(
30
+ confidence_threshold: float = 0.5,
31
+ zones: Optional[Dict[str, List[List[float]]]] = None,
32
+ person_categories: Optional[List[str]] = None,
33
+ enable_tracking: bool = False,
34
+ time_window_minutes: int = 60,
35
+ alert_thresholds: Optional[Dict[str, int]] = None,
36
+ category: str = "general",
37
+ **kwargs
38
+ ) -> PeopleCountingConfig:
39
+ """
40
+ Create a people counting configuration with sensible defaults.
41
+
42
+ Args:
43
+ confidence_threshold: Minimum confidence for detections (0.0-1.0)
44
+ zones: Dictionary of zone_name -> polygon points [[x1,y1], [x2,y2], ...]
45
+ person_categories: List of category names that represent people
46
+ enable_tracking: Whether to enable object tracking
47
+ time_window_minutes: Time window for counting statistics
48
+ alert_thresholds: Dictionary of zone_name -> max_count for alerts
49
+ category: Use case category
50
+ **kwargs: Additional configuration parameters
51
+
52
+ Returns:
53
+ PeopleCountingConfig: Configured people counting configuration
54
+
55
+ Example:
56
+ config = create_people_counting_config(
57
+ confidence_threshold=0.6,
58
+ zones={
59
+ "entrance": [[0, 0], [100, 0], [100, 100], [0, 100]],
60
+ "exit": [[200, 0], [300, 0], [300, 100], [200, 100]]
61
+ },
62
+ alert_thresholds={"entrance": 10, "exit": 5}
63
+ )
64
+ """
65
+ # Create zone configuration if zones provided
66
+ zone_config = None
67
+ if zones:
68
+ zone_config = ZoneConfig(zones=zones)
69
+
70
+ # Create alert configuration if thresholds provided
71
+ alert_config = None
72
+ if alert_thresholds:
73
+ alert_config = AlertConfig(count_thresholds=alert_thresholds)
74
+
75
+ return PeopleCountingConfig(
76
+ category=category,
77
+ usecase="people_counting",
78
+ confidence_threshold=confidence_threshold,
79
+ zone_config=zone_config,
80
+ person_categories=person_categories or ["person", "people"],
81
+ enable_tracking=enable_tracking,
82
+ time_window_minutes=time_window_minutes,
83
+ alert_config=alert_config,
84
+ **kwargs
85
+ )
86
+
87
+
88
+ def create_people_tracking_config(
89
+ confidence_threshold: float = 0.5,
90
+ zones: Optional[Dict[str, List[List[float]]]] = None,
91
+ line_config: Optional[Dict[str, Any]] = None,
92
+ person_categories: Optional[List[str]] = None,
93
+ enable_tracking: bool = True,
94
+ enable_unique_counting: bool = True,
95
+ time_window_minutes: int = 60,
96
+ count_thresholds: Optional[Dict[str, int]] = None,
97
+ occupancy_thresholds: Optional[Dict[str, int]] = None,
98
+ crossing_thresholds: Optional[Dict[str, int]] = None,
99
+ enable_smoothing: bool = False,
100
+ smoothing_algorithm: str = "kalman",
101
+ smoothing_window_size: int = 5,
102
+ smoothing_cooldown_frames: int = 10,
103
+ smoothing_confidence_range_factor: float = 0.2,
104
+ category: str = "general",
105
+ alert_type: Optional[List[str]] = None,
106
+ alert_value: Optional[List[str]] = None,
107
+ alert_incident_category: Optional[List[str]] = None,
108
+ **kwargs
109
+ ) -> PeopleTrackingConfig:
110
+ """
111
+ Create a people tracking configuration with sensible defaults.
112
+
113
+ Args:
114
+ confidence_threshold: Minimum confidence for detections (0.0-1.0)
115
+ zones: Dictionary of zone_name -> polygon points [[x1,y1], [x2,y2], ...]
116
+ line_config: Dictionary defining line crossing configuration (e.g., {"points": [[x1,y1], [x2,y2]], "side1_label": "Outside", "side2_label": "Inside"})
117
+ person_categories: List of category names that represent people
118
+ enable_tracking: Whether to enable object tracking
119
+ enable_unique_counting: Whether to enable unique people counting
120
+ time_window_minutes: Time window for tracking statistics
121
+ count_thresholds: Dictionary of category -> max_count for alerts
122
+ occupancy_thresholds: Dictionary of zone_name -> max_count for zone occupancy alerts
123
+ crossing_thresholds: Dictionary of direction (e.g., 'side1_to_side2') -> max_count for line crossing alerts
124
+ enable_smoothing: Whether to enable bounding box smoothing
125
+ smoothing_algorithm: Algorithm for smoothing (e.g., 'kalman')
126
+ smoothing_window_size: Number of frames for smoothing window
127
+ smoothing_cooldown_frames: Frames to wait before re-smoothing
128
+ smoothing_confidence_range_factor: Factor for confidence range in smoothing
129
+ category: Use case category
130
+ alert_type: List of alert types (e.g., ['email', 'sms'])
131
+ alert_value: List of alert values corresponding to alert types (e.g., ['user@example.com'])
132
+ alert_incident_category: List of alert incident categories (e.g., ['Tracking Alert'])
133
+ **kwargs: Additional configuration parameters
134
+
135
+ Returns:
136
+ PeopleTrackingConfig: Configured people tracking configuration
137
+
138
+ Example:
139
+ config = create_people_tracking_config(
140
+ confidence_threshold=0.6,
141
+ zones={
142
+ "entrance": [[0, 0], [100, 0], [100, 100], [0, 100]],
143
+ "exit": [[200, 0], [300, 0], [300, 100], [200, 100]]
144
+ },
145
+ line_config={
146
+ "points": [[100, 200], [300, 200]],
147
+ "side1_label": "Outside",
148
+ "side2_label": "Inside"
149
+ },
150
+ count_thresholds={"all": 10},
151
+ occupancy_thresholds={"entrance": 5, "exit": 3},
152
+ crossing_thresholds={"side1_to_side2": 2, "side2_to_side1": 2},
153
+ enable_tracking=True,
154
+ enable_smoothing=True
155
+ )
156
+ """
157
+ # Create zone configuration if zones provided
158
+ zone_config = None
159
+ if zones:
160
+ zone_config = ZoneConfig(zones=zones)
161
+
162
+ # Create line configuration if line_config provided
163
+ line_config_obj = None
164
+ if line_config:
165
+ line_config_obj = LineConfig(
166
+ points=line_config.get("points", []),
167
+ side1_label=line_config.get("side1_label", "Side A"),
168
+ side2_label=line_config.get("side2_label", "Side B")
169
+ )
170
+
171
+ # Create alert configuration if any thresholds provided
172
+ alert_config = None
173
+ if count_thresholds or occupancy_thresholds or crossing_thresholds or alert_type or alert_value or alert_incident_category:
174
+ alert_config = AlertConfig(
175
+ count_thresholds=count_thresholds or {},
176
+ occupancy_thresholds=occupancy_thresholds or {},
177
+ crossing_thresholds=crossing_thresholds or {},
178
+ alert_type=alert_type or ["Default"],
179
+ alert_value=alert_value or ["JSON"],
180
+ alert_incident_category=alert_incident_category or ["Incident Detection Alert"]
181
+ )
182
+
183
+ return PeopleTrackingConfig(
184
+ category=category,
185
+ usecase="people_tracking",
186
+ confidence_threshold=confidence_threshold,
187
+ zone_config=zone_config,
188
+ line_config=line_config_obj,
189
+ person_categories=person_categories or ["person", "people"],
190
+ enable_tracking=enable_tracking,
191
+ enable_unique_counting=enable_unique_counting,
192
+ time_window_minutes=time_window_minutes,
193
+ alert_config=alert_config,
194
+ enable_smoothing=enable_smoothing,
195
+ smoothing_algorithm=smoothing_algorithm,
196
+ smoothing_window_size=smoothing_window_size,
197
+ smoothing_cooldown_frames=smoothing_cooldown_frames,
198
+ smoothing_confidence_range_factor=smoothing_confidence_range_factor,
199
+ **kwargs
200
+ )
201
+
202
+ def create_intrusion_detection_config(
203
+ confidence_threshold: float = 0.5,
204
+ zones: Optional[Dict[str, List[List[float]]]] = None,
205
+ person_categories: Optional[List[str]] = None,
206
+ enable_tracking: bool = False,
207
+ time_window_minutes: int = 60,
208
+ alert_thresholds: Optional[Dict[str, int]] = None,
209
+ category: str = "security",
210
+ **kwargs
211
+ ) -> IntrusionConfig:
212
+ """
213
+ Create a intrusion detection configuration with sensible defaults.
214
+
215
+ Args:
216
+ confidence_threshold: Minimum confidence for detections (0.0-1.0)
217
+ zones: Dictionary of zone_name -> polygon points [[x1,y1], [x2,y2], ...]
218
+ person_categories: List of category names that represent people
219
+ enable_tracking: Whether to enable object tracking
220
+ time_window_minutes: Time window for counting statistics
221
+ alert_thresholds: Dictionary of zone_name -> max_count for alerts
222
+ category: Use case category
223
+ **kwargs: Additional configuration parameters
224
+
225
+ Returns:
226
+ IntrusionConfig: Configured intrusion detection configuration
227
+
228
+ Example:
229
+ config = create_intrusion_detection_config(
230
+ confidence_threshold=0.6,
231
+ zones={
232
+ "High": [[535, 558], [745, 453], [846, 861], [665, 996]],
233
+ "Mid": [[663, 995], [925, 817], [1266, 885], [1012, 1116]]
234
+ },
235
+ alert_thresholds={"High": 0, "Mid": 0}
236
+ )
237
+ """
238
+ # Create zone configuration if zones provided
239
+ zone_config = None
240
+ if zones:
241
+ zone_config = ZoneConfig(zones=zones)
242
+
243
+ # Create alert configuration if thresholds provided
244
+ alert_config = None
245
+ if alert_thresholds:
246
+ alert_config = AlertConfig(count_thresholds=alert_thresholds)
247
+
248
+ return IntrusionConfig(
249
+ category=category,
250
+ usecase="intrusion_detection",
251
+ confidence_threshold=confidence_threshold,
252
+ zone_config=zone_config,
253
+ person_categories=person_categories or ["person"],
254
+ enable_tracking=enable_tracking,
255
+ time_window_minutes=time_window_minutes,
256
+ alert_config=alert_config,
257
+ **kwargs
258
+ )
259
+
260
+
261
+ def create_proximity_detection_config(
262
+ confidence_threshold: float = 0.5,
263
+ zones: Optional[Dict[str, List[List[float]]]] = None,
264
+ person_categories: Optional[List[str]] = None,
265
+ enable_tracking: bool = False,
266
+ time_window_minutes: int = 60,
267
+ alert_thresholds: Optional[Dict[str, int]] = None,
268
+ category: str = "general",
269
+ **kwargs
270
+ ) -> ProximityConfig:
271
+ """
272
+ Create a proximity detection configuration with sensible defaults.
273
+
274
+ Args:
275
+ confidence_threshold: Minimum confidence for detections (0.0-1.0)
276
+ zones: Dictionary of zone_name -> polygon points [[x1,y1], [x2,y2], ...]
277
+ person_categories: List of category names that represent people
278
+ enable_tracking: Whether to enable object tracking
279
+ time_window_minutes: Time window for counting statistics
280
+ alert_thresholds: Dictionary of zone_name -> max_count for alerts
281
+ category: Use case category
282
+ **kwargs: Additional configuration parameters
283
+
284
+ Returns:
285
+ ProximityConfig: Configured proximity detection configuration
286
+
287
+ Example:
288
+ config = create_proximity_detection_config(
289
+ confidence_threshold=0.6,
290
+ zones={
291
+ "entrance": [[0, 0], [100, 0], [100, 100], [0, 100]],
292
+ "exit": [[200, 0], [300, 0], [300, 100], [200, 100]]
293
+ },
294
+ alert_thresholds={"entrance": 10, "exit": 5}
295
+ )
296
+ """
297
+ # Create zone configuration if zones provided
298
+ zone_config = None
299
+ if zones:
300
+ zone_config = ZoneConfig(zones=zones)
301
+
302
+ # Create alert configuration if thresholds provided
303
+ alert_config = None
304
+ if alert_thresholds:
305
+ alert_config = AlertConfig(count_thresholds=alert_thresholds)
306
+
307
+ return ProximityConfig(
308
+ category=category,
309
+ usecase="proximity_detection",
310
+ confidence_threshold=confidence_threshold,
311
+ zone_config=zone_config,
312
+ person_categories=person_categories or ["person"],
313
+ enable_tracking=enable_tracking,
314
+ time_window_minutes=time_window_minutes,
315
+ alert_config=alert_config,
316
+ **kwargs
317
+ )
318
+
319
+
320
+ def create_customer_service_config(
321
+ confidence_threshold: float = 0.5,
322
+ customer_areas: Optional[Dict[str, List[List[float]]]] = None,
323
+ staff_areas: Optional[Dict[str, List[List[float]]]] = None,
324
+ service_areas: Optional[Dict[str, List[List[float]]]] = None,
325
+ staff_categories: Optional[List[str]] = None,
326
+ customer_categories: Optional[List[str]] = None,
327
+ service_proximity_threshold: float = 100.0,
328
+ enable_tracking: bool = True,
329
+ enable_alerts: bool = False,
330
+ category: str = "sales",
331
+ **kwargs
332
+ ) -> CustomerServiceConfig:
333
+ """
334
+ Create a customer service configuration with sensible defaults.
335
+
336
+ Args:
337
+ confidence_threshold: Minimum confidence for detections (0.0-1.0)
338
+ customer_areas: Dictionary of area_name -> polygon for customer areas
339
+ staff_areas: Dictionary of area_name -> polygon for staff areas
340
+ service_areas: Dictionary of area_name -> polygon for service areas
341
+ staff_categories: List of category names that represent staff
342
+ customer_categories: List of category names that represent customers
343
+ service_proximity_threshold: Distance threshold for service interactions
344
+ enable_tracking: Whether to enable object tracking
345
+ enable_alerts: Whether to enable alerting system
346
+ category: Use case category
347
+ **kwargs: Additional configuration parameters
348
+
349
+ Returns:
350
+ CustomerServiceConfig: Configured customer service configuration
351
+
352
+ Example:
353
+ config = create_customer_service_config(
354
+ confidence_threshold=0.6,
355
+ customer_areas={
356
+ "waiting_area": [[0, 0], [200, 0], [200, 100], [0, 100]]
357
+ },
358
+ staff_areas={
359
+ "service_desk": [[200, 0], [400, 0], [400, 100], [200, 100]]
360
+ },
361
+ service_proximity_threshold=150.0
362
+ )
363
+ """
364
+ # Create tracking configuration if enabled
365
+ tracking_config = None
366
+ if enable_tracking:
367
+ tracking_config = TrackingConfig(
368
+ tracking_method="kalman",
369
+ max_age=30,
370
+ min_hits=3
371
+ )
372
+
373
+ # Create alert configuration if enabled
374
+ alert_config = None
375
+ if enable_alerts:
376
+ alert_config = AlertConfig()
377
+
378
+ return CustomerServiceConfig(
379
+ category=category,
380
+ usecase="customer_service",
381
+ confidence_threshold=confidence_threshold,
382
+ customer_areas=customer_areas or {},
383
+ staff_areas=staff_areas or {},
384
+ service_areas=service_areas or {},
385
+ staff_categories=staff_categories or ["staff", "employee"],
386
+ customer_categories=customer_categories or ["customer", "person"],
387
+ service_proximity_threshold=service_proximity_threshold,
388
+ enable_tracking=enable_tracking,
389
+ tracking_config=tracking_config,
390
+ alert_config=alert_config,
391
+ **kwargs
392
+ )
393
+
394
+
395
+ def create_advanced_customer_service_config(
396
+ customer_areas: Dict[str, List[List[float]]],
397
+ staff_areas: Dict[str, List[List[float]]],
398
+ service_areas: Optional[Dict[str, List[List[float]]]] = None,
399
+ staff_categories: List[str] = None,
400
+ customer_categories: List[str] = None,
401
+ service_proximity_threshold: float = 100.0,
402
+ max_service_time: float = 1800.0,
403
+ tracking_method: str = "kalman",
404
+ enable_analytics: bool = True,
405
+ confidence_threshold: float = 0.6,
406
+ alert_thresholds: Optional[Dict[str, int]] = None,
407
+ category: str = "sales",
408
+ **kwargs
409
+ ) -> CustomerServiceConfig:
410
+ """
411
+ Create advanced customer service configuration with journey analysis.
412
+
413
+ Args:
414
+ customer_areas: Dictionary of customer area polygons
415
+ staff_areas: Dictionary of staff area polygons
416
+ service_areas: Optional service area polygons
417
+ staff_categories: List of staff category names
418
+ customer_categories: List of customer category names
419
+ service_proximity_threshold: Distance threshold for service interactions
420
+ max_service_time: Maximum service time in seconds
421
+ tracking_method: Tracking method to use
422
+ enable_analytics: Enable advanced analytics
423
+ confidence_threshold: Detection confidence threshold
424
+ alert_thresholds: Alert threshold configuration
425
+ category: Use case category
426
+ **kwargs: Additional configuration parameters
427
+
428
+ Returns:
429
+ CustomerServiceConfig: Configured customer service config
430
+ """
431
+ # Set defaults
432
+ if staff_categories is None:
433
+ staff_categories = ["staff", "employee", "worker"]
434
+ if customer_categories is None:
435
+ customer_categories = ["customer", "person", "visitor"]
436
+ if service_areas is None:
437
+ service_areas = {}
438
+
439
+ # Create tracking configuration for journey analysis
440
+ tracking_config = TrackingConfig(
441
+ tracking_method=tracking_method,
442
+ max_age=30,
443
+ min_hits=3,
444
+ iou_threshold=0.3,
445
+ target_classes=staff_categories + customer_categories,
446
+ use_appearance_features=True,
447
+ appearance_threshold=0.7
448
+ )
449
+
450
+ # Create alert configuration
451
+ alert_config = None
452
+ if alert_thresholds:
453
+ alert_config = AlertConfig(
454
+ count_thresholds=alert_thresholds,
455
+ occupancy_thresholds={},
456
+ service_time_threshold=max_service_time,
457
+ alert_cooldown=30.0
458
+ )
459
+
460
+ return CustomerServiceConfig(
461
+ category=category,
462
+ usecase="advanced_customer_service",
463
+ customer_areas=customer_areas,
464
+ staff_areas=staff_areas,
465
+ service_areas=service_areas,
466
+ staff_categories=staff_categories,
467
+ customer_categories=customer_categories,
468
+ service_proximity_threshold=service_proximity_threshold,
469
+ max_service_time=max_service_time,
470
+ confidence_threshold=confidence_threshold,
471
+ enable_analytics=enable_analytics,
472
+ enable_tracking=True,
473
+ tracking_config=tracking_config,
474
+ alert_config=alert_config,
475
+ **kwargs
476
+ )
477
+
478
+
479
+ def create_basic_counting_tracking_config(
480
+ confidence_threshold: float = 0.5,
481
+ target_categories: Optional[List[str]] = None,
482
+ zones: Optional[Dict[str, List[List[float]]]] = None,
483
+ enable_tracking: bool = True,
484
+ tracking_method: str = "kalman",
485
+ max_age: int = 30,
486
+ min_hits: int = 3,
487
+ count_thresholds: Optional[Dict[str, int]] = None,
488
+ zone_thresholds: Optional[Dict[str, int]] = None,
489
+ alert_cooldown: float = 60.0,
490
+ enable_unique_counting: bool = True,
491
+ **kwargs
492
+ ):
493
+ """
494
+ Create a basic counting with tracking configuration.
495
+
496
+ This is a simplified configuration for scenarios where you need basic object counting
497
+ with tracking capabilities and simple alerting. It's designed to be easy to use
498
+ while providing essential tracking and counting features.
499
+
500
+ Args:
501
+ confidence_threshold: Minimum confidence for detections (0.0-1.0)
502
+ target_categories: List of category names to count and track
503
+ zones: Dictionary of zone_name -> polygon points for spatial analysis
504
+ enable_tracking: Whether to enable object tracking
505
+ tracking_method: Tracking algorithm ('kalman', 'sort', 'deepsort', 'bytetrack')
506
+ max_age: Maximum age for tracks in frames
507
+ min_hits: Minimum hits before confirming track
508
+ count_thresholds: Dictionary of category -> max_count for count alerts
509
+ zone_thresholds: Dictionary of zone_name -> max_occupancy for zone alerts
510
+ alert_cooldown: Alert cooldown time in seconds
511
+ enable_unique_counting: Enable unique object counting using tracking
512
+ **kwargs: Additional configuration parameters
513
+
514
+ Returns:
515
+ BasicCountingTrackingConfig: Configured basic counting tracking configuration
516
+
517
+ Example:
518
+ # Basic setup with tracking
519
+ config = create_basic_counting_tracking_config(
520
+ confidence_threshold=0.6,
521
+ target_categories=["person", "car", "bicycle"],
522
+ enable_tracking=True,
523
+ tracking_method="bytetrack"
524
+ )
525
+
526
+ # With zones and alerts
527
+ config = create_basic_counting_tracking_config(
528
+ confidence_threshold=0.5,
529
+ zones={
530
+ "entrance": [[0, 0], [200, 0], [200, 100], [0, 100]],
531
+ "parking": [[200, 0], [800, 0], [800, 400], [200, 400]]
532
+ },
533
+ count_thresholds={"person": 20, "car": 50},
534
+ zone_thresholds={"entrance": 10, "parking": 30},
535
+ alert_cooldown=120.0
536
+ )
537
+
538
+ # Simple object counting
539
+ config = create_basic_counting_tracking_config(
540
+ target_categories=["object"],
541
+ enable_tracking=False, # Disable tracking for simple counting
542
+ enable_unique_counting=False
543
+ )
544
+ """
545
+ # Import here to avoid circular imports
546
+ from ..usecases.basic_counting_tracking import BasicCountingTrackingConfig
547
+
548
+ return BasicCountingTrackingConfig(
549
+ category="general",
550
+ usecase="basic_counting_tracking",
551
+ confidence_threshold=confidence_threshold,
552
+ target_categories=target_categories or ["person", "people", "object"],
553
+ zones=zones,
554
+ enable_tracking=enable_tracking,
555
+ tracking_method=tracking_method,
556
+ max_age=max_age,
557
+ min_hits=min_hits,
558
+ count_thresholds=count_thresholds,
559
+ zone_thresholds=zone_thresholds,
560
+ alert_cooldown=alert_cooldown,
561
+ enable_unique_counting=enable_unique_counting,
562
+ **kwargs
563
+ )
564
+
565
+
566
+ def create_zone_from_bbox(x: float, y: float, width: float, height: float) -> List[List[float]]:
567
+ """
568
+ Create a rectangular zone from bounding box coordinates.
569
+
570
+ Args:
571
+ x: Left coordinate
572
+ y: Top coordinate
573
+ width: Zone width
574
+ height: Zone height
575
+
576
+ Returns:
577
+ List[List[float]]: Polygon points for the rectangular zone
578
+
579
+ Example:
580
+ zone = create_zone_from_bbox(100, 50, 200, 150)
581
+ # Returns [[100, 50], [300, 50], [300, 200], [100, 200]]
582
+ """
583
+ return [
584
+ [x, y], # Top-left
585
+ [x + width, y], # Top-right
586
+ [x + width, y + height], # Bottom-right
587
+ [x, y + height] # Bottom-left
588
+ ]
589
+
590
+
591
+ def create_polygon_zone(points: List[Tuple[float, float]]) -> List[List[float]]:
592
+ """
593
+ Create a polygon zone from a list of coordinate tuples.
594
+
595
+ Args:
596
+ points: List of (x, y) coordinate tuples
597
+
598
+ Returns:
599
+ List[List[float]]: Polygon points in the required format
600
+
601
+ Example:
602
+ zone = create_polygon_zone([(0, 0), (100, 0), (100, 100), (50, 150), (0, 100)])
603
+ """
604
+ return [[float(x), float(y)] for x, y in points]
605
+
606
+
607
+ def validate_zone_polygon(polygon: List[List[float]]) -> Tuple[bool, str]:
608
+ """
609
+ Validate a zone polygon for correctness.
610
+
611
+ Args:
612
+ polygon: Polygon points [[x1, y1], [x2, y2], ...]
613
+
614
+ Returns:
615
+ Tuple[bool, str]: (is_valid, error_message)
616
+
617
+ Example:
618
+ is_valid, error = validate_zone_polygon([[0, 0], [100, 0], [100, 100]])
619
+ if not is_valid:
620
+ print(f"Invalid polygon: {error}")
621
+ """
622
+ if not isinstance(polygon, list):
623
+ return False, "Polygon must be a list"
624
+
625
+ if len(polygon) < 3:
626
+ return False, "Polygon must have at least 3 points"
627
+
628
+ for i, point in enumerate(polygon):
629
+ if not isinstance(point, list) or len(point) != 2:
630
+ return False, f"Point {i} must be a list of 2 coordinates"
631
+
632
+ try:
633
+ float(point[0])
634
+ float(point[1])
635
+ except (ValueError, TypeError):
636
+ return False, f"Point {i} coordinates must be numeric"
637
+
638
+ return True, ""
639
+
640
+
641
+ def create_config_from_template(
642
+ usecase: str,
643
+ template_file: Optional[Union[str, Path]] = None,
644
+ **overrides
645
+ ):
646
+ """
647
+ Create configuration from a template file or default template.
648
+
649
+ Args:
650
+ usecase: Use case name ('people_counting', 'customer_service', 'advanced_customer_service', 'basic_counting_tracking')
651
+ template_file: Optional path to template file (JSON/YAML)
652
+ **overrides: Parameters to override in the template
653
+
654
+ Returns:
655
+ BaseConfig: Created configuration
656
+
657
+ Example:
658
+ # From default template
659
+ config = create_config_from_template(
660
+ "people_counting",
661
+ confidence_threshold=0.7,
662
+ zones={"area1": [[0, 0], [100, 0], [100, 100], [0, 100]]}
663
+ )
664
+
665
+ # From file template
666
+ config = create_config_from_template(
667
+ "customer_service",
668
+ template_file="templates/retail_config.json",
669
+ confidence_threshold=0.6
670
+ )
671
+
672
+ # Basic counting with tracking
673
+ config = create_config_from_template(
674
+ "basic_counting_tracking",
675
+ target_categories=["person", "car"],
676
+ enable_tracking=True
677
+ )
678
+ """
679
+ if template_file:
680
+ # Load from file and apply overrides
681
+ config = config_manager.load_from_file(template_file)
682
+ if overrides:
683
+ # Convert to dict, apply overrides, and recreate
684
+ config_dict = config.to_dict()
685
+ config_dict.update(overrides)
686
+ config = config_manager.create_config(usecase, **config_dict)
687
+ return config
688
+ else:
689
+ # Create from default template with overrides
690
+ if usecase == "people_counting":
691
+ return create_people_counting_config(**overrides)
692
+ elif usecase == "intrusion_detection":
693
+ return create_intrusion_detection_config(**overrides)
694
+ elif usecase == "proximity_detection":
695
+ return create_proximity_detection_config(**overrides)
696
+ elif usecase == "customer_service":
697
+ return create_customer_service_config(**overrides)
698
+ elif usecase == "advanced_customer_service":
699
+ return create_advanced_customer_service_config(**overrides)
700
+ elif usecase == "basic_counting_tracking":
701
+ return create_basic_counting_tracking_config(**overrides)
702
+ elif usecase == "people_tracking":
703
+ return create_people_tracking_config(**overrides)
704
+ else:
705
+ raise ValueError(f"Unsupported use case: {usecase}")
706
+
707
+
708
+ def get_use_case_examples() -> Dict[str, Dict[str, Any]]:
709
+ """
710
+ Get example configurations for all supported use cases.
711
+
712
+ Returns:
713
+ Dict[str, Dict[str, Any]]: Dictionary of use_case -> example_config
714
+
715
+ Example:
716
+ examples = get_use_case_examples()
717
+ people_counting_example = examples["people_counting"]
718
+ print(json.dumps(people_counting_example, indent=2))
719
+ """
720
+ return {
721
+ "people_counting": {
722
+ "usecase": "people_counting",
723
+ "category": "general",
724
+ "confidence_threshold": 0.6,
725
+ "enable_tracking": True,
726
+ "time_window_minutes": 60,
727
+ "person_categories": ["person", "people"],
728
+ "zone_config": {
729
+ "zones": {
730
+ "entrance": [[0, 0], [200, 0], [200, 100], [0, 100]],
731
+ "main_area": [[200, 0], [800, 0], [800, 600], [200, 600]],
732
+ "exit": [[800, 0], [1000, 0], [1000, 100], [800, 100]]
733
+ }
734
+ },
735
+ "alert_config": {
736
+ "count_thresholds": {
737
+ "entrance": 10,
738
+ "main_area": 50,
739
+ "exit": 10
740
+ },
741
+ "alert_cooldown": 60.0
742
+ }
743
+ },
744
+
745
+ "intrusion_detection": {
746
+ "usecase": "intrusion_detection",
747
+ "category": "security",
748
+ "confidence_threshold": 0.6,
749
+ "enable_tracking": True,
750
+ "time_window_minutes": 60,
751
+ "person_categories": ["person"],
752
+ "zone_config": {
753
+ "zones": {
754
+ "Boarding Gate": [[314, 652], [1034, 317], [1854, 845], [987, 1491]]
755
+ }
756
+ },
757
+ "alert_config": {
758
+ "count_thresholds": {
759
+ "Boarding Gate": 0
760
+ },
761
+ "alert_cooldown": 10.0
762
+ }
763
+ },
764
+
765
+ "proximity_detection": {
766
+ "usecase": "proximity_detection",
767
+ "category": "security",
768
+ "confidence_threshold": 0.6,
769
+ "enable_tracking": True,
770
+ "time_window_minutes": 60,
771
+ "person_categories": ["person"],
772
+ "zone_config": {
773
+ "zones": {}
774
+ },
775
+ "alert_config": {
776
+ "count_thresholds": {
777
+ "Boarding Gate": 0
778
+ },
779
+ "alert_cooldown": 10.0
780
+ }
781
+ },
782
+
783
+ "customer_service": {
784
+ "usecase": "customer_service",
785
+ "category": "sales",
786
+ "confidence_threshold": 0.5,
787
+ "enable_tracking": True,
788
+ "staff_categories": ["staff", "employee"],
789
+ "customer_categories": ["customer", "person"],
790
+ "service_proximity_threshold": 120.0,
791
+ "customer_areas": {
792
+ "waiting_area": [[0, 0], [300, 0], [300, 200], [0, 200]],
793
+ "service_area": [[300, 0], [600, 0], [600, 200], [300, 200]]
794
+ },
795
+ "staff_areas": {
796
+ "service_desk": [[350, 50], [550, 50], [550, 150], [350, 150]]
797
+ },
798
+ "tracking_config": {
799
+ "tracking_method": "kalman",
800
+ "max_age": 30,
801
+ "min_hits": 3,
802
+ "iou_threshold": 0.3
803
+ }
804
+ },
805
+
806
+ "advanced_customer_service": {
807
+ "usecase": "advanced_customer_service",
808
+ "category": "sales",
809
+ "confidence_threshold": 0.6,
810
+ "enable_tracking": True,
811
+ "enable_analytics": True,
812
+ "staff_categories": ["staff", "employee"],
813
+ "customer_categories": ["customer", "person"],
814
+ "service_proximity_threshold": 100.0,
815
+ "max_service_time": 1800.0,
816
+ "enable_journey_analysis": True,
817
+ "enable_queue_analytics": True,
818
+ "customer_areas": {
819
+ "entrance": [[0, 0], [100, 0], [100, 100], [0, 100]],
820
+ "queue_area": [[100, 0], [400, 0], [400, 150], [100, 150]],
821
+ "service_area": [[400, 0], [700, 0], [700, 150], [400, 150]]
822
+ },
823
+ "staff_areas": {
824
+ "reception": [[450, 50], [650, 50], [650, 100], [450, 100]]
825
+ },
826
+ "service_areas": {
827
+ "service_counter": [[400, 0], [700, 0], [700, 50], [400, 50]]
828
+ },
829
+ "tracking_config": {
830
+ "tracking_method": "bytetrack",
831
+ "max_age": 50,
832
+ "min_hits": 3,
833
+ "iou_threshold": 0.3
834
+ },
835
+ "alert_config": {
836
+ "service_time_threshold": 1800.0,
837
+ "dwell_time_threshold": 300.0,
838
+ "alert_cooldown": 120.0
839
+ }
840
+ },
841
+
842
+ "basic_counting_tracking": {
843
+ "usecase": "basic_counting_tracking",
844
+ "category": "general",
845
+ "confidence_threshold": 0.5,
846
+ "target_categories": ["person", "car", "bicycle"],
847
+ "enable_tracking": True,
848
+ "tracking_method": "kalman",
849
+ "max_age": 30,
850
+ "min_hits": 3,
851
+ "enable_unique_counting": True,
852
+ "zones": {
853
+ "entrance": [[0, 0], [200, 0], [200, 100], [0, 100]],
854
+ "main_area": [[200, 0], [800, 0], [800, 400], [200, 400]],
855
+ "exit": [[800, 0], [1000, 0], [1000, 100], [800, 100]]
856
+ },
857
+ "count_thresholds": {
858
+ "person": 20,
859
+ "car": 10,
860
+ "all": 30
861
+ },
862
+ "zone_thresholds": {
863
+ "entrance": 5,
864
+ "main_area": 25,
865
+ "exit": 5
866
+ },
867
+ "alert_cooldown": 60.0
868
+ }
869
+ }
870
+
871
+
872
+ # Helper functions for common zone patterns
873
+ def create_retail_store_zones(
874
+ store_width: float = 1000,
875
+ store_height: float = 600,
876
+ entrance_width: float = 200,
877
+ checkout_width: float = 300
878
+ ) -> Dict[str, List[List[float]]]:
879
+ """
880
+ Create typical retail store zone layout.
881
+
882
+ Args:
883
+ store_width: Total store width
884
+ store_height: Total store height
885
+ entrance_width: Width of entrance area
886
+ checkout_width: Width of checkout area
887
+
888
+ Returns:
889
+ Dict[str, List[List[float]]]: Dictionary of zone_name -> polygon
890
+ """
891
+ return {
892
+ "entrance": create_zone_from_bbox(0, 0, entrance_width, store_height),
893
+ "shopping_area": create_zone_from_bbox(
894
+ entrance_width, 0,
895
+ store_width - entrance_width - checkout_width,
896
+ store_height
897
+ ),
898
+ "checkout": create_zone_from_bbox(
899
+ store_width - checkout_width, 0,
900
+ checkout_width, store_height
901
+ )
902
+ }
903
+
904
+
905
+ def create_office_zones(
906
+ office_width: float = 800,
907
+ office_height: float = 600,
908
+ reception_height: float = 150
909
+ ) -> Dict[str, List[List[float]]]:
910
+ """
911
+ Create typical office zone layout.
912
+
913
+ Args:
914
+ office_width: Total office width
915
+ office_height: Total office height
916
+ reception_height: Height of reception area
917
+
918
+ Returns:
919
+ Dict[str, List[List[float]]]: Dictionary of zone_name -> polygon
920
+ """
921
+ return {
922
+ "reception": create_zone_from_bbox(0, 0, office_width, reception_height),
923
+ "waiting_area": create_zone_from_bbox(0, reception_height, office_width // 3, office_height - reception_height),
924
+ "work_area": create_zone_from_bbox(office_width // 3, reception_height, 2 * office_width // 3, office_height - reception_height)
925
+ }