Last active
December 15, 2015 21:38
-
-
Save EyalAr/5326708 to your computer and use it in GitHub Desktop.
Code samples for my face detection and recognition with OpenCV tutorial.
http://blog.eyalarubas.com/2013/03/14/face-detection-and-recognition-theory-and-practice/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CsvWriter { | |
public: | |
CsvWriter(const string &csvPath); | |
virtual ~CsvWriter(); | |
void nextLine(); | |
void addEntry(const string &s); | |
private: | |
ofstream _fs; | |
bool _isFirstEntry; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FaceDetector { | |
public: | |
FaceDetector( | |
const string &cascadePath, | |
double scaleFactor, | |
int minNeighbors, | |
double minSizeRatio, | |
double maxSizeRatio); | |
virtual ~FaceDetector(); | |
void findFacesInImage(const Mat &img, vector<Rect> &res); | |
private: | |
CascadeClassifier _cascade; | |
double _scaleFactor; | |
int _minNeighbors; | |
double _minSizeRatio; | |
double _maxSizeRatio; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FramesReader | |
{ | |
public: | |
FramesReader(const string &vidPath, int startFrame, int endFrame, int delta); | |
virtual ~FramesReader(); | |
bool getNext(Mat &frame); | |
Size getSize(); | |
private: | |
VideoCapture _vid; | |
int _endFrame, | |
_delta; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FramesWriter | |
{ | |
public: | |
FramesWriter(const string vidPath, double fps, Size size, int fourcc); | |
virtual ~FramesWriter(); | |
void write(Mat &frame); | |
private: | |
VideoWriter _vid; | |
Size _f_size; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PersonRecognizer { | |
public: | |
PersonRecognizer(const vector<Mat> &imgs, int radius, int neighbors, | |
int grid_x, int grid_y, double threshold); | |
virtual ~PersonRecognizer(); | |
bool recognize(const Mat &face, double &confidence) const; | |
private: | |
Ptr<FaceRecognizer> _model; | |
Size _faceSize; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment