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,12 @@
1
+ # Boundary Drawing Tool Data Files
2
+ # This directory contains user-generated boundary tool files
3
+ # These files are created when users draw boundaries and should not be in version control
4
+
5
+ # Ignore all files in this directory except this .gitignore
6
+ *
7
+ !.gitignore
8
+
9
+ # Explanation:
10
+ # - Each boundary tool session creates a unique timestamped directory
11
+ # - Contains HTML files, processed images, and configuration files
12
+ # - These are user-specific and should remain local
@@ -0,0 +1,206 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Example usage of the Easy Boundary Drawing Tool.
4
+
5
+ This file demonstrates various ways to use the boundary drawing tool
6
+ with minimal code for quick zone definition.
7
+ """
8
+
9
+ import os
10
+ from matrice_analytics.boundary_drawing_internal import (
11
+ EasyBoundaryTool,
12
+ quick_boundary_tool,
13
+ create_standalone_tool,
14
+ get_usage_template
15
+ )
16
+
17
+
18
+ def example_1_quick_video_tool():
19
+ """Example 1: Create a boundary tool from a video file with one line."""
20
+ print("šŸ“¹ Example 1: Quick video boundary tool")
21
+ print("=" * 50)
22
+
23
+ # Replace with your video file path
24
+ video_path = "example_video.mp4"
25
+
26
+ if os.path.exists(video_path):
27
+ # One line to create and open the tool
28
+ html_path = quick_boundary_tool(
29
+ video_path,
30
+ zones_needed=["queue", "staff", "entry", "exit"]
31
+ )
32
+ print(f"āœ… Tool created: {html_path}")
33
+ else:
34
+ print(f"āš ļø Video file not found: {video_path}")
35
+ print("Replace 'example_video.mp4' with your actual video file path")
36
+
37
+
38
+ def example_2_image_tool():
39
+ """Example 2: Create a boundary tool from an image file."""
40
+ print("\nšŸ–¼ļø Example 2: Image boundary tool")
41
+ print("=" * 50)
42
+
43
+ # Replace with your image file path
44
+ image_path = "example_frame.jpg"
45
+
46
+ if os.path.exists(image_path):
47
+ tool = EasyBoundaryTool()
48
+ html_path = tool.create_from_image(image_path)
49
+ print(f"āœ… Tool created: {html_path}")
50
+ else:
51
+ print(f"āš ļø Image file not found: {image_path}")
52
+ print("Replace 'example_frame.jpg' with your actual image file path")
53
+
54
+
55
+ def example_3_class_usage():
56
+ """Example 3: Using the class for more control."""
57
+ print("\nšŸ”§ Example 3: Class-based usage with more control")
58
+ print("=" * 50)
59
+
60
+ # Initialize tool with custom settings
61
+ tool = EasyBoundaryTool(
62
+ auto_open_browser=False, # Don't auto-open browser
63
+ grid_step=25 # Smaller grid for precision
64
+ )
65
+
66
+ # Replace with your file path
67
+ file_path = "your_file.mp4" # or .jpg, .png, etc.
68
+
69
+ if os.path.exists(file_path):
70
+ # Auto-detect file type and create tool
71
+ html_path = tool.quick_setup(
72
+ file_path,
73
+ zones_needed=["customer_area", "service_desk", "waiting_zone"]
74
+ )
75
+ print(f"āœ… Tool created (browser not opened): {html_path}")
76
+
77
+ # Get template code for integration
78
+ template = tool.get_template_code(["customer_area", "service_desk"])
79
+ print("\nšŸ“ Template code for using your zones:")
80
+ print(template[:300] + "..." if len(template) > 300 else template)
81
+
82
+ # Clean up temporary files when done
83
+ tool.cleanup()
84
+ else:
85
+ print(f"āš ļø File not found: {file_path}")
86
+ print("Replace 'your_file.mp4' with your actual file path")
87
+
88
+
89
+ def example_4_standalone_tool():
90
+ """Example 4: Create a standalone tool for drag & drop."""
91
+ print("\nšŸ“Ž Example 4: Standalone drag & drop tool")
92
+ print("=" * 50)
93
+
94
+ # Create a standalone HTML tool
95
+ html_path = create_standalone_tool(
96
+ output_path="my_boundary_tool.html",
97
+ auto_open=True
98
+ )
99
+
100
+ print(f"āœ… Standalone tool created: {html_path}")
101
+ print("šŸŽÆ You can now drag & drop any video or image file into the tool!")
102
+
103
+
104
+ def example_5_integration_code():
105
+ """Example 5: Show how to integrate generated zones with post-processing."""
106
+ print("\nšŸ”— Example 5: Integration with post-processing")
107
+ print("=" * 50)
108
+
109
+ # Example zones (replace with your generated zones)
110
+ zones = {
111
+ "queue": [[100, 200], [300, 200], [300, 400], [100, 400]],
112
+ "staff": [[500, 100], [700, 100], [700, 300], [500, 300]],
113
+ "entry": [[50, 50], [150, 100]]
114
+ }
115
+
116
+ print("šŸ“ Example integration code:")
117
+ print("""
118
+ # 1. Customer Service Processor
119
+ from matrice_analytics.post_processing import CustomerServiceProcessor
120
+
121
+ processor = CustomerServiceProcessor(
122
+ customer_areas=zones["queue"],
123
+ staff_areas=zones["staff"],
124
+ service_areas=zones.get("service", {})
125
+ )
126
+
127
+ # 2. Advanced Tracking with Entry/Exit
128
+ from matrice_analytics.post_processing import AdvancedTrackingProcessor
129
+ from matrice_analytics.post_processing.config import AdvancedTrackingConfig
130
+
131
+ config = AdvancedTrackingConfig(
132
+ boundary_config={
133
+ "points": zones["entry"],
134
+ "type": "line"
135
+ }
136
+ )
137
+ tracker = AdvancedTrackingProcessor(config)
138
+
139
+ # 3. Count objects in zones
140
+ from matrice_analytics.post_processing import CountingProcessor
141
+
142
+ counter = CountingProcessor(your_config)
143
+ results = counter.count_in_zones(detection_results, zones=zones)
144
+ """)
145
+
146
+
147
+ def example_6_workflow():
148
+ """Example 6: Complete workflow example."""
149
+ print("\nšŸ”„ Example 6: Complete workflow")
150
+ print("=" * 50)
151
+
152
+ print("""
153
+ šŸ“‹ Complete Boundary Drawing Workflow:
154
+
155
+ 1. šŸ“¹ Start with your video/image:
156
+ tool = EasyBoundaryTool()
157
+ html_path = tool.create_from_video("security_camera.mp4")
158
+
159
+ 2. šŸŽØ Use the interactive tool to draw zones:
160
+ - Select zone types (queue, staff, entry, etc.)
161
+ - Click on image to add points
162
+ - Complete zones with right-click or Enter
163
+ - Generate and copy the Python code
164
+
165
+ 3. šŸ“ Use generated zones in your application:
166
+ # Paste the generated code
167
+ zones = {
168
+ "queue": [[x1, y1], [x2, y2], ...],
169
+ "staff": [[x1, y1], [x2, y2], ...]
170
+ }
171
+
172
+ 4. šŸ”§ Integrate with post-processing:
173
+ processor = CustomerServiceProcessor(
174
+ customer_areas=zones["queue"],
175
+ staff_areas=zones["staff"]
176
+ )
177
+
178
+ 5. šŸš€ Process your data:
179
+ results = processor.process_detections(detection_data)
180
+ """)
181
+
182
+
183
+ def main():
184
+ """Run all examples."""
185
+ print("šŸŽÆ Easy Boundary Drawing Tool - Usage Examples")
186
+ print("=" * 60)
187
+
188
+ # Run examples
189
+ example_1_quick_video_tool()
190
+ example_2_image_tool()
191
+ example_3_class_usage()
192
+ example_4_standalone_tool()
193
+ example_5_integration_code()
194
+ example_6_workflow()
195
+
196
+ print("\n" + "=" * 60)
197
+ print("šŸ’” Tips:")
198
+ print("- Replace example file paths with your actual files")
199
+ print("- The tool supports MP4, AVI, MOV, JPG, PNG, and more")
200
+ print("- Generated zones work directly with Matrice post-processing")
201
+ print("- Save configurations as JSON for reuse")
202
+ print("- Use custom zone names for specific use cases")
203
+
204
+
205
+ if __name__ == "__main__":
206
+ main()
@@ -0,0 +1,110 @@
1
+ # Boundary Drawing Tool Usage Examples
2
+
3
+ This folder contains ready-to-use launcher scripts for the Matrice Boundary Drawing Tool.
4
+
5
+ ## šŸ“ Files
6
+
7
+ ### `boundary_drawer_launcher.py`
8
+ - **Purpose**: Full-featured launcher with comprehensive error handling
9
+ - **Features**: Detailed instructions, multiple fallback methods, airport security zones
10
+ - **Best for**: First-time users or when you need detailed guidance
11
+
12
+ ### `simple_boundary_launcher.py`
13
+ - **Purpose**: Clean, simple launcher that's easy to customize
14
+ - **Features**: Function-based approach, minimal output, customizable zones
15
+ - **Best for**: Experienced users or when you want to modify the code
16
+
17
+ ## šŸš€ Quick Start
18
+
19
+ 1. **Navigate to this folder**:
20
+ ```bash
21
+ cd python-sdk/src/matrice/deploy/utils/boundary_drawing_internal/usage
22
+ ```
23
+
24
+ 2. **Run a launcher**:
25
+ ```bash
26
+ python boundary_drawer_launcher.py
27
+ # OR
28
+ python simple_boundary_launcher.py
29
+ ```
30
+
31
+ 3. **The tool will**:
32
+ - Check if your video file exists at: `C:\Users\pathi\OneDrive\Desktop\matriceai\matrice-applications\airport-security\door2.mp4`
33
+ - Launch an interactive HTML tool in your browser
34
+ - Allow you to draw boundaries on video frames
35
+ - Generate Python code with zone coordinates
36
+
37
+ ## šŸŽÆ Customization
38
+
39
+ ### Change Video Path
40
+ Edit the `VIDEO_PATH` variable in either file:
41
+ ```python
42
+ VIDEO_PATH = r"path\to\your\video.mp4"
43
+ ```
44
+
45
+ ### Modify Zone Names
46
+ Update the zone lists for your specific use case:
47
+ ```python
48
+ # For airport security
49
+ SECURITY_ZONES = [
50
+ "entry_door",
51
+ "security_line",
52
+ "checkpoint",
53
+ "waiting_area",
54
+ "restricted_zone",
55
+ "exit_door"
56
+ ]
57
+
58
+ # For retail
59
+ RETAIL_ZONES = [
60
+ "entrance",
61
+ "checkout",
62
+ "aisles",
63
+ "customer_service"
64
+ ]
65
+ ```
66
+
67
+ ## šŸ”§ How the Tool Works
68
+
69
+ 1. **Select Zone Type**: Choose from the dropdown menu
70
+ 2. **Draw Boundaries**: Click points on the video frame
71
+ 3. **Complete Zone**: Right-click or press Enter
72
+ 4. **Generate Code**: Click the "Generate Code" button
73
+ 5. **Copy & Use**: Copy the Python code for your application
74
+
75
+ ## šŸ“¤ Output Format
76
+
77
+ The tool generates Python code like this:
78
+ ```python
79
+ zones = {
80
+ "entry_door": [[100, 200], [300, 200], [300, 400], [100, 400]],
81
+ "security_line": [[350, 150], [500, 150], [500, 350], [350, 350]],
82
+ "checkpoint": [[200, 100], [400, 120], [380, 250], [180, 230]]
83
+ }
84
+ ```
85
+
86
+ ## šŸ”— Integration
87
+
88
+ Use the generated zones with Matrice post-processing:
89
+ ```python
90
+ from matrice_analytics.post_processing import CustomerServiceProcessor
91
+
92
+ processor = CustomerServiceProcessor(
93
+ customer_areas=zones["waiting_area"],
94
+ staff_areas=zones["restricted_zone"]
95
+ )
96
+ ```
97
+
98
+ ## šŸ› Troubleshooting
99
+
100
+ - **Import Error**: Make sure you're running from the correct directory
101
+ - **Video Not Found**: Check the video path in the script
102
+ - **Browser Doesn't Open**: The HTML file path will be printed - open it manually
103
+ - **Tool Not Working**: Try the alternative method in `boundary_drawer_launcher.py`
104
+
105
+ ## šŸ’” Tips
106
+
107
+ - Use precise boundary drawing for better results
108
+ - Save your zone configurations as JSON for reuse
109
+ - Test with a short video clip first
110
+ - The tool works with MP4, AVI, MOV, JPG, PNG files
@@ -0,0 +1,102 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Boundary Drawing Tool Launcher for Airport Security Video
4
+
5
+ This script launches the interactive boundary drawing tool for creating
6
+ zones in the airport security video door2.mp4.
7
+ """
8
+
9
+ import os
10
+ import sys
11
+ from pathlib import Path
12
+
13
+ # Add the python-sdk to the path so we can import matrice modules
14
+ # Navigate up from usage folder to find the src directory
15
+ current_dir = Path(__file__).parent.absolute()
16
+ src_path = current_dir.parent.parent.parent
17
+ sys.path.insert(0, str(src_path))
18
+
19
+ # Alternative: Add the matrice package directly
20
+ matrice_path = src_path / "matrice"
21
+ if matrice_path.exists():
22
+ sys.path.insert(0, str(src_path))
23
+
24
+ try:
25
+ from matrice_analytics.boundary_drawing_internal import (
26
+ EasyBoundaryTool,
27
+ quick_boundary_tool
28
+ )
29
+ except ImportError as e:
30
+ print(f"āŒ Error importing matrice modules: {e}")
31
+ print("Make sure you're running this from the matriceai directory")
32
+ sys.exit(1)
33
+
34
+
35
+ def main():
36
+ """Launch the boundary drawing tool for the airport security video."""
37
+
38
+ # Video path
39
+ video_path = r"C:\Users\pathi\OneDrive\Desktop\matriceai\matrice-applications\airport-security\door2.mp4"
40
+
41
+ print("šŸŽÆ Airport Security Boundary Drawing Tool")
42
+ print("=" * 50)
43
+ print(f"šŸ“¹ Video: {video_path}")
44
+
45
+ # Check if video exists
46
+ if not os.path.exists(video_path):
47
+ print(f"āŒ Video file not found: {video_path}")
48
+ print("\nPlease check that the file exists and the path is correct.")
49
+ return
50
+
51
+ print("āœ… Video file found!")
52
+ print("\nšŸš€ Launching boundary drawing tool...")
53
+
54
+ try:
55
+ # Launch the boundary drawing tool with relevant zones for airport security
56
+ html_path = quick_boundary_tool(
57
+ video_path,
58
+ zones_needed=[
59
+ "entry_zone",
60
+ "security_checkpoint",
61
+ "waiting_area",
62
+ "restricted_area",
63
+ "exit_zone",
64
+ "monitoring_zone"
65
+ ]
66
+ )
67
+
68
+ print(f"āœ… Boundary drawing tool launched!")
69
+ print(f"🌐 Tool URL: {html_path}")
70
+ print("\nšŸ“‹ Instructions:")
71
+ print("1. The tool should open in your default browser")
72
+ print("2. Select a zone type from the dropdown")
73
+ print("3. Click on the video frame to create boundary points")
74
+ print("4. Right-click or press Enter to complete a zone")
75
+ print("5. Generate Python code when finished")
76
+ print("6. Copy the generated code for use in your application")
77
+
78
+ print("\nšŸ’” Suggested zones for airport security:")
79
+ print("- entry_zone: Area where people enter")
80
+ print("- security_checkpoint: X-ray and metal detector area")
81
+ print("- waiting_area: Queue or waiting zones")
82
+ print("- restricted_area: Staff-only or secure areas")
83
+ print("- exit_zone: Exit doors and pathways")
84
+ print("- monitoring_zone: Areas under special surveillance")
85
+
86
+ except Exception as e:
87
+ print(f"āŒ Error launching tool: {e}")
88
+ print("\nTrying alternative method...")
89
+
90
+ # Alternative method using the class directly
91
+ try:
92
+ tool = EasyBoundaryTool(auto_open_browser=True)
93
+ html_path = tool.create_from_video(video_path)
94
+ print(f"āœ… Alternative launch successful!")
95
+ print(f"🌐 Tool URL: {html_path}")
96
+ except Exception as e2:
97
+ print(f"āŒ Alternative method also failed: {e2}")
98
+ print("Please check the matrice installation and try again.")
99
+
100
+
101
+ if __name__ == "__main__":
102
+ main()
@@ -0,0 +1,107 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Simple Boundary Drawing Tool Launcher
4
+
5
+ A simpler version of the boundary drawing launcher with more configuration options.
6
+ """
7
+
8
+ import os
9
+ import sys
10
+ from pathlib import Path
11
+
12
+ # Add the python-sdk to the path
13
+ # Navigate up from usage folder to find the src directory
14
+ current_dir = Path(__file__).parent.absolute()
15
+ src_path = current_dir.parent.parent.parent
16
+ sys.path.insert(0, str(src_path))
17
+
18
+ # Alternative: Add the matrice package directly
19
+ matrice_path = src_path / "matrice"
20
+ if matrice_path.exists():
21
+ sys.path.insert(0, str(src_path))
22
+
23
+ def launch_boundary_tool(video_path, custom_zones=None):
24
+ """
25
+ Launch the boundary drawing tool for any video file.
26
+
27
+ Args:
28
+ video_path (str): Path to the video file
29
+ custom_zones (list): List of zone names to use
30
+ """
31
+
32
+ try:
33
+ from matrice_analytics.boundary_drawing_internal import EasyBoundaryTool
34
+ except ImportError as e:
35
+ print(f"āŒ Error importing matrice modules: {e}")
36
+ return None
37
+
38
+ # Default zones if none provided
39
+ if custom_zones is None:
40
+ custom_zones = ["zone1", "zone2", "zone3", "zone4"]
41
+
42
+ print(f"šŸŽÆ Launching boundary tool for: {os.path.basename(video_path)}")
43
+ print(f"šŸ“ Zones to create: {', '.join(custom_zones)}")
44
+
45
+ # Check if file exists
46
+ if not os.path.exists(video_path):
47
+ print(f"āŒ File not found: {video_path}")
48
+ return None
49
+
50
+ try:
51
+ # Create the tool with custom settings
52
+ tool = EasyBoundaryTool(
53
+ auto_open_browser=True, # Automatically open browser
54
+ grid_step=20 # Grid step for precise drawing
55
+ )
56
+
57
+ # Create the boundary tool
58
+ html_path = tool.quick_setup(video_path, zones_needed=custom_zones)
59
+
60
+ print(f"āœ… Tool created successfully!")
61
+ print(f"🌐 Browser should open automatically")
62
+ print(f"šŸ“„ Tool file: {html_path}")
63
+
64
+ return html_path
65
+
66
+ except Exception as e:
67
+ print(f"āŒ Error creating tool: {e}")
68
+ return None
69
+
70
+
71
+ if __name__ == "__main__":
72
+ # Your video path
73
+ VIDEO_PATH = r"C:\Users\pathi\OneDrive\Desktop\matriceai\matrice-applications\airport-security\door2.mp4"
74
+
75
+ # Custom zones for airport security (you can modify these)
76
+ SECURITY_ZONES = [
77
+ "entry_door",
78
+ "security_line",
79
+ "checkpoint",
80
+ "waiting_area",
81
+ "restricted_zone",
82
+ "exit_door"
83
+ ]
84
+
85
+ print("šŸ”’ Airport Security Boundary Drawing Tool")
86
+ print("=" * 45)
87
+
88
+ # Launch the tool
89
+ result = launch_boundary_tool(VIDEO_PATH, SECURITY_ZONES)
90
+
91
+ if result:
92
+ print("\n✨ Success! The boundary drawing tool is now open.")
93
+ print("\nšŸ“‹ How to use:")
94
+ print("1. Select a zone type from the dropdown menu")
95
+ print("2. Click points on the video frame to draw boundaries")
96
+ print("3. Complete each zone by right-clicking or pressing Enter")
97
+ print("4. Click 'Generate Code' when finished")
98
+ print("5. Copy the generated Python code for your application")
99
+
100
+ print("\nšŸ’¾ The generated code will look like:")
101
+ print("zones = {")
102
+ print(' "entry_door": [[x1, y1], [x2, y2], ...],')
103
+ print(' "security_line": [[x1, y1], [x2, y2], ...],')
104
+ print(" ...")
105
+ print("}")
106
+ else:
107
+ print("\nāŒ Failed to launch the tool. Please check the error messages above.")