SafeSpace is an intuitive, interactive iOS application designed to help parents and guardians identify and mitigate potential household dangers for children in real-time. Built specifically for the Apple Swift Student Challenge, SafeSpace leverages the power of on-device Machine Learning and Augmented Reality to turn an iPhone into a smart safety scanner.
- Real-Time Hazard Detection: Simply point your camera around your home. SafeSpace's custom CoreML model instantly processes the live feed to identify hazards.
- Dynamic AR Overlays: When a dangerous item is detected, SafeSpace overlays a smooth, pulsing AR bounding box directly onto the physical object, making the danger immediately obvious.
- Smart Scanning System: Avoids jarring false positives with a built-in 1.2-second confident scanning ring before alerting the user.
- Actionable Safety Tips: Displays clear, non-alarming, and actionable safety advice on a neat "Danger Card" corresponding to the specific hazard detected.
- History Tracking: Automatically logs the last 20 detected hazards along with their timestamps and confidence levels so you can review potential blind spots in your home later.
- Privacy First, On-Device Processing: All computer vision and machine learning inferences happen locally on the device via the Vision frameworkโno camera feeds are ever sent to the cloud.
SafeSpace's model is trained to recognize three primary high-risk categories in the home:
- โ๏ธ Scissors & Knives (Sharp objects)
- ๐ Electrical Outlets & Cables (Exposed sockets and wiring)
- ๐ซง Cleaning Products (Harmful chemicals within reach)
SafeSpace is built using modern Apple frameworks and fully embraces declarative UI and spatial computing concepts:
- SwiftUI: Entirely built with SwiftUI for a reactive, state-driven, and highly animated interface (including custom bottom sheets, onboarding flows, and haptic feedback integrations).
- CoreML & CreateML: Uses a custom trained Image Classification model natively integrated to run optimally on Apple Silicon.
- ARKit & SceneKit: Uses
ARWorldTrackingConfigurationandARSCNViewwrapped in aUIViewRepresentableto project safety warnings spatially. - Vision Framework: Handles the heavy lifting of extracting and processing
CVPixelBufferframes from the ARKit camera feed efficiently on background queues. - Combine: Powers the reactive
ARViewModelpipeline to keep the view state perfectly synchronized with hardware sensors.
- Xcode 15.0 or later
- iOS 17.0 or later
- An iPhone or iPad with an A9 chip or later (Requires physical device for ARKit camera tracking; the iOS Simulator does not support live ARKit camera feeds).
- Clone the repository:
git clone https://github.com/tade-dev/FoodSenseAR.git
- Open
FoodSenseAR.xcodeprojin Xcode. - Select your physical iOS device as the run destination.
- Ensure your Apple Developer Signing Identity is selected in the Signing & Capabilities tab.
- Build and Run (
Cmd + R).
- Onboarding: First-time users are greeted with a beautiful, paginated onboarding flow explaining house scanning.
- Scanning: As you pan the camera, the
ARViewContainerpasses frames every 0.5s to theDetectionService. - Validating: If the CoreML model hits a confidence threshold of >90%, a visual HUD ring begins tracking the object.
- Alerting: If the object remains in frame for an uninterrupted 1.2 seconds, the AR engine drops a frosted-glass Danger Card providing detailed safety instructions, and logs it to History.
Created with โค๏ธ for the Apple Swift Student Challenge.