Skip to main content
. 2023 Jan 22;11(3):330. doi: 10.3390/healthcare11030330
Algorithm 1: Contactless Heartbeat rate prediction
Input: a video stream
Output: instant average heartbeat rate (bpm) prediction.
  1. Read a video stream from a camera or a file.

  2. Determine the number of frames from the video file, a.

  3. Covert frames to RGB images.

  4. Detect faces using the Viola–Jones method and put rectangular boxes around the detecting faces.

  5. Image segmentation: rescale images, remove noise, enhance the quality, and convert to grayscale.

  6. Create zeros matrices for two variables, b and c, where b refers to the images captured from the frames and c represents the equivalent images after converting into grayscale.

  7. For (i = 1: a)

  8.    Extract the required features and save their results in d(i)

  9. End

  10. Find the maximum value of all computed features of the matrix, d.

  11. For the feature with the maximum value, determine its mean for the two highest numbers and save it in M.

  12. Initialize several parameters, tp, counter, and hp, to predict the heartbeat where tp refers to the last time, counter with initial value = 0. Hp denotes the initial heart rate of 60 bpm.

  13. For (i = 1: a)

  14.    Read the current time (t) from the source file.

  15.    Predict the heartbeat rate and save the result in hn. Initially, hn = hp.

  16.    hn = [ (hn * (counter+1))/((t- tp) * 60) ] / [ counter +1]

  17.    Ceil the result in hn.

  18.    Increment the counter.

  19.    Set the last time, tp, to be the current time, t.

  20. End

  21. Calculate accuracy, MAE, and MSE.

  22. End of the algorithm.