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