Early Detection of Active Shooters: Leveraging Open Source Computer Vision and AWS for Weapon Detection
SoftStackers presents a design pattern combining META's SAM2 model with AWS services and affordable hardware to monitor video systems and flag weapons, aiming to identify threats early.
An Open-Source Security Solution: Free and Accessible for Everyone
The vision is deploying technology that could lock down a school while a shooter is still in the parking lot through computer vision detection. META's open-source SAM2 Model enables identification of objects in video and images via text prompting.
SoftStackers presents a design pattern combining SAM2 with AWS services and affordable hardware like Raspberry Pi to monitor video systems and flag weapons including rifles, handguns, and knives, aiming to identify threats early and reduce emergency response times.
What Does the Platform Do and How Does it Work?
Unlike expensive commercial alternatives, this solution leverages SAM2 for open source, high accuracy detection requiring minimal development and cost. When weapons are detected, notifications go to police, school administrators, or citizens for human verification before response.
The system processes real-time feeds from CCTV systems, cell phones, body cams, and, in the future, VR headsets using text-prompted object identification.
The Power of Open Source
META's open-source approach encourages innovation and collaboration by making technology freely available to developers, researchers, and tech enthusiasts. This democratization aims to inspire customized solutions for specific security contexts.
A Call to Action
This is inspiration rather than a complete solution, calling developers and innovators to leverage cutting-edge technology to address critical issues like school shootings and public safety threats.
Implementing an Opensource Weapon Detection Platform
AWS Infrastructure Design
The architecture includes:
- S3 Bucket: Stores video frames for processing
- Kinesis Video Streams: Captures and processes video in real-time
- IAM Roles: Manage permissions for SageMaker and Lambda
- SageMaker: Deploys SAM2 for real-time inference
- SNS Topic: Sends alerts when weapons detected
- Lambda Function: Processes frames and invokes the model
Terraform Configuration
The implementation provides complete infrastructure-as-code for deploying S3 buckets, Kinesis streams, SageMaker models and endpoints, IAM roles with appropriate policies, and Lambda functions with SNS integration.
Lambda Function Implementation
A Python Lambda function processes S3-stored video frames by:
- Retrieving images from S3
- Preprocessing with OpenCV
- Invoking the SageMaker endpoint
- Detecting weapons in results
- Publishing alerts to SNS for identified threats
Edge Device Design
Hardware Requirements
Recommended platforms include:
- Raspberry Pi 4: Popular for edge processing with AWS IoT Greengrass
- NVIDIA Jetson Nano: Better performance for intensive ML tasks
- Other Options: Intel NUC or BeagleBone Black
AWS IoT Greengrass Installation
Setup process includes:
- Installing appropriate OS on edge device
- Installing and configuring AWS CLI
- Creating IoT Core resources (things, certificates, policies)
- Downloading Greengrass Core software
- Configuring the Greengrass group
Edge Processing Implementation
A Python Greengrass Lambda function runs locally on edge devices to:
- Capture video from CCTV cameras
- Preprocess frames (resizing, normalization)
- Publish processed data to IoT topics
- Maintain continuous operation
The function uses OpenCV for frame capture and the Greengrass SDK for AWS communication.
Connecting and Integrating with AWS Services
Integration involves deploying local Lambda functions through Greengrass, configuring video stream capture from cameras, and ensuring secure communication between edge devices and AWS IoT Core using pre-configured certificates and policies.
Conclusion
By leveraging META's SAM2 Model and AWS services, organizations can create weapon detection applications enhancing public safety. While the solution requires customization, we share it to inspire further development and collaboration toward community protection.