matrice 1.0.99141__tar.gz → 1.0.99142__tar.gz
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.
- {matrice-1.0.99141/src/matrice.egg-info → matrice-1.0.99142}/PKG-INFO +1 -1
- {matrice-1.0.99141 → matrice-1.0.99142}/setup.py +1 -1
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/config.py +4 -0
- matrice-1.0.99142/src/matrice/deploy/utils/post_processing/usecases/road_lane_detection.py +598 -0
- matrice-1.0.99142/src/matrice/deploy/utils/post_processing/usecases/shelf_inventory_detection.py +583 -0
- {matrice-1.0.99141 → matrice-1.0.99142/src/matrice.egg-info}/PKG-INFO +1 -1
- matrice-1.0.99141/src/matrice/deploy/utils/post_processing/usecases/road_lane_detection.py +0 -606
- matrice-1.0.99141/src/matrice/deploy/utils/post_processing/usecases/shelf_inventory_detection.py +0 -618
- {matrice-1.0.99141 → matrice-1.0.99142}/LICENSE.txt +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/README.md +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/setup.cfg +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/__init__.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/action.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/actionTracker.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/action_tracker.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/annotation.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/app_store.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/application.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/compute.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/compute_manager/__init__.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/compute_manager/action_instance.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/compute_manager/actions_manager.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/compute_manager/actions_scaledown_manager.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/compute_manager/instance_manager.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/compute_manager/instance_utils.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/compute_manager/prechecks.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/compute_manager/resources_tracker.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/compute_manager/scaling.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/compute_manager/shutdown_manager.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/compute_manager/task_utils.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/data_processing/__init__.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/data_processing/augmentation_utils/__init__.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/data_processing/augmentation_utils/base.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/data_processing/augmentation_utils/strategies/__init__.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/data_processing/augmentation_utils/strategies/bit_depth_reduction.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/data_processing/augmentation_utils/strategies/blur.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/data_processing/augmentation_utils/strategies/brightness_contrast.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/data_processing/augmentation_utils/strategies/color_jitter.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/data_processing/augmentation_utils/strategies/compression_artifacts.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/data_processing/augmentation_utils/strategies/downscale_upscale.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/data_processing/augmentation_utils/strategies/film_grain.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/data_processing/augmentation_utils/strategies/flip.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/data_processing/augmentation_utils/strategies/fog.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/data_processing/augmentation_utils/strategies/horizontal_flip.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/data_processing/augmentation_utils/strategies/hsv.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/data_processing/augmentation_utils/strategies/iso_noise.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/data_processing/augmentation_utils/strategies/low_light.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/data_processing/augmentation_utils/strategies/posterize.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/data_processing/augmentation_utils/strategies/rain.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/data_processing/augmentation_utils/strategies/random_affine.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/data_processing/augmentation_utils/strategies/salt_pepper.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/data_processing/augmentation_utils/strategies/shadows.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/data_processing/augmentation_utils/strategies/snow.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/data_processing/augmentation_utils/strategies/speckle.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/data_processing/augmentation_utils/strategies/sunflare.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/data_processing/client.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/data_processing/client_utils.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/data_processing/create_dataset.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/data_processing/data_augmentation.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/data_processing/data_augmentor.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/data_processing/data_formats/__init__.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/data_processing/data_formats/imagenet_classification.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/data_processing/data_formats/labelbox_classification.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/data_processing/data_formats/labelbox_detection.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/data_processing/data_formats/mscoco_detection.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/data_processing/data_formats/pascalvoc_detection.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/data_processing/data_formats/unlabelled.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/data_processing/data_formats/video_davis_segmentation.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/data_processing/data_formats/video_detection_mscoco.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/data_processing/data_formats/video_imagenet_classification.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/data_processing/data_formats/video_kinetics_activity_recognition.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/data_processing/data_formats/video_mot_tracking.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/data_processing/data_formats/video_mscoco_detection.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/data_processing/data_formats/video_youtube_bb_tracking.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/data_processing/data_formats/yolo_detection.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/data_processing/data_labelling.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/data_processing/data_prep.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/data_processing/data_processor.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/data_processing/image_augmentations.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/data_processing/image_data_augmentation.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/data_processing/new_data_augmentation.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/data_processing/pipeline.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/data_processing/server.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/data_processing/server_utils.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/data_processing/video_server.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/dataset.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/__init__.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/aggregator/__init__.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/aggregator/aggregator.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/aggregator/ingestor.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/aggregator/pipeline.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/aggregator/publisher.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/aggregator/synchronizer.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/client/__init__.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/client/auto_streaming/__init__.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/client/auto_streaming/auto_streaming.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/client/auto_streaming/auto_streaming_utils.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/client/client.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/client/client_stream_utils.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/client/client_utils.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/client/frame_comparators.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/client/streaming_gateway/__init__.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/client/streaming_gateway/streaming_gateway.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/client/streaming_gateway/streaming_gateway_utils.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/client/streaming_gateway/streaming_results_handler.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/server/__init__.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/server/inference/__init__.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/server/inference/batch_manager.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/server/inference/cache_manager.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/server/inference/inference_interface.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/server/inference/model_manager.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/server/inference/triton_utils.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/server/proxy/__init__.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/server/proxy/proxy_interface.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/server/proxy/proxy_utils.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/server/server.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/server/stream_worker.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/__init__.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/boundary_drawing_internal/__init__.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/boundary_drawing_internal/boundary_drawing_internal.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/boundary_drawing_internal/boundary_drawing_tool.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/boundary_drawing_internal/example_usage.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/kafka_utils.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/__init__.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/advanced_tracker/__init__.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/advanced_tracker/base.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/advanced_tracker/config.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/advanced_tracker/kalman_filter.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/advanced_tracker/matching.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/advanced_tracker/strack.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/advanced_tracker/tracker.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/core/__init__.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/core/base.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/core/config.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/core/config_utils.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/processor.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/test_cases/__init__.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/test_cases/run_tests.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/test_cases/test_advanced_customer_service.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/test_cases/test_basic_counting_tracking.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/test_cases/test_comprehensive.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/test_cases/test_config.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/test_cases/test_customer_service.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/test_cases/test_data_generators.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/test_cases/test_people_counting.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/test_cases/test_processor.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/test_cases/test_utilities.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/test_cases/test_utils.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/usecases/__init__.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/usecases/advanced_customer_service.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/usecases/age_detection.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/usecases/anti_spoofing_detection.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/usecases/assembly_line_detection.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/usecases/banana_defect_detection.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/usecases/basic_counting_tracking.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/usecases/blood_cancer_detection_img.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/usecases/car_damage_detection.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/usecases/car_part_segmentation.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/usecases/chicken_pose_detection.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/usecases/child_monitoring.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/usecases/color_detection.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/usecases/color_map_utils.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/usecases/concrete_crack_detection.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/usecases/crop_weed_detection.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/usecases/customer_service.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/usecases/defect_detection_products.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/usecases/distracted_driver_detection.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/usecases/emergency_vehicle_detection.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/usecases/face_emotion.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/usecases/fashion_detection.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/usecases/field_mapping.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/usecases/fire_detection.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/usecases/flare_analysis.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/usecases/flower_segmentation.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/usecases/gender_detection.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/usecases/leaf.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/usecases/leaf_disease.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/usecases/license_plate_detection.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/usecases/mask_detection.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/usecases/parking.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/usecases/parking_space_detection.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/usecases/pedestrian_detection.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/usecases/people_counting.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/usecases/plaque_segmentation_img.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/usecases/pothole_segmentation.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/usecases/ppe_compliance.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/usecases/price_tag_detection.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/usecases/shoplifting_detection.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/usecases/shopping_cart_analysis.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/usecases/skin_cancer_classification_img.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/usecases/solar_panel.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/usecases/template_usecase.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/usecases/theft_detection.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/usecases/traffic_sign_monitoring.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/usecases/underwater_pollution_detection.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/usecases/vehicle_monitoring.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/usecases/warehouse_object_segmentation.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/usecases/weapon_detection.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/usecases/weld_defect_detection.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/usecases/windmill_maintenance.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/usecases/wound_segmentation.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/utils/__init__.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/utils/advanced_counting_utils.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/utils/advanced_helper_utils.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/utils/advanced_tracking_utils.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/utils/alerting_utils.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/utils/category_mapping_utils.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/utils/color_utils.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/utils/counting_utils.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/utils/filter_utils.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/utils/format_utils.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/utils/geometry_utils.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/utils/smoothing_utils.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deploy/utils/post_processing/utils/tracking_utils.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deployment/__init__.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deployment/camera_manager.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deployment/deployment.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deployment/inference_pipeline.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/deployment/streaming_gateway_manager.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/docker_utils.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/drift_monitor.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/exported_model.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/local_test.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/metrics_calculator.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/metrics_calculator_oop.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/model_store.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/models.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/pipeline.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/projects.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/rpc.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/scaling.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/session.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/testing.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/token_auth.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice/utils.py +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice.egg-info/SOURCES.txt +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice.egg-info/dependency_links.txt +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice.egg-info/requires.txt +0 -0
- {matrice-1.0.99141 → matrice-1.0.99142}/src/matrice.egg-info/top_level.txt +0 -0
@@ -26,6 +26,8 @@ APP_NAME_TO_USECASE = {
|
|
26
26
|
"weld_defect_detection" : "weld_defect_detection",
|
27
27
|
"fruit_monitoring" : "fruit_monitoring",
|
28
28
|
"concrete_crack_detection": "concrete_crack_detection",
|
29
|
+
"lane_detection" : "lane_detection",
|
30
|
+
"shelf_inventory" :"shelf_inventory",
|
29
31
|
}
|
30
32
|
|
31
33
|
APP_NAME_TO_CATEGORY = {
|
@@ -56,6 +58,8 @@ APP_NAME_TO_CATEGORY = {
|
|
56
58
|
"weld_defect_detection" : "weld",
|
57
59
|
"fruit_monitoring" : "agriculture",
|
58
60
|
"concrete_crack_detection": "general",
|
61
|
+
"lane_detection" : "traffic",
|
62
|
+
"shelf_inventory" : "retail",
|
59
63
|
}
|
60
64
|
|
61
65
|
def get_usecase_from_app_name(app_name: str) -> str:
|
@@ -0,0 +1,598 @@
|
|
1
|
+
"""
|
2
|
+
Road Lane Detection Use Case for Post-Processing
|
3
|
+
|
4
|
+
This module provides road lane detection functionality with lane type classification,
|
5
|
+
zone analysis, and alert generation.
|
6
|
+
"""
|
7
|
+
|
8
|
+
from typing import Any, Dict, List, Optional
|
9
|
+
from dataclasses import asdict, dataclass, field
|
10
|
+
import time
|
11
|
+
from datetime import datetime, timezone
|
12
|
+
|
13
|
+
from ..core.base import BaseProcessor, ProcessingContext, ProcessingResult, ConfigProtocol
|
14
|
+
from ..utils import (
|
15
|
+
filter_by_confidence,
|
16
|
+
filter_by_categories,
|
17
|
+
apply_category_mapping,
|
18
|
+
count_objects_by_category,
|
19
|
+
count_objects_in_zones,
|
20
|
+
calculate_counting_summary,
|
21
|
+
match_results_structure,
|
22
|
+
bbox_smoothing,
|
23
|
+
BBoxSmoothingConfig,
|
24
|
+
BBoxSmoothingTracker
|
25
|
+
)
|
26
|
+
from ..core.config import BaseConfig, AlertConfig, ZoneConfig
|
27
|
+
|
28
|
+
@dataclass
|
29
|
+
class LaneDetectionConfig(BaseConfig):
|
30
|
+
"""Configuration for road lane detection use case."""
|
31
|
+
enable_smoothing: bool = True
|
32
|
+
smoothing_algorithm: str = "observability"
|
33
|
+
smoothing_window_size: int = 20
|
34
|
+
smoothing_cooldown_frames: int = 5
|
35
|
+
smoothing_confidence_range_factor: float = 0.5
|
36
|
+
confidence_threshold: float = 0.6
|
37
|
+
usecase_categories: List[str] = field(
|
38
|
+
default_factory=lambda: ['Divider-Line', 'Dotted-Line', 'Double-Line', 'Random-Line', 'Road-Sign-Line', 'Solid-Line']
|
39
|
+
)
|
40
|
+
target_categories: List[str] = field(
|
41
|
+
default_factory=lambda: ['Divider-Line', 'Dotted-Line', 'Double-Line', 'Random-Line', 'Road-Sign-Line', 'Solid-Line']
|
42
|
+
)
|
43
|
+
alert_config: Optional[AlertConfig] = None
|
44
|
+
index_to_category: Optional[Dict[int, str]] = field(
|
45
|
+
default_factory=lambda: {
|
46
|
+
0: "Divider-Line",
|
47
|
+
1: "Dotted-Line",
|
48
|
+
2: "Double-Line",
|
49
|
+
3: "Random-Line",
|
50
|
+
4: "Road-Sign-Line",
|
51
|
+
5: "Solid-Line"
|
52
|
+
}
|
53
|
+
)
|
54
|
+
|
55
|
+
class LaneDetectionUseCase(BaseProcessor):
|
56
|
+
CATEGORY_DISPLAY = {
|
57
|
+
"Divider-Line": "Divider Line",
|
58
|
+
"Dotted-Line": "Dotted Line",
|
59
|
+
"Double-Line": "Double Line",
|
60
|
+
"Random-Line": "Random Line",
|
61
|
+
"Road-Sign-Line": "Road Sign Line",
|
62
|
+
"Solid-Line": "Solid Line"
|
63
|
+
}
|
64
|
+
|
65
|
+
def __init__(self):
|
66
|
+
super().__init__("lane_detection")
|
67
|
+
self.category = "traffic"
|
68
|
+
self.CASE_TYPE: Optional[str] = 'lane_detection'
|
69
|
+
self.CASE_VERSION: Optional[str] = '1.0'
|
70
|
+
self.target_categories = ['Divider-Line', 'Dotted-Line', 'Double-Line', 'Random-Line', 'Road-Sign-Line', 'Solid-Line']
|
71
|
+
self.smoothing_tracker = None
|
72
|
+
self.tracker = None
|
73
|
+
self._total_frame_counter = 0
|
74
|
+
self._global_frame_offset = 0
|
75
|
+
self._tracking_start_time = None
|
76
|
+
self._track_aliases: Dict[Any, Any] = {}
|
77
|
+
self._canonical_tracks: Dict[Any, Dict[str, Any]] = {}
|
78
|
+
self._track_merge_iou_threshold: float = 0.05
|
79
|
+
self._track_merge_time_window: float = 7.0
|
80
|
+
self._ascending_alert_list: List[int] = []
|
81
|
+
self.current_incident_end_timestamp: str = "N/A"
|
82
|
+
|
83
|
+
def process(self, data: Any, config: ConfigProtocol, context: Optional[ProcessingContext] = None,
|
84
|
+
stream_info: Optional[Dict[str, Any]] = None) -> ProcessingResult:
|
85
|
+
start_time = time.time()
|
86
|
+
if not isinstance(config, LaneDetectionConfig):
|
87
|
+
return self.create_error_result("Invalid config type", usecase=self.name, category=self.category, context=context)
|
88
|
+
if context is None:
|
89
|
+
context = ProcessingContext()
|
90
|
+
|
91
|
+
input_format = match_results_structure(data)
|
92
|
+
context.input_format = input_format
|
93
|
+
context.confidence_threshold = config.confidence_threshold
|
94
|
+
|
95
|
+
if config.confidence_threshold is not None:
|
96
|
+
processed_data = filter_by_confidence(data, config.confidence_threshold)
|
97
|
+
self.logger.debug(f"Applied confidence filtering with threshold {config.confidence_threshold}")
|
98
|
+
else:
|
99
|
+
processed_data = data
|
100
|
+
self.logger.debug("No confidence filtering applied")
|
101
|
+
|
102
|
+
if config.index_to_category:
|
103
|
+
processed_data = apply_category_mapping(processed_data, config.index_to_category)
|
104
|
+
self.logger.debug("Applied category mapping")
|
105
|
+
|
106
|
+
if config.target_categories:
|
107
|
+
processed_data = [d for d in processed_data if d.get('category') in self.target_categories]
|
108
|
+
self.logger.debug("Applied category filtering")
|
109
|
+
|
110
|
+
if config.enable_smoothing:
|
111
|
+
if self.smoothing_tracker is None:
|
112
|
+
smoothing_config = BBoxSmoothingConfig(
|
113
|
+
smoothing_algorithm=config.smoothing_algorithm,
|
114
|
+
window_size=config.smoothing_window_size,
|
115
|
+
cooldown_frames=config.smoothing_cooldown_frames,
|
116
|
+
confidence_threshold=config.confidence_threshold,
|
117
|
+
confidence_range_factor=config.smoothing_confidence_range_factor,
|
118
|
+
enable_smoothing=True
|
119
|
+
)
|
120
|
+
self.smoothing_tracker = BBoxSmoothingTracker(smoothing_config)
|
121
|
+
processed_data = bbox_smoothing(processed_data, self.smoothing_tracker.config, self.smoothing_tracker)
|
122
|
+
|
123
|
+
try:
|
124
|
+
from ..advanced_tracker import AdvancedTracker
|
125
|
+
from ..advanced_tracker.config import TrackerConfig
|
126
|
+
if self.tracker is None:
|
127
|
+
tracker_config = TrackerConfig()
|
128
|
+
self.tracker = AdvancedTracker(tracker_config)
|
129
|
+
self.logger.info("Initialized AdvancedTracker for Lane Detection")
|
130
|
+
processed_data = self.tracker.update(processed_data)
|
131
|
+
except Exception as e:
|
132
|
+
self.logger.warning(f"AdvancedTracker failed: {e}")
|
133
|
+
|
134
|
+
self._update_tracking_state(processed_data)
|
135
|
+
self._total_frame_counter += 1
|
136
|
+
|
137
|
+
frame_number = None
|
138
|
+
if stream_info:
|
139
|
+
input_settings = stream_info.get("input_settings", {})
|
140
|
+
start_frame = input_settings.get("start_frame")
|
141
|
+
end_frame = input_settings.get("end_frame")
|
142
|
+
if start_frame is not None and end_frame is not None and start_frame == end_frame:
|
143
|
+
frame_number = start_frame
|
144
|
+
|
145
|
+
general_counting_summary = calculate_counting_summary(data)
|
146
|
+
counting_summary = self._count_categories(processed_data, config)
|
147
|
+
total_counts = self.get_total_counts()
|
148
|
+
counting_summary['total_counts'] = total_counts
|
149
|
+
alerts = self._check_alerts(counting_summary, frame_number, config)
|
150
|
+
predictions = self._extract_predictions(processed_data)
|
151
|
+
|
152
|
+
incidents_list = self._generate_incidents(counting_summary, alerts, config, frame_number, stream_info)
|
153
|
+
tracking_stats_list = self._generate_tracking_stats(counting_summary, alerts, config, frame_number, stream_info)
|
154
|
+
business_analytics_list = self._generate_business_analytics(counting_summary, alerts, config, stream_info, is_empty=True)
|
155
|
+
summary_list = self._generate_summary(counting_summary, incidents_list, tracking_stats_list, business_analytics_list, alerts)
|
156
|
+
|
157
|
+
incidents = incidents_list[0] if incidents_list else {}
|
158
|
+
tracking_stats = tracking_stats_list[0] if tracking_stats_list else {}
|
159
|
+
business_analytics = business_analytics_list[0] if business_analytics_list else {}
|
160
|
+
summary = summary_list[0] if summary_list else {}
|
161
|
+
agg_summary = {str(frame_number): {
|
162
|
+
"incidents": incidents,
|
163
|
+
"tracking_stats": tracking_stats,
|
164
|
+
"business_analytics": business_analytics,
|
165
|
+
"alerts": alerts,
|
166
|
+
"human_text": summary}
|
167
|
+
}
|
168
|
+
|
169
|
+
context.mark_completed()
|
170
|
+
result = self.create_result(
|
171
|
+
data={"agg_summary": agg_summary},
|
172
|
+
usecase=self.name,
|
173
|
+
category=self.category,
|
174
|
+
context=context
|
175
|
+
)
|
176
|
+
return result
|
177
|
+
|
178
|
+
def _check_alerts(self, summary: dict, frame_number: Any, config: LaneDetectionConfig) -> List[Dict]:
|
179
|
+
def get_trend(data, lookback=900, threshold=0.6):
|
180
|
+
window = data[-lookback:] if len(data) >= lookback else data
|
181
|
+
if len(window) < 2:
|
182
|
+
return True
|
183
|
+
increasing = 0
|
184
|
+
total = 0
|
185
|
+
for i in range(1, len(window)):
|
186
|
+
if window[i] >= window[i - 1]:
|
187
|
+
increasing += 1
|
188
|
+
total += 1
|
189
|
+
ratio = increasing / total
|
190
|
+
return ratio >= threshold
|
191
|
+
|
192
|
+
frame_key = str(frame_number) if frame_number is not None else "current_frame"
|
193
|
+
alerts = []
|
194
|
+
total_detections = summary.get("total_count", 0)
|
195
|
+
total_counts_dict = summary.get("total_counts", {})
|
196
|
+
per_category_count = summary.get("per_category_count", {})
|
197
|
+
|
198
|
+
if not config.alert_config:
|
199
|
+
return alerts
|
200
|
+
|
201
|
+
if hasattr(config.alert_config, 'count_thresholds') and config.alert_config.count_thresholds:
|
202
|
+
for category, threshold in config.alert_config.count_thresholds.items():
|
203
|
+
if category == "all" and total_detections > threshold:
|
204
|
+
alerts.append({
|
205
|
+
"alert_type": getattr(config.alert_config, 'alert_type', ['Default']),
|
206
|
+
"alert_id": f"alert_{category}_{frame_key}",
|
207
|
+
"incident_category": self.CASE_TYPE,
|
208
|
+
"threshold_level": threshold,
|
209
|
+
"ascending": get_trend(self._ascending_alert_list, lookback=900, threshold=0.8),
|
210
|
+
"settings": {t: v for t, v in zip(getattr(config.alert_config, 'alert_type', ['Default']),
|
211
|
+
getattr(config.alert_config, 'alert_value', ['JSON']))}
|
212
|
+
})
|
213
|
+
elif category in per_category_count and per_category_count[category] > threshold:
|
214
|
+
alerts.append({
|
215
|
+
"alert_type": getattr(config.alert_config, 'alert_type', ['Default']),
|
216
|
+
"alert_id": f"alert_{category}_{frame_key}",
|
217
|
+
"incident_category": self.CASE_TYPE,
|
218
|
+
"threshold_level": threshold,
|
219
|
+
"ascending": get_trend(self._ascending_alert_list, lookback=900, threshold=0.8),
|
220
|
+
"settings": {t: v for t, v in zip(getattr(config.alert_config, 'alert_type', ['Default']),
|
221
|
+
getattr(config.alert_config, 'alert_value', ['JSON']))}
|
222
|
+
})
|
223
|
+
return alerts
|
224
|
+
|
225
|
+
def _generate_incidents(self, counting_summary: Dict, alerts: List, config: LaneDetectionConfig,
|
226
|
+
frame_number: Optional[int] = None, stream_info: Optional[Dict[str, Any]] = None) -> List[Dict]:
|
227
|
+
incidents = []
|
228
|
+
total_detections = counting_summary.get("total_count", 0)
|
229
|
+
current_timestamp = self._get_current_timestamp_str(stream_info)
|
230
|
+
camera_info = self.get_camera_info_from_stream(stream_info)
|
231
|
+
|
232
|
+
self._ascending_alert_list = self._ascending_alert_list[-900:] if len(self._ascending_alert_list) > 900 else self._ascending_alert_list
|
233
|
+
|
234
|
+
if total_detections > 0:
|
235
|
+
level = "low"
|
236
|
+
intensity = 5.0
|
237
|
+
start_timestamp = self._get_start_timestamp_str(stream_info)
|
238
|
+
if start_timestamp and self.current_incident_end_timestamp == 'N/A':
|
239
|
+
self.current_incident_end_timestamp = 'Incident still active'
|
240
|
+
elif start_timestamp and self.current_incident_end_timestamp == 'Incident still active':
|
241
|
+
if len(self._ascending_alert_list) >= 15 and sum(self._ascending_alert_list[-15:]) / 15 < 1.5:
|
242
|
+
self.current_incident_end_timestamp = current_timestamp
|
243
|
+
elif self.current_incident_end_timestamp != 'Incident still active' and self.current_incident_end_timestamp != 'N/A':
|
244
|
+
self.current_incident_end_timestamp = 'N/A'
|
245
|
+
|
246
|
+
if config.alert_config and config.alert_config.count_thresholds:
|
247
|
+
threshold = config.alert_config.count_thresholds.get("all", 15)
|
248
|
+
intensity = min(10.0, (total_detections / threshold) * 10)
|
249
|
+
if intensity >= 9:
|
250
|
+
level = "critical"
|
251
|
+
self._ascending_alert_list.append(3)
|
252
|
+
elif intensity >= 7:
|
253
|
+
level = "significant"
|
254
|
+
self._ascending_alert_list.append(2)
|
255
|
+
elif intensity >= 5:
|
256
|
+
level = "medium"
|
257
|
+
self._ascending_alert_list.append(1)
|
258
|
+
else:
|
259
|
+
level = "low"
|
260
|
+
self._ascending_alert_list.append(0)
|
261
|
+
else:
|
262
|
+
if total_detections > 30:
|
263
|
+
level = "critical"
|
264
|
+
intensity = 10.0
|
265
|
+
self._ascending_alert_list.append(3)
|
266
|
+
elif total_detections > 25:
|
267
|
+
level = "significant"
|
268
|
+
intensity = 9.0
|
269
|
+
self._ascending_alert_list.append(2)
|
270
|
+
elif total_detections > 15:
|
271
|
+
level = "medium"
|
272
|
+
intensity = 7.0
|
273
|
+
self._ascending_alert_list.append(1)
|
274
|
+
else:
|
275
|
+
level = "low"
|
276
|
+
intensity = min(10.0, total_detections / 3.0)
|
277
|
+
self._ascending_alert_list.append(0)
|
278
|
+
|
279
|
+
human_text_lines = [f"LANE INCIDENTS DETECTED @ {current_timestamp}:"]
|
280
|
+
human_text_lines.append(f"\tSeverity Level: {(self.CASE_TYPE, level)}")
|
281
|
+
human_text = "\n".join(human_text_lines)
|
282
|
+
|
283
|
+
alert_settings = []
|
284
|
+
if config.alert_config and hasattr(config.alert_config, 'alert_type'):
|
285
|
+
alert_settings.append({
|
286
|
+
"alert_type": getattr(config.alert_config, 'alert_type', ['Default']),
|
287
|
+
"incident_category": self.CASE_TYPE,
|
288
|
+
"threshold_level": config.alert_config.count_thresholds if hasattr(config.alert_config, 'count_thresholds') else {},
|
289
|
+
"ascending": True,
|
290
|
+
"settings": {t: v for t, v in zip(getattr(config.alert_config, 'alert_type', ['Default']),
|
291
|
+
getattr(config.alert_config, 'alert_value', ['JSON']))}
|
292
|
+
})
|
293
|
+
|
294
|
+
event = self.create_incident(
|
295
|
+
incident_id=f"{self.CASE_TYPE}_{frame_number}",
|
296
|
+
incident_type=self.CASE_TYPE,
|
297
|
+
severity_level=level,
|
298
|
+
human_text=human_text,
|
299
|
+
camera_info=camera_info,
|
300
|
+
alerts=alerts,
|
301
|
+
alert_settings=alert_settings,
|
302
|
+
start_time=start_timestamp,
|
303
|
+
end_time=self.current_incident_end_timestamp,
|
304
|
+
level_settings={"low": 1, "medium": 3, "significant": 4, "critical": 7}
|
305
|
+
)
|
306
|
+
incidents.append(event)
|
307
|
+
else:
|
308
|
+
self._ascending_alert_list.append(0)
|
309
|
+
incidents.append({})
|
310
|
+
|
311
|
+
return incidents
|
312
|
+
|
313
|
+
def _generate_tracking_stats(self, counting_summary: Dict, alerts: List, config: LaneDetectionConfig,
|
314
|
+
frame_number: Optional[int] = None, stream_info: Optional[Dict[str, Any]] = None) -> List[Dict]:
|
315
|
+
camera_info = self.get_camera_info_from_stream(stream_info)
|
316
|
+
tracking_stats = []
|
317
|
+
total_detections = counting_summary.get("total_count", 0)
|
318
|
+
total_counts_dict = counting_summary.get("total_counts", {})
|
319
|
+
per_category_count = counting_summary.get("per_category_count", {})
|
320
|
+
current_timestamp = self._get_current_timestamp_str(stream_info, precision=False)
|
321
|
+
start_timestamp = self._get_start_timestamp_str(stream_info, precision=False)
|
322
|
+
high_precision_start_timestamp = self._get_current_timestamp_str(stream_info, precision=True)
|
323
|
+
high_precision_reset_timestamp = self._get_start_timestamp_str(stream_info, precision=True)
|
324
|
+
|
325
|
+
total_counts = [{"category": cat, "count": count} for cat, count in total_counts_dict.items() if count > 0]
|
326
|
+
current_counts = [{"category": cat, "count": count} for cat, count in per_category_count.items() if count > 0 or total_detections > 0]
|
327
|
+
|
328
|
+
detections = []
|
329
|
+
for detection in counting_summary.get("detections", []):
|
330
|
+
bbox = detection.get("bounding_box", {})
|
331
|
+
category = detection.get("category", "lane")
|
332
|
+
if detection.get("masks"):
|
333
|
+
segmentation = detection.get("masks", [])
|
334
|
+
detection_obj = self.create_detection_object(category, bbox, segmentation=segmentation)
|
335
|
+
elif detection.get("segmentation"):
|
336
|
+
segmentation = detection.get("segmentation")
|
337
|
+
detection_obj = self.create_detection_object(category, bbox, segmentation=segmentation)
|
338
|
+
elif detection.get("mask"):
|
339
|
+
segmentation = detection.get("mask")
|
340
|
+
detection_obj = self.create_detection_object(category, bbox, segmentation=segmentation)
|
341
|
+
else:
|
342
|
+
detection_obj = self.create_detection_object(category, bbox)
|
343
|
+
detections.append(detection_obj)
|
344
|
+
|
345
|
+
alert_settings = []
|
346
|
+
if config.alert_config and hasattr(config.alert_config, 'alert_type'):
|
347
|
+
alert_settings.append({
|
348
|
+
"alert_type": getattr(config.alert_config, 'alert_type', ['Default']),
|
349
|
+
"incident_category": self.CASE_TYPE,
|
350
|
+
"threshold_level": config.alert_config.count_thresholds if hasattr(config.alert_config, 'count_thresholds') else {},
|
351
|
+
"ascending": True,
|
352
|
+
"settings": {t: v for t, v in zip(getattr(config.alert_config, 'alert_type', ['Default']),
|
353
|
+
getattr(config.alert_config, 'alert_value', ['JSON']))}
|
354
|
+
})
|
355
|
+
|
356
|
+
human_text_lines = [f"Tracking Statistics:"]
|
357
|
+
human_text_lines.append(f"CURRENT FRAME @ {current_timestamp}")
|
358
|
+
for cat, count in per_category_count.items():
|
359
|
+
human_text_lines.append(f"\t{cat}: {count}")
|
360
|
+
human_text_lines.append(f"TOTAL SINCE {start_timestamp}")
|
361
|
+
for cat, count in total_counts_dict.items():
|
362
|
+
if count > 0:
|
363
|
+
human_text_lines.append(f"\t{cat}: {count}")
|
364
|
+
human_text_lines.append(f"Alerts: {alerts[0].get('settings', {})} sent @ {current_timestamp}" if alerts else "Alerts: None")
|
365
|
+
human_text = "\n".join(human_text_lines)
|
366
|
+
|
367
|
+
reset_settings = [{"interval_type": "daily", "reset_time": {"value": 9, "time_unit": "hour"}}]
|
368
|
+
tracking_stat = self.create_tracking_stats(
|
369
|
+
total_counts=total_counts,
|
370
|
+
current_counts=current_counts,
|
371
|
+
detections=detections,
|
372
|
+
human_text=human_text,
|
373
|
+
camera_info=camera_info,
|
374
|
+
alerts=alerts,
|
375
|
+
alert_settings=alert_settings,
|
376
|
+
reset_settings=reset_settings,
|
377
|
+
start_time=high_precision_start_timestamp,
|
378
|
+
reset_time=high_precision_reset_timestamp
|
379
|
+
)
|
380
|
+
tracking_stats.append(tracking_stat)
|
381
|
+
return tracking_stats
|
382
|
+
|
383
|
+
def _generate_business_analytics(self, counting_summary: Dict, alerts: Any, config: LaneDetectionConfig,
|
384
|
+
stream_info: Optional[Dict[str, Any]] = None, is_empty=False) -> List[Dict]:
|
385
|
+
if is_empty:
|
386
|
+
return []
|
387
|
+
|
388
|
+
def _generate_summary(self, summary: dict, incidents: List, tracking_stats: List, business_analytics: List, alerts: List) -> List[str]:
|
389
|
+
lines = {}
|
390
|
+
lines["Application Name"] = self.CASE_TYPE
|
391
|
+
lines["Application Version"] = self.CASE_VERSION
|
392
|
+
if incidents:
|
393
|
+
lines["Incidents:"] = f"\n\t{incidents[0].get('human_text', 'No incidents detected')}\n"
|
394
|
+
if tracking_stats:
|
395
|
+
lines["Tracking Statistics:"] = f"\t{tracking_stats[0].get('human_text', 'No tracking statistics detected')}\n"
|
396
|
+
if business_analytics:
|
397
|
+
lines["Business Analytics:"] = f"\t{business_analytics[0].get('human_text', 'No business analytics detected')}\n"
|
398
|
+
if not incidents and not tracking_stats and not business_analytics:
|
399
|
+
lines["Summary"] = "No Summary Data"
|
400
|
+
return [lines]
|
401
|
+
|
402
|
+
def _get_track_ids_info(self, detections: list) -> Dict[str, Any]:
|
403
|
+
frame_track_ids = {det.get('track_id') for det in detections if det.get('track_id') is not None}
|
404
|
+
total_track_ids = set()
|
405
|
+
for s in getattr(self, '_per_category_total_track_ids', {}).values():
|
406
|
+
total_track_ids.update(s)
|
407
|
+
return {
|
408
|
+
"total_count": len(total_track_ids),
|
409
|
+
"current_frame_count": len(frame_track_ids),
|
410
|
+
"total_unique_track_ids": len(total_track_ids),
|
411
|
+
"current_frame_track_ids": list(frame_track_ids),
|
412
|
+
"last_update_time": time.time(),
|
413
|
+
"total_frames_processed": getattr(self, '_total_frame_counter', 0)
|
414
|
+
}
|
415
|
+
|
416
|
+
def _update_tracking_state(self, detections: list):
|
417
|
+
if not hasattr(self, "_per_category_total_track_ids"):
|
418
|
+
self._per_category_total_track_ids = {cat: set() for cat in self.target_categories}
|
419
|
+
self._current_frame_track_ids = {cat: set() for cat in self.target_categories}
|
420
|
+
|
421
|
+
for det in detections:
|
422
|
+
cat = det.get("category")
|
423
|
+
raw_track_id = det.get("track_id")
|
424
|
+
if cat not in self.target_categories or raw_track_id is None:
|
425
|
+
continue
|
426
|
+
bbox = det.get("bounding_box", det.get("bbox"))
|
427
|
+
canonical_id = self._merge_or_register_track(raw_track_id, bbox)
|
428
|
+
det["track_id"] = canonical_id
|
429
|
+
self._per_category_total_track_ids.setdefault(cat, set()).add(canonical_id)
|
430
|
+
self._current_frame_track_ids[cat].add(canonical_id)
|
431
|
+
|
432
|
+
def get_total_counts(self):
|
433
|
+
return {cat: len(ids) for cat, ids in getattr(self, '_per_category_total_track_ids', {}).items()}
|
434
|
+
|
435
|
+
def _format_timestamp_for_stream(self, timestamp: float) -> str:
|
436
|
+
dt = datetime.fromtimestamp(timestamp, tz=timezone.utc)
|
437
|
+
return dt.strftime('%Y:%m:%d %H:%M:%S')
|
438
|
+
|
439
|
+
def _format_timestamp_for_video(self, timestamp: float) -> str:
|
440
|
+
hours = int(timestamp // 3600)
|
441
|
+
minutes = int((timestamp % 3600) // 60)
|
442
|
+
seconds = round(float(timestamp % 60), 2)
|
443
|
+
return f"{hours:02d}:{minutes:02d}:{seconds:.1f}"
|
444
|
+
|
445
|
+
def _get_current_timestamp_str(self, stream_info: Optional[Dict[str, Any]], precision=False, frame_id: Optional[str] = None) -> str:
|
446
|
+
if not stream_info:
|
447
|
+
return "00:00:00.00" if precision else "00:00:00"
|
448
|
+
if precision:
|
449
|
+
if stream_info.get("input_settings", {}).get("start_frame", "na") != "na":
|
450
|
+
start_time = (int(frame_id) if frame_id else stream_info.get("input_settings", {}).get("start_frame", 30)) / stream_info.get("input_settings", {}).get("original_fps", 30)
|
451
|
+
return self._format_timestamp_for_video(start_time)
|
452
|
+
return datetime.now(timezone.utc).strftime("%Y-%m-%d-%H:%M:%S.%f UTC")
|
453
|
+
if stream_info.get("input_settings", {}).get("start_frame", "na") != "na":
|
454
|
+
start_time = (int(frame_id) if frame_id else stream_info.get("input_settings", {}).get("start_frame", 30)) / stream_info.get("input_settings", {}).get("original_fps", 30)
|
455
|
+
return self._format_timestamp_for_video(start_time)
|
456
|
+
stream_time_str = stream_info.get("input_settings", {}).get("stream_info", {}).get("stream_time", "")
|
457
|
+
if stream_time_str:
|
458
|
+
try:
|
459
|
+
timestamp_str = stream_time_str.replace(" UTC", "")
|
460
|
+
dt = datetime.strptime(timestamp_str, "%Y-%m-%d-%H:%M:%S.%f")
|
461
|
+
timestamp = dt.replace(tzinfo=timezone.utc).timestamp()
|
462
|
+
return self._format_timestamp_for_stream(timestamp)
|
463
|
+
except:
|
464
|
+
return self._format_timestamp_for_stream(time.time())
|
465
|
+
return self._format_timestamp_for_stream(time.time())
|
466
|
+
|
467
|
+
def _get_start_timestamp_str(self, stream_info: Optional[Dict[str, Any]], precision=False) -> str:
|
468
|
+
if not stream_info:
|
469
|
+
return "00:00:00" if not precision else "00:00:00.00"
|
470
|
+
if precision:
|
471
|
+
if stream_info.get("input_settings", {}).get("start_frame", "na") != "na":
|
472
|
+
return "00:00:00.00"
|
473
|
+
return datetime.now(timezone.utc).strftime("%Y-%m-%d-%H:%M:%S.%f UTC")
|
474
|
+
if stream_info.get("input_settings", {}).get("start_frame", "na") != "na":
|
475
|
+
return "00:00:00"
|
476
|
+
if self._tracking_start_time is None:
|
477
|
+
stream_time_str = stream_info.get("input_settings", {}).get("stream_info", {}).get("stream_time", "")
|
478
|
+
if stream_time_str:
|
479
|
+
try:
|
480
|
+
timestamp_str = stream_time_str.replace(" UTC", "")
|
481
|
+
dt = datetime.strptime(timestamp_str, "%Y-%m-%d-%H:%M:%S.%f")
|
482
|
+
self._tracking_start_time = dt.replace(tzinfo=timezone.utc).timestamp()
|
483
|
+
except:
|
484
|
+
self._tracking_start_time = time.time()
|
485
|
+
else:
|
486
|
+
self._tracking_start_time = time.time()
|
487
|
+
dt = datetime.fromtimestamp(self._tracking_start_time, tz=timezone.utc)
|
488
|
+
dt = dt.replace(minute=0, second=0, microsecond=0)
|
489
|
+
return dt.strftime('%Y:%m:%d %H:%M:%S')
|
490
|
+
|
491
|
+
def _count_categories(self, detections: list, config: LaneDetectionConfig) -> dict:
|
492
|
+
counts = {}
|
493
|
+
for det in detections:
|
494
|
+
cat = det.get('category', 'unknown')
|
495
|
+
counts[cat] = counts.get(cat, 0) + 1
|
496
|
+
return {
|
497
|
+
"total_count": sum(counts.values()),
|
498
|
+
"per_category_count": counts,
|
499
|
+
"detections": [
|
500
|
+
{
|
501
|
+
"bounding_box": det.get("bounding_box"),
|
502
|
+
"category": det.get("category"),
|
503
|
+
"confidence": det.get("confidence"),
|
504
|
+
"track_id": det.get("track_id"),
|
505
|
+
"frame_id": det.get("frame_id")
|
506
|
+
}
|
507
|
+
for det in detections
|
508
|
+
]
|
509
|
+
}
|
510
|
+
|
511
|
+
def _extract_predictions(self, detections: list) -> List[Dict[str, Any]]:
|
512
|
+
return [
|
513
|
+
{
|
514
|
+
"category": det.get("category", "unknown"),
|
515
|
+
"confidence": det.get("confidence", 0.0),
|
516
|
+
"bounding_box": det.get("bounding_box", {})
|
517
|
+
}
|
518
|
+
for det in detections
|
519
|
+
]
|
520
|
+
|
521
|
+
def _compute_iou(self, box1: Any, box2: Any) -> float:
|
522
|
+
def _bbox_to_list(bbox):
|
523
|
+
if bbox is None:
|
524
|
+
return []
|
525
|
+
if isinstance(bbox, list):
|
526
|
+
return bbox[:4] if len(bbox) >= 4 else []
|
527
|
+
if isinstance(bbox, dict):
|
528
|
+
if "xmin" in bbox:
|
529
|
+
return [bbox["xmin"], bbox["ymin"], bbox["xmax"], bbox["ymax"]]
|
530
|
+
if "x1" in bbox:
|
531
|
+
return [bbox["x1"], bbox["y1"], bbox["x2"], bbox["y2"]]
|
532
|
+
values = [v for v in bbox.values() if isinstance(v, (int, float))]
|
533
|
+
return values[:4] if len(values) >= 4 else []
|
534
|
+
return []
|
535
|
+
|
536
|
+
l1 = _bbox_to_list(box1)
|
537
|
+
l2 = _bbox_to_list(box2)
|
538
|
+
if len(l1) < 4 or len(l2) < 4:
|
539
|
+
return 0.0
|
540
|
+
x1_min, y1_min, x1_max, y1_max = l1
|
541
|
+
x2_min, y2_min, x2_max, y2_max = l2
|
542
|
+
x1_min, x1_max = min(x1_min, x1_max), max(x1_min, x1_max)
|
543
|
+
y1_min, y1_max = min(y1_min, y1_max), max(y1_min, y1_max)
|
544
|
+
x2_min, x2_max = min(x2_min, x2_max), max(x2_min, x2_max)
|
545
|
+
y2_min, y2_max = min(y2_min, y2_max), max(y2_min, y2_max)
|
546
|
+
inter_x_min = max(x1_min, x2_min)
|
547
|
+
inter_y_min = max(y1_min, y2_min)
|
548
|
+
inter_x_max = min(x1_max, x2_max)
|
549
|
+
inter_y_max = min(y1_max, y2_max)
|
550
|
+
inter_w = max(0.0, inter_x_max - inter_x_min)
|
551
|
+
inter_h = max(0.0, inter_y_max - inter_y_min)
|
552
|
+
inter_area = inter_w * inter_h
|
553
|
+
area1 = (x1_max - x1_min) * (y1_max - y1_min)
|
554
|
+
area2 = (x2_max - x2_min) * (y2_max - y2_min)
|
555
|
+
union_area = area1 + area2 - inter_area
|
556
|
+
return (inter_area / union_area) if union_area > 0 else 0.0
|
557
|
+
|
558
|
+
def _merge_or_register_track(self, raw_id: Any, bbox: Any) -> Any:
|
559
|
+
if raw_id is None or bbox is None:
|
560
|
+
return raw_id
|
561
|
+
now = time.time()
|
562
|
+
if raw_id in self._track_aliases:
|
563
|
+
canonical_id = self._track_aliases[raw_id]
|
564
|
+
track_info = self._canonical_tracks.get(canonical_id)
|
565
|
+
if track_info is not None:
|
566
|
+
track_info["last_bbox"] = bbox
|
567
|
+
track_info["last_update"] = now
|
568
|
+
track_info["raw_ids"].add(raw_id)
|
569
|
+
return canonical_id
|
570
|
+
for canonical_id, info in self._canonical_tracks.items():
|
571
|
+
if now - info["last_update"] > self._track_merge_time_window:
|
572
|
+
continue
|
573
|
+
iou = self._compute_iou(bbox, info["last_bbox"])
|
574
|
+
if iou >= self._track_merge_iou_threshold:
|
575
|
+
self._track_aliases[raw_id] = canonical_id
|
576
|
+
info["last_bbox"] = bbox
|
577
|
+
info["last_update"] = now
|
578
|
+
info["raw_ids"].add(raw_id)
|
579
|
+
return canonical_id
|
580
|
+
canonical_id = raw_id
|
581
|
+
self._track_aliases[raw_id] = canonical_id
|
582
|
+
self._canonical_tracks[canonical_id] = {
|
583
|
+
"last_bbox": bbox,
|
584
|
+
"last_update": now,
|
585
|
+
"raw_ids": {raw_id}
|
586
|
+
}
|
587
|
+
return canonical_id
|
588
|
+
|
589
|
+
def _format_timestamp(self, timestamp: float) -> str:
|
590
|
+
return datetime.fromtimestamp(timestamp, timezone.utc).strftime('%Y-%m-%d %H:%M:%S UTC')
|
591
|
+
|
592
|
+
def _get_tracking_start_time(self) -> str:
|
593
|
+
if self._tracking_start_time is None:
|
594
|
+
return "N/A"
|
595
|
+
return self._format_timestamp(self._tracking_start_time)
|
596
|
+
|
597
|
+
def _set_tracking_start_time(self) -> None:
|
598
|
+
self._tracking_start_time = time.time()
|