Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: Digital filter critical frequencies must be 0 < Wn < 1 #13

Open
luistelmocosta opened this issue Jan 13, 2020 · 1 comment

Comments

@luistelmocosta
Copy link

First, thank you for this amazing project. The results look very promsing!

However, I am getting this error a lot and I really don't know what is triggering it and how to solve it.

C:\Users\luis.s.costa\AppData\Local\Continuum\anaconda3\envs\HR_measurement\lib\site-packages\numpy\core\fromnumeric.py:3257: RuntimeWarning: Mean of empty slice.
  out=out, **kwargs)
C:\Users\luis.s.costa\AppData\Local\Continuum\anaconda3\envs\HR_measurement\lib\site-packages\numpy\core\_methods.py:161: RuntimeWarning: invalid value encountered in double_scalars
  ret = ret.dtype.type(ret / rcount)
Traceback (most recent call last):
  File "GUI.py", line 273, in run
    self.main_loop()
  File "GUI.py", line 222, in main_loop
    self.process.run()
  File "C:\Users\luis.s.costa\Documents\201912.HeartRateMeasurement\Heart-rate-measurement-using-camera-master\process.py", line 106, in run
    processed = self.butter_bandpass_filter(processed,0.8,3,self.fps,order = 3)
  File "C:\Users\luis.s.costa\Documents\201912.HeartRateMeasurement\Heart-rate-measurement-using-camera-master\process.py", line 151, in butter_bandpass_filter
    b, a = self.butter_bandpass(lowcut, highcut, fs, order=order)
  File "C:\Users\luis.s.costa\Documents\201912.HeartRateMeasurement\Heart-rate-measurement-using-camera-master\process.py", line 145, in butter_bandpass
    b, a = signal.butter(order, [low, high], btype='band')
  File "C:\Users\luis.s.costa\AppData\Local\Continuum\anaconda3\envs\HR_measurement\lib\site-packages\scipy\signal\filter_design.py", line 2867, in butter
    output=output, ftype='butter', fs=fs)
  File "C:\Users\luis.s.costa\AppData\Local\Continuum\anaconda3\envs\HR_measurement\lib\site-packages\scipy\signal\filter_design.py", line 2346, in iirfilter
    raise ValueError("Digital filter critical frequencies "
ValueError: Digital filter critical frequencies must be 0 < Wn < 1

Everything worls flawlessly, I just want a workaround to avoid this error. One idea could be use the previous value in the case this error appears. 

Any idea how to fix this?
@dorukkarinca
Copy link

dorukkarinca commented May 3, 2020

This has to do with the fps being 0, which results in a division-by-zero in butter_bandpass

Correction: this has to do with the fps being not large enough. You need to raise the fps to 6 or above by one or more of:

  • retrying on a faster computer
  • retrying after closing high-CPU apps
  • retrying after cooling down your computer (e.g. moving to a cooler room)
  • reducing the input resolution
  • trying a pre-recorded video instead of a webcam feed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants