-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathface.cpp
More file actions
37 lines (31 loc) · 1.09 KB
/
face.cpp
File metadata and controls
37 lines (31 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "opencv2/objdetect.hpp"
#include "opencv2/highgui.hpp"
#include <iostream>
#include "face.h"
// Start ID at 0
int Face::numFaces = 0;
Face::Face(const cv::Rect& detection, Mask& _mask, const int& nFrame) : mask(_mask), lastPosition(detection), lastFrameSeen(nFrame) {
lastTimeSeen = (double)cv::getTickCount();
numDetections = 1;
numFaces += 1;
id = numFaces;
}
// Time pasted since last detection in milliseconds
double Face::timeUndetectedMs() const {
return ((double)cv::getTickCount() - this->lastTimeSeen)*1000 / cv::getTickFrequency();
}
// Number of frames since last detection
int Face::undetectedFrames(const int& currentFrame) const {
return currentFrame - lastFrameSeen;
}
// Update members with latest information
void Face::updateSeen(const cv::Rect & detection, const int& nFrame) {
lastPosition = detection;
lastTimeSeen = (double)cv::getTickCount();
numDetections += 1;
lastFrameSeen = nFrame;
std::cout << "Updating face " << id << ": " << numDetections << " detections" << std::endl;
}
const Mask& Face::getMask() const {
return mask;
}