Octave: Finding the mean fundamental frequency given an audio signal
Your code appears to be looking for zero crossings of the rectified signal, which won’t work reliably if your signal has strong harmonics or overtones of the fundamental frequency within your filter’s passband.  Strong overtones of low frequencies is very common in audio data.

As a likely better alternative, look up pitch detection/estimation algorithms, such as autocorrelation, ASDF and AMDF