我正在尝试构建心率监测器,用户可以将手指放在相机上并打开闪光灯并显示心率。
截至目前,我正在通过手机拍摄视频,然后在笔记本电脑中使用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找到峰值。 任何帮助都会很棒。
答案 0 :(得分:0)