A ballistocardiograph records the mechanical activity of the heart. We present a novel algorithm for the detection of individual heart beats and beat-to-beat interval lengths in ballistocardiograms (BCGs) from healthy subjects. An automatic training step based on unsupervised learning techniques is used to extract the shape of a single heart beat from the BCG. Using the learned parameters, the occurrence of individual heart beats in the signal is detected. A final refinement step improves the accuracy of the estimated beat-to-beat interval lengths. Compared to many existing algorithms, the new approach offers heart rate estimates on a beat-to-beat basis. The agreement of the proposed algorithm with an ECG reference has been evaluated. A relative beat-to-beat interval error of 1.79% with a coverage of 95.94% was achieved on recordings from 16 subjects.