A professional scientific Android application for cosmic ray detection using your phone's camera sensor. Based on the DECO (Distributed Electronic Cosmic-ray Observatory) methodology from WIPAC.
Open the project in Android Studio (File → Open → select this folder), then Sync Project with Gradle Files and run on a device (API 26+). Requires a physical device with a camera; emulators are not supported.
- Real Camera-Based Detection: Uses phone camera sensor to detect actual cosmic ray events (no simulation)
- Automatic Calibration: Measures background noise over 30 samples before detection begins
- Two-Stage Analysis:
- Stage 1: Candidate detection (bright pixel identification)
- Stage 2: Event classification (particle type identification)
- Real-time Statistics: Track total events, events per minute, and detection time
- Event Logging: Comprehensive database with geolocation data
- Particle Classification: Identifies muons, electrons, gamma rays, and alpha particles
- Configurable Sensitivity: Adjust detection thresholds
- Professional UI: Scientific interface designed for research use
- Optional Backend: Connect to a WordPress site for event submission and (optionally) blockchain anchoring and token rewards
The app implements the DECO methodology:
- Image Capture: Records camera images every 1–2 seconds
- Calibration: Measures background noise level over 30 samples (~30 seconds)
- Bright Pixel Detection: Analyzes each image for pixels exceeding noise threshold
- Candidate Detection: If enough bright pixels found, marks as candidate
- Event Classification: Performs detailed analysis to classify particle type based on spatial patterns
- Data Logging: Saves confirmed events with metadata and geolocation
The camera sensor detects:
- Cosmic-ray muons: Linear tracks through the sensor
- Electrons: Compact clusters
- Gamma rays: Larger clusters
- Alpha particles: From natural radioactive decay
- Kotlin 1.9+
- Jetpack Compose – declarative UI
- Material Design 3 – theme and components
- CameraX / Camera2 – image capture
- Room – local persistence
- MVVM – architecture; Coroutines & Flow – async
app/src/main/java/com/cosmic/detector/
├── data/
│ ├── CosmicEvent.kt, CosmicEventDao.kt, AppDatabase.kt
│ ├── CosmicEventRepository.kt
│ └── blockchain/ # WordPress API client, offline queue
├── detection/
│ ├── advanced/ # Image analysis, clustering
│ ├── camera2/ # Camera capture
│ ├── ImageAnalyzer.kt, CameraDetectionService.kt
├── ui/
│ ├── theme/, screens/, navigation/, viewmodel/
└── utils/
Optional server-side pieces (not required to run the app):
- WordPress plugin (
cosmic-randomizer-tvec-connector.php) – REST API for registration and event submission - Node signing service (
node-signing-service/) – optional token transfers and blockchain anchoring
- Clone the repo and open the project in Android Studio.
- Sync Gradle (Android Studio will download Gradle if needed).
- Connect a device or start a physical device emulator with camera support.
- Run the app (e.g. Run → Run 'app').
Requirements: Android SDK 26+ (min), 34 (target). Physical device with camera; no emulator support for detection.
- Cover the camera lens (e.g. with electrical tape) to reduce background light.
- Place the phone face up, camera down, on a flat surface.
- Grant camera and location permissions when prompted.
- Tap Start; wait for calibration (~30 seconds).
- Detection runs automatically; monitor stats and events in the app.
- Adjust sensitivity and optional WordPress URL in Settings if you use a backend.
Tips: Cosmic ray events are rare (hours of runtime may be needed). Keep the device plugged in; detection is battery-intensive.
- Android SDK 26+ (Android 8.0+)
- Physical device with camera
- Camera and location permissions
- Kotlin 1.9+, Android Studio Hedgehog or later (recommended)
This application is for scientific research and educational use.
Developed By Reza Mirfayzi