This project provides a step counter using both traditional peak detection and a Convolutional Neural Network (CNN) to improve accuracy. It processes accelerometer data from both hands, aligns it with video-based automated step counting, and learns to predict steps precisely.
- MediaPipe-based step detection extracts step frames directly from video using pose tracking.
- Video and accelerometer data are aligned using clap detection (detected in audio waveform).
- The number of frames from the video is matched to accelerometer sampling frequency, ensuring precise step alignment.
- Traditional ENMO-based peak detection for quick step estimation.
- A CNN trained on ENMO features detects steps more reliably than peak detection.
- Acceleration data, step peaks, and CNN predictions are plotted dynamically.
Before training the CNN, data is preprocessed automatically and checked manuelly:
- Each video is analyzed using MediaPipe to detect ankle and foot index motion.
- Steps are extracted, stored in step_counts.csv, then scaled to match the accelerometer sampling rate (scaled_step_counts.csv).
- The start and end points of accelerometer data are synchronized with the video using clap detection (clap_detection_methods.py).
- Acceleration data is sliced to match the segment of the video using save_acc_metadata_sliced.py.
- ENMO (Euclidean Norm Minus One) is computed from X, Y, Z acceleration.
- Values are normalized for stable training.

- A simple peak detection is applied
peak_picker.pyfor quick validation before CNN training.
The first step in detecting walking patterns is using a simple peak-picking algorithm. This method detects peaks in the ENMO signal, identifying potential step events.
A 1D CNN is trained on ENMO data to detect steps more accurately.
- Conv1D Layers extract temporal step features.
- Pooling Layers reduce noise.
- Fully Connected Layers output a probability for each frame.
- β The CNN learns step patterns and improves detections by reducing false positives and misalignments.
- The model is tested on unseen data.
- Steps detected by the CNN (π΄ red dots) are compared to ground truth steps (crosses).

To ensure all dependencies are installed, choose one of the two methods:
Option 1: Install with requirements.txt
pip install -r requirements.txt**Option 2: Install viaenvironment.yml(for Conda users)conda env create -f environment.ymlconda activate stepcounter
python save_acc_metadata_sliced.py
-> Extracts step frames from video & syncs with accelerometer data.
python peak_picker.py
-> Detects steps using a simple peak detection algorithm.
python training.py
-> Trains the CNN on synchronized ENMO features.
- β Refine CNN training to better align detected steps exactly on peaks.
- π Optimize CNN loss function for better step probability calibration.
- π Experiment with larger datasets (different walking speeds).
- π Improve peak detection pre-filtering before CNN classification.
