2015-12-29 55 views
3

我正試圖建立心率監測器,用戶可以用手指將他的手指放在相機上,並向他顯示心率。使用OpenCV的心率監測器

截至目前,我從手機中捕獲視頻,然後在筆記本電腦上使用OpenCV處理視頻。

我下面的步驟是:

  • 捕獲視頻
  • 找到平均紅色平面值對每個幀
  • 濾波器的數據,使得不想要的峯值被去除
  • 計算峯值然後顯示心率

    import numpy as np 
    import cv2 
    
    #connecting with the captured video file taken from mobile 
    cap = cv2.VideoCapture('heart_rate.mp4') 
    
    #getting the number of frames 
    no_of_frames = int(cap.get(7)) 
    
    #assigning an initial zero red value for every frame 
    red_plane = np.zeros(no_of_frames) 
    
    #time_list is used for storing occurence time of each frame in the video 
    time_list=[] 
    t=0 
    
    #camera frame per second is 30 and so each frame acccurs after 1/30th second 
    difference = 1/30 
    for i in range(no_of_frames): 
    
        #reading the frame 
        ret,frame = cap.read() 
        length,width,channels = frame.shape 
    
        #calculating average red value in the frame 
        red_plane[i] = np.sum(frame[:,:,2])/(length*width) 
        time_list.append(t) 
        t = t+ difference 
    
    
    cap.release() 
    

我無法應用低通濾波器來平滑我的數據,以及如何使用OpenCV找到峯值。 任何幫助將是偉大的。

+1

也請谷歌「FFT」和「歐拉放大」 – berak

+0

你爲什麼要一個低通濾波器?它可以通過高斯濾鏡來模糊框架以消除細節和噪音。對於峯值,我會在分析完所有幀後處理這個問題 –

+0

@tales_padua我想要一個低通濾波器來平滑圖形,這樣可以消除不需要的峯值,只剩下所需的峯值。實際上,我正在計算描述單個幀的單個紅色值,因此我正在爲視頻中的每個幀找到紅色值,然後我想查找峯值 – kkk

回答

0

我以30FPS製作視頻,將每幀r通道求和並將平均和存儲到列表中。然後我按照下面的方式在matplotlib中繪製列表。

enter image description here

我們可以很容易地找到幀90約八峯幀300。換句話說,有7 periods in 200 frames(taken in 200/30 s),所以心率是7/(200/30) = 21/20 => 63/60。這就是說,我的心率是63

也許,Fourier Analysis將有所幫助。但不幸的是,我仍然不知道如何分析這條曲線在節目...

(因爲我忘了Signals & System通過AlanV.Oppenh

ORZ ......


心臟跳動手指gif。

enter image description here