We present a flexible, easy-to-expand digital signal processing method for detecting heart rate (HR) for cardiac vibration signals of fiber Bragg grating (FBG) sensor. The FBG-based method of measuring HR is possible to use during the magnetic resonance imaging procedure, which is its unique advantage. Our goal was to design a detection method with plurality of parameters and to subject these parameters to genetic algorithm optimization technique. In effect, we arrived at a method that is well able to deal with much distorted signals with low SNR. We proved that the method we developed allows automatic adjustment to the shape of the waves of signal carrying useful information about the moments of heartbeat. Thus, we can easily adapt our technique to the analysis of signals, which contains information on HR, from sensors employing different techniques of strain detection. The proposed method has the capabilities of analyzing signals in semi-real-time (online) with beat-to-beat resolution, significantly low delay, and negligible computational power requirements. We verified our method on recordings in a group of seven subjects. Verification included over 6000 heartbeats (82 min 47 s of recordings). The root-mean-square error of our method does not exceed 6.0 bpm.