source: foam/trunk/simple-faceident/src/FaceBank.h @ 76

Revision 76, 2.1 KB checked in by dave, 12 years ago (diff)

changed file format to xml, experimental multiple image/face matching, better makefile

Line 
1// Copyright (C) 2009 foam
2//
3// This program is free software; you can redistribute it and/or modify
4// it under the terms of the GNU General Public License as published by
5// the Free Software Foundation; either version 2 of the License, or
6// (at your option) any later version.
7//
8// This program is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11// GNU General Public License for more details.
12//
13// You should have received a copy of the GNU General Public License
14// along with this program; if not, write to the Free Software
15// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16
17#include <iostream>
18#include <map>
19#include <vector>
20#include <assert.h>
21#include "cv.h"
22#include "Face.h"
23
24#ifndef FACE_BANK
25#define FACE_BANK
26
27/////////////////////////////////////////////////////////////////////////////////
28// A database of detected faces
29
30class FaceBank
31{
32public:
33        // FaceWidth and FaceHeight are the size for the internal stored image of the face for
34        // comparison, ErrorThresh is the error amount which will trigger a new face to be stored
35        FaceBank(unsigned int FaceWidth, unsigned int FaceHeight, float ErrorThresh);
36        ~FaceBank();
37
38        void Clear();
39       
40        // Learn this face, the face may be a false positive, so we'll discard the
41        // suggestion if we've seen it before, and the error is greater than ErrorThresh
42        float Suggest(IplImage *face, unsigned int ID);
43
44        // Gives the id, given a face, and returns the confidence
45        float Identify(IplImage *face, unsigned int &ID, int &imagenum);
46       
47        // Collect multiple images per user
48        void AllowMultiFaceImages(bool s) { m_MultiFaceImages=s; }
49       
50        std::map<unsigned int, Face*> &GetFaceMap() { return m_FaceMap; }
51       
52        unsigned int GetFaceWidth() { return m_FaceWidth; }
53        unsigned int GetFaceHeight() { return m_FaceHeight; }
54
55        void Save(const std::string &filename) const;
56        void Load(const std::string &filename);
57
58private:       
59
60        unsigned int m_FaceWidth;
61        unsigned int m_FaceHeight;
62        float m_ErrorThresh;
63        bool m_MultiFaceImages;
64       
65        std::map<unsigned int, Face*> m_FaceMap;
66};
67
68#endif
Note: See TracBrowser for help on using the repository browser.