【发布时间】:2015-12-29 17:53:28
【问题描述】:
我正在尝试构建心率监视器,用户可以将手指放在相机上并打开闪光灯,然后向他显示心率。
到目前为止,我正在从手机中捕获视频,然后在笔记本电脑中使用 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 找到峰值。 任何帮助都会很棒。
【问题讨论】:
-
请在谷歌上搜索“fft”和“欧拉放大率”
-
为什么需要低通滤波器?最好通过高斯滤波器来模糊帧以去除细节和噪声。对于峰值,我会在分析完所有帧后处理它
-
@tales_padua 我想要一个低通滤波器来平滑图形,这样可以去除不需要的峰值,只留下所需的峰值。实际上,我正在计算一个描述单个帧的单个红色值,因此我正在为我的视频中的每一帧找到红色值,然后我想找到峰值
-
还有经典的ICA方法:osapublishing.org/…
-
为了平滑图像,我会使用高斯滤波器。您可以在这里查看如何使用它,以及其他一些有用的有用方法:docs.opencv.org/master/d4/d13/…
标签: python opencv image-processing