gpt4 book ai didi

python - 使用 OpenCV 的心率监测器

转载 作者:太空宇宙 更新时间:2023-11-03 21:13:56 25 4
gpt4 key购买 nike

我正在尝试构建心率监测器,用户可以将手指放在闪光灯打开的相机上,心率就会显示给他。

截至目前,我正在从手机中捕获视频,然后在笔记本电脑中使用 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 找到峰值。任何帮助都会很棒。

最佳答案

我以 30FPS 制作视频,对每一帧 r channel 求和并将平均和存储到列表中。然后我在 matplotlib 中绘制列表如下。

enter image description here

我们可以很容易地找到从帧 90 到帧 300 的大约八个峰值。换句话说,200 帧中有 7 个周期(在 200/30 秒内拍摄),因此心率是 7/(200/30) = 21/20 => 63/60。也就是说,我的心率是 63

或许,傅立叶分析 会有所帮助。但是,不幸的是,我仍然不知道如何在程序中分析这条曲线......

(因为我忘记了 AlanV.OppenhSignals & System )

我...


心跳手指 gif。

enter image description here

关于python - 使用 OpenCV 的心率监测器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34516323/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com