Giter VIP home page Giter VIP logo

vpglib's Introduction

VPGLIB

VPGLIB is the library for the blood pulse extraction from the video of the human face. HR measurement ranges from 55 bpm to 175 bpm and absolute error in most cases should be less than 5 bpm. Pay attention that ordinary PC is not certified as measurement tool, so measurement error could be high. Use library only at your own risk, no warranties are granted.

How to use:

#include "vpg.h"
...
cv::VideoCapture capture;

if(capture.open(0)) { // open default video capture device	
	vpg::FaceProcessor faceproc(CASCADE_FILENAME); // CASCADE_FILENAME is a path to haarcascade or lbpcascade for the face detection
	double framePeriod = faceproc.measureFramePeriod(&capture); // measure discretization period of the video in milliseconds
	vpg::PulseProcessor pulseproc(framePeriod); // object that performs harmonic analysis of vpg-signal
	cv::Mat frame;
	unsigned int k = 0; // it is counter of enrolled frames
	double s = 0.0, t = 0.0; // this is variables for temporal results storing ('s' for vpg-signal count, 't' for actual frame time)
	while(true) {
		if(capture.read(frame)) {
			faceproc.enrollImage(frame, s, t); // perform face detection, then skin detection, then average skin pixels
			pulseproc.update(s,t); // update vpg-signal
			cv::rectangle(frame,faceproc.getFaceRect(),cv::Scalar(255,255,255)); // draw target rect
			cv::imshow("Video probe", frame);
	        }
	        if(k % 64 == 0) {
		        std::printf("\nHR measurement: %d bpm\n\n", pulseproc.computeFrequency()); // compute and print heart rate estimation
		}
	        k++;
		int c = cv::waitKey(1.0); // enroll user input
		if( (char)c == '27' )  {// use need to press escape for the exit 
			break;
		}
	}
}
...

Dependencies:

  1. OpenCV

Designed by Alex A. Taranov, 2015, list of the project sources

vpglib's People

Contributors

pi-null-mezon avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.