Skip to content

Instantly share code, notes, and snippets.

@EyalAr
Last active December 15, 2015 21:38
Show Gist options
  • Save EyalAr/5326708 to your computer and use it in GitHub Desktop.
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/
class CsvWriter {
public:
CsvWriter(const string &csvPath);
virtual ~CsvWriter();
void nextLine();
void addEntry(const string &s);
private:
ofstream _fs;
bool _isFirstEntry;
};
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;
};
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;
};
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;
};
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