Added comments
This commit is contained in:
parent
8c97a5a416
commit
aafe28c0e0
18
ppg.cpp
18
ppg.cpp
|
|
@ -26,16 +26,16 @@ int main(){
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
cv::CascadeClassifier faceDetector;
|
cv::CascadeClassifier faceDetector;
|
||||||
if(!faceDetector.load("./haarcascade_frontalface_alt.xml"))
|
if(!faceDetector.load("./haarcascade_frontalface_alt.xml"))//Testing to see if cascade_frontalface.xml is available (necessary for the program to work)
|
||||||
{
|
{
|
||||||
std::cerr<<"[ERROR] Unable to load face cascade"<<std::endl;
|
std::cerr<<"[ERROR] Unable to load face cascade"<<std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
if(isDiscardData)
|
if(isDiscardData) //This function delays the beginning of the analysis of the data
|
||||||
{
|
{
|
||||||
countDiscard++;
|
countDiscard++;
|
||||||
if (countDiscard == DISCARD_DURATION*FPS)
|
if (countDiscard == DISCARD_DURATION*FPS)
|
||||||
|
|
@ -51,22 +51,22 @@ int main(){
|
||||||
cap.read(frame);
|
cap.read(frame);
|
||||||
|
|
||||||
//Check if we succeeded
|
//Check if we succeeded
|
||||||
if (frame.empty())
|
if (frame.empty()) //If the camera records a blank frame, returns an error.
|
||||||
{
|
{
|
||||||
std::cerr<<"[ERROR] Blank frame grabbed"<<std::endl;
|
std::cerr<<"[ERROR] Blank frame grabbed"<<std::endl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
cv::imshow("Color", frame);
|
cv::imshow("Color", frame); //shows the colored frame
|
||||||
if (cv::waitKey(1000.0/FPS)>=0)
|
if (cv::waitKey(1000.0/FPS)>=0) //Stops after 1000/FPS frames
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
cv::Mat frame_gray;
|
cv::Mat frame_gray;
|
||||||
cv::cvtColor(frame, frame_gray, cv::COLOR_BGR2GRAY);
|
cv::cvtColor(frame, frame_gray, cv::COLOR_BGR2GRAY);
|
||||||
cv::imshow("Gray", frame_gray);
|
cv::imshow("Gray", frame_gray); //Shows frame in greyscale
|
||||||
std::vector<cv::Rect> faceRectangles;
|
std::vector<cv::Rect> faceRectangles;
|
||||||
faceDetector.detectMultiScale(frame_gray, faceRectangles, 1.1, 3, 0, cv::Size(20,20));
|
faceDetector.detectMultiScale(frame_gray, faceRectangles, 1.1, 3, 0, cv::Size(20,20)); //Detects face
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue