I am a Python learner and I am developing a small project related to image analysis, to understand this concept I tried to understand the various dragon codes, but this time I sucked and anyone can explain this code? Particularly FFT Part? HeartMonitor (object): def __init __ (auto, window_duration, fps = 30, min_bpm = 50, MAX_BPM = 200): "" "orbit which beats the heart in a sequence of the image Detects color samples of @param window_duration @param possible heartrates to use seconds of samples @param MAX_BPM Nominal sample rate for cut off for maximum possible heart rate @param min_bpm minimum cut off "" "Number of FPS self .min_bpm = min_bpm self .max_bpm = MAX_BPM # The maximum number of sampling buffers will be self.buf_size = integer (window_duration * fps) # buffer (tie) Mstamp, value) tuples self.buf = [] @property DEF FPS (self): "" "average buffer" "framerate / sampleRate" return boat (lane (self.buf) / (self.buf [-1] [0] - self.buf [0] [0] DEF get_fft (self): "Perform" Fast Fourier-conversion on buffer and return (magnitude, phase) tuples for each one box. " # Go 'Model' equally times even_times = numpy.linspace (self.buf [0] [0], own .bff [-1] [0], lane (self. Bff)) # interpolate d ata interlaced = Numpy.interp (even_times, * zip (* self.buf)) # display FFT fft = numpy.fft.rfft (intermittent) return zip (numpy.abs (FFT), numpy equally spaced space generated temp samples To (angle (fft))
numpy.fft.rfft is a library function that calculates FFT from actual data samples equal to The time must be the same.
The first item of buf using code> is>
self.buf [-1] that buf
< The last item of code> lane (self.buf) is the same as the items in buf
, so you end up with the same number of samples , But the timings are transferred with the axis, so that they are equally distinction (variable interpolated ). Now Interpolated can be passed to numpy.fft.rfft
Comments
Post a Comment