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,455 @@
1
+ # Post-Processing Module - Refactored Architecture
2
+
3
+ ## Overview
4
+
5
+ This module provides a comprehensive, refactored post-processing system for the Matrice Python SDK. The system has been completely redesigned to be more pythonic, maintainable, and extensible while providing powerful analytics capabilities for various use cases.
6
+
7
+ ## ๐Ÿš€ Key Features
8
+
9
+ ### โœ… **Unified Architecture**
10
+ - **Single Entry Point**: `PostProcessor` class handles all processing needs
11
+ - **Standardized Results**: All operations return `ProcessingResult` objects
12
+ - **Consistent Configuration**: Type-safe configuration system with validation
13
+ - **Registry Pattern**: Easy registration and discovery of use cases
14
+
15
+ ### โœ… **Separate Use Case Classes**
16
+ - **People Counting**: Advanced people counting with zone analysis and tracking
17
+ - **Customer Service**: Comprehensive customer service analytics with business intelligence
18
+ - **Extensible Design**: Easy to add new use cases
19
+
20
+ ### โœ… **Pythonic Configuration Management**
21
+ - **Dataclass-based**: Type-safe configurations using dataclasses
22
+ - **Nested Configurations**: Support for complex nested config structures
23
+ - **File Support**: JSON/YAML configuration file loading and saving
24
+ - **Validation**: Built-in validation with detailed error messages
25
+
26
+ ### โœ… **Comprehensive Error Handling**
27
+ - **Standardized Errors**: All errors return structured `ProcessingResult` objects
28
+ - **Detailed Information**: Error messages include type, context, and debugging info
29
+ - **Graceful Degradation**: System continues operating even with partial failures
30
+
31
+ ### โœ… **Processing Statistics**
32
+ - **Performance Tracking**: Automatic processing time measurement
33
+ - **Success Metrics**: Success/failure rates and statistics
34
+ - **Insights Generation**: Automatic generation of actionable insights
35
+
36
+ ## ๐Ÿ“ Architecture
37
+
38
+ ```
39
+ post_processing/
40
+ โ”œโ”€โ”€ __init__.py # Main exports and convenience functions
41
+ โ”œโ”€โ”€ processor.py # Main PostProcessor class
42
+ โ”œโ”€โ”€ README.md # This documentation
43
+ โ”‚
44
+ โ”œโ”€โ”€ core/ # Core system components
45
+ โ”‚ โ”œโ”€โ”€ __init__.py
46
+ โ”‚ โ”œโ”€โ”€ base.py # Base classes, enums, and protocols
47
+ โ”‚ โ”œโ”€โ”€ config.py # Configuration system
48
+ โ”‚ โ””โ”€โ”€ advanced_usecases.py # Advanced use case implementations
49
+ โ”‚
50
+ โ”œโ”€โ”€ usecases/ # Separate use case implementations
51
+ โ”‚ โ”œโ”€โ”€ __init__.py
52
+ โ”‚ โ”œโ”€โ”€ people_counting.py # People counting use case
53
+ โ”‚ โ””โ”€โ”€ customer_service.py # Customer service use case
54
+ โ”‚
55
+ โ””โ”€โ”€ utils/ # Utility functions organized by category
56
+ โ”œโ”€โ”€ __init__.py
57
+ โ”œโ”€โ”€ geometry_utils.py # Geometric calculations
58
+ โ”œโ”€โ”€ format_utils.py # Format detection and conversion
59
+ โ”œโ”€โ”€ filter_utils.py # Filtering and cleaning operations
60
+ โ”œโ”€โ”€ counting_utils.py # Counting and aggregation
61
+ โ””โ”€โ”€ tracking_utils.py # Tracking and movement analysis
62
+ ```
63
+
64
+ ## ๐Ÿ›  Quick Start
65
+
66
+ ### Basic Usage
67
+
68
+ ```python
69
+ from matrice_analytics.post_processing import PostProcessor, process_simple
70
+
71
+ # Method 1: Simple processing (recommended for quick tasks)
72
+ result = process_simple(
73
+ raw_results,
74
+ usecase="people_counting",
75
+ confidence_threshold=0.5
76
+ )
77
+
78
+ # Method 2: Using PostProcessor class (recommended for complex workflows)
79
+ processor = PostProcessor()
80
+ result = processor.process_simple(
81
+ raw_results,
82
+ usecase="people_counting",
83
+ confidence_threshold=0.5,
84
+ enable_tracking=True
85
+ )
86
+
87
+ print(f"Status: {result.status.value}")
88
+ print(f"Summary: {result.summary}")
89
+ print(f"Insights: {len(result.insights)} generated")
90
+ ```
91
+
92
+ ### Advanced Configuration
93
+
94
+ ```python
95
+ # Create complex configuration
96
+ config = processor.create_config(
97
+ 'people_counting',
98
+ confidence_threshold=0.6,
99
+ enable_tracking=True,
100
+ person_categories=['person', 'people', 'human'],
101
+ zone_config={
102
+ 'zones': {
103
+ 'entrance': [[0, 0], [100, 0], [100, 100], [0, 100]],
104
+ 'checkout': [[200, 200], [300, 200], [300, 300], [200, 300]]
105
+ }
106
+ },
107
+ alert_config={
108
+ 'count_thresholds': {'all': 10},
109
+ 'occupancy_thresholds': {'entrance': 5}
110
+ }
111
+ )
112
+
113
+ # Process with configuration
114
+ result = processor.process(raw_results, config)
115
+ ```
116
+
117
+ ### Configuration File Support
118
+
119
+ ```python
120
+ # Save configuration to file
121
+ processor.save_config(config, "people_counting_config.json")
122
+
123
+ # Load and use configuration from file
124
+ result = processor.process_from_file(raw_results, "people_counting_config.json")
125
+ ```
126
+
127
+ ## ๐Ÿ“Š Use Cases
128
+
129
+ ### 1. People Counting (`people_counting`)
130
+
131
+ Advanced people counting with comprehensive analytics:
132
+
133
+ ```python
134
+ result = process_simple(
135
+ raw_results,
136
+ usecase="people_counting",
137
+ confidence_threshold=0.5,
138
+ enable_tracking=True,
139
+ person_categories=['person', 'people'],
140
+ zone_config={
141
+ 'zones': {
142
+ 'entrance': [[0, 0], [100, 0], [100, 100], [0, 100]]
143
+ }
144
+ }
145
+ )
146
+ ```
147
+
148
+ **Features:**
149
+ - Multi-category person detection
150
+ - Zone-based counting and analysis
151
+ - Unique person tracking
152
+ - Occupancy analysis
153
+ - Alert generation based on thresholds
154
+ - Temporal analysis and trends
155
+
156
+ ### 2. Customer Service (`customer_service`)
157
+
158
+ Comprehensive customer service analytics:
159
+
160
+ ```python
161
+ result = process_simple(
162
+ raw_results,
163
+ usecase="customer_service",
164
+ confidence_threshold=0.6,
165
+ service_proximity_threshold=50.0,
166
+ staff_categories=['staff', 'employee'],
167
+ customer_categories=['customer', 'person']
168
+ )
169
+ ```
170
+
171
+ **Features:**
172
+ - Staff utilization analysis
173
+ - Customer-staff interaction detection
174
+ - Service quality metrics
175
+ - Area occupancy analysis
176
+ - Queue management insights
177
+ - Business intelligence metrics
178
+
179
+ ## ๐Ÿ”ง Configuration System
180
+
181
+ ### Configuration Classes
182
+
183
+ All configurations are type-safe dataclasses with built-in validation:
184
+
185
+ ```python
186
+ from matrice_analytics.post_processing import PeopleCountingConfig, ZoneConfig
187
+
188
+ # Create configuration programmatically
189
+ config = PeopleCountingConfig(
190
+ confidence_threshold=0.5,
191
+ enable_tracking=True,
192
+ zone_config=ZoneConfig(
193
+ zones={
194
+ 'entrance': [[0, 0], [100, 0], [100, 100], [0, 100]]
195
+ }
196
+ )
197
+ )
198
+
199
+ # Validate configuration
200
+ errors = config.validate()
201
+ if errors:
202
+ print(f"Configuration errors: {errors}")
203
+ ```
204
+
205
+ ### Configuration Templates
206
+
207
+ ```python
208
+ # Get configuration template for a use case
209
+ template = processor.get_config_template('people_counting')
210
+ print(f"Available options: {list(template.keys())}")
211
+
212
+ # List all available use cases
213
+ use_cases = processor.list_available_usecases()
214
+ print(f"Available use cases: {use_cases}")
215
+ ```
216
+
217
+ ## ๐Ÿ“ˆ Processing Results
218
+
219
+ All processing operations return a standardized `ProcessingResult` object:
220
+
221
+ ```python
222
+ class ProcessingResult:
223
+ data: Any # Processed data
224
+ status: ProcessingStatus # SUCCESS, ERROR, WARNING, PARTIAL
225
+ usecase: str # Use case name
226
+ category: str # Use case category
227
+ processing_time: float # Processing time in seconds
228
+ summary: str # Human-readable summary
229
+ insights: List[str] # Generated insights
230
+ warnings: List[str] # Warning messages
231
+ error_message: Optional[str] # Error message if failed
232
+ predictions: List[Dict[str, Any]] # Detailed predictions
233
+ metrics: Dict[str, Any] # Performance metrics
234
+ ```
235
+
236
+ ### Working with Results
237
+
238
+ ```python
239
+ result = processor.process_simple(data, "people_counting")
240
+
241
+ # Check status
242
+ if result.is_success():
243
+ print(f"โœ… {result.summary}")
244
+
245
+ # Access insights
246
+ for insight in result.insights:
247
+ print(f"๐Ÿ’ก {insight}")
248
+
249
+ # Access metrics
250
+ print(f"๐Ÿ“Š Metrics: {result.metrics}")
251
+
252
+ # Access processed data
253
+ processed_data = result.data
254
+ else:
255
+ print(f"โŒ Processing failed: {result.error_message}")
256
+ ```
257
+
258
+ ## ๐Ÿ“Š Statistics and Monitoring
259
+
260
+ ```python
261
+ # Get processing statistics
262
+ stats = processor.get_statistics()
263
+ print(f"Total processed: {stats['total_processed']}")
264
+ print(f"Success rate: {stats['success_rate']:.2%}")
265
+ print(f"Average processing time: {stats['average_processing_time']:.3f}s")
266
+
267
+ # Reset statistics
268
+ processor.reset_statistics()
269
+ ```
270
+
271
+ ## ๐Ÿ”Œ Extensibility
272
+
273
+ ### Adding New Use Cases
274
+
275
+ 1. **Create Use Case Class**:
276
+
277
+ ```python
278
+ from matrice_analytics.post_processing.core.base import BaseProcessor
279
+
280
+ class MyCustomUseCase(BaseProcessor):
281
+ def __init__(self):
282
+ super().__init__("my_custom_usecase")
283
+ self.category = "custom"
284
+
285
+ def process(self, data, config, context=None):
286
+ # Implement your processing logic
287
+ return self.create_result(processed_data, "my_custom_usecase", "custom")
288
+ ```
289
+
290
+ 2. **Register Use Case**:
291
+
292
+ ```python
293
+ from matrice_analytics.post_processing.core.base import registry
294
+
295
+ registry.register_use_case("custom", "my_custom_usecase", MyCustomUseCase)
296
+ ```
297
+
298
+ ### Adding New Utility Functions
299
+
300
+ Add utility functions to the appropriate module in the `utils/` directory and export them in `utils/__init__.py`.
301
+
302
+ ## ๐Ÿงช Testing
303
+
304
+ The system includes comprehensive error handling and validation. Here's how to test your implementations:
305
+
306
+ ```python
307
+ # Test configuration validation
308
+ errors = processor.validate_config({
309
+ 'usecase': 'people_counting',
310
+ 'confidence_threshold': 0.5
311
+ })
312
+
313
+ # Test with sample data
314
+ sample_data = [
315
+ {'category': 'person', 'confidence': 0.8, 'bbox': [10, 10, 50, 50]}
316
+ ]
317
+
318
+ result = process_simple(sample_data, 'people_counting')
319
+ assert result.is_success()
320
+ ```
321
+
322
+ ## ๐Ÿ”„ Migration from Old System
323
+
324
+ If you're migrating from the old post-processing system:
325
+
326
+ 1. **Update Imports**:
327
+ ```python
328
+ # Old
329
+ from matrice_analytics.old_post_processing import some_function
330
+
331
+ # New
332
+ from matrice_analytics.post_processing import PostProcessor, process_simple
333
+ ```
334
+
335
+ 2. **Update Processing Calls**:
336
+ ```python
337
+ # Old
338
+ result = old_process_function(data, config_dict)
339
+
340
+ # New
341
+ result = process_simple(data, "usecase_name", **config_dict)
342
+ ```
343
+
344
+ 3. **Update Configuration**:
345
+ ```python
346
+ # Old
347
+ config = {"threshold": 0.5, "enable_tracking": True}
348
+
349
+ # New
350
+ config = processor.create_config("people_counting",
351
+ confidence_threshold=0.5,
352
+ enable_tracking=True)
353
+ ```
354
+
355
+ ## ๐Ÿ› Troubleshooting
356
+
357
+ ### Common Issues
358
+
359
+ 1. **Use Case Not Found**:
360
+ ```python
361
+ # Check available use cases
362
+ print(processor.list_available_usecases())
363
+ ```
364
+
365
+ 2. **Configuration Validation Errors**:
366
+ ```python
367
+ # Validate configuration
368
+ errors = processor.validate_config(config)
369
+ if errors:
370
+ print(f"Validation errors: {errors}")
371
+ ```
372
+
373
+ 3. **Processing Failures**:
374
+ ```python
375
+ # Check result status and error details
376
+ if not result.is_success():
377
+ print(f"Error: {result.error_message}")
378
+ print(f"Error type: {result.error_type}")
379
+ print(f"Error details: {result.error_details}")
380
+ ```
381
+
382
+ ## ๐Ÿ“ API Reference
383
+
384
+ ### Main Classes
385
+
386
+ - **`PostProcessor`**: Main processing class
387
+ - **`ProcessingResult`**: Standardized result container
388
+ - **`BaseConfig`**: Base configuration class
389
+ - **`PeopleCountingConfig`**: People counting configuration
390
+ - **`CustomerServiceConfig`**: Customer service configuration
391
+
392
+ ### Convenience Functions
393
+
394
+ - **`process_simple()`**: Simple processing function
395
+ - **`create_config_template()`**: Get configuration template
396
+ - **`list_available_usecases()`**: List available use cases
397
+ - **`validate_config()`**: Validate configuration
398
+
399
+ ### Utility Functions
400
+
401
+ The system provides comprehensive utility functions organized by category:
402
+
403
+ - **Geometry**: Point-in-polygon, distance calculations, IoU
404
+ - **Format**: Format detection and conversion
405
+ - **Filter**: Confidence filtering, deduplication
406
+ - **Counting**: Object counting, zone analysis
407
+ - **Tracking**: Movement analysis, line crossing detection
408
+
409
+ ## ๐ŸŽฏ Best Practices
410
+
411
+ 1. **Use Simple Processing for Quick Tasks**:
412
+ ```python
413
+ result = process_simple(data, "people_counting", confidence_threshold=0.5)
414
+ ```
415
+
416
+ 2. **Use PostProcessor Class for Complex Workflows**:
417
+ ```python
418
+ processor = PostProcessor()
419
+ config = processor.create_config("people_counting", **params)
420
+ result = processor.process(data, config)
421
+ ```
422
+
423
+ 3. **Always Check Result Status**:
424
+ ```python
425
+ if result.is_success():
426
+ # Process successful result
427
+ else:
428
+ # Handle error
429
+ ```
430
+
431
+ 4. **Use Configuration Files for Complex Setups**:
432
+ ```python
433
+ processor.save_config(config, "config.json")
434
+ result = processor.process_from_file(data, "config.json")
435
+ ```
436
+
437
+ 5. **Monitor Processing Statistics**:
438
+ ```python
439
+ stats = processor.get_statistics()
440
+ # Monitor success rates and performance
441
+ ```
442
+
443
+ ## ๐Ÿ”ฎ Future Enhancements
444
+
445
+ The refactored system is designed for easy extension. Planned enhancements include:
446
+
447
+ - Additional use cases (security monitoring, retail analytics)
448
+ - Advanced tracking algorithms
449
+ - Real-time processing capabilities
450
+ - Integration with external analytics platforms
451
+ - Machine learning-based insights generation
452
+
453
+ ---
454
+
455
+ **The refactored post-processing system provides a solid foundation for scalable, maintainable, and powerful analytics capabilities. The clean architecture makes it easy to extend and customize for specific use cases while maintaining consistency and reliability.**