Move the sources to trunk
[opencv] / cvaux / src / cvfacetemplate.h
1 /*M///////////////////////////////////////////////////////////////////////////////////////
2 //
3 //  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
4 //
5 //  By downloading, copying, installing or using the software you agree to this license.
6 //  If you do not agree to this license, do not download, install,
7 //  copy or use the software.
8 //
9 //
10 //                        Intel License Agreement
11 //                For Open Source Computer Vision Library
12 //
13 // Copyright (C) 2000, Intel Corporation, all rights reserved.
14 // Third party copyrights are property of their respective owners.
15 //
16 // Redistribution and use in source and binary forms, with or without modification,
17 // are permitted provided that the following conditions are met:
18 //
19 //   * Redistribution's of source code must retain the above copyright notice,
20 //     this list of conditions and the following disclaimer.
21 //
22 //   * Redistribution's in binary form must reproduce the above copyright notice,
23 //     this list of conditions and the following disclaimer in the documentation
24 //     and/or other materials provided with the distribution.
25 //
26 //   * The name of Intel Corporation may not be used to endorse or promote products
27 //     derived from this software without specific prior written permission.
28 //
29 // This software is provided by the copyright holders and contributors "as is" and
30 // any express or implied warranties, including, but not limited to, the implied
31 // warranties of merchantability and fitness for a particular purpose are disclaimed.
32 // In no event shall the Intel Corporation or contributors be liable for any direct,
33 // indirect, incidental, special, exemplary, or consequential damages
34 // (including, but not limited to, procurement of substitute goods or services;
35 // loss of use, data, or profits; or business interruption) however caused
36 // and on any theory of liability, whether in contract, strict liability,
37 // or tort (including negligence or otherwise) arising in any way out of
38 // the use of this software, even if advised of the possibility of such damage.
39 //
40 //M*/
41 ///////////////////////////////////////////////
42 //// Created by Khudyakov V.A. bober@gorodok.net
43 //////////////////////////////////////////////
44
45 #ifndef __CVFACETEMPLATE_H__
46 #define __CVFACETEMPLATE_H__
47
48 class FaceFeature
49 {
50 public:
51         FaceFeature(double dWeight,void * lpContour,bool bIsFeature);
52         FaceFeature();
53         virtual ~FaceFeature();
54         inline bool isFaceFeature();
55         inline void * GetContour();
56         inline double GetWeight();
57         inline void SetContour(void * lpContour); 
58         inline void SetWeight(double dWeight);
59         inline void SetFeature(bool bIsFeature);
60 private:
61         double m_dWeight;
62         void * m_lpContour;
63         bool m_bIsFaceFeature;
64 };//class FaceFeature
65
66 inline void FaceFeature::SetFeature(bool bIsFeature)
67 {
68         m_bIsFaceFeature = bIsFeature;
69 }
70
71 inline bool FaceFeature::isFaceFeature()
72 {
73         return m_bIsFaceFeature;
74 }//inline bool FaceFeature::isFaceFeature()
75
76 inline void * FaceFeature::GetContour()
77 {
78         return m_lpContour;     
79 }//inline void * FaceFeature::GetContour()
80
81 inline double FaceFeature::GetWeight()
82 {
83         return m_dWeight;
84 }//inline long FaceFeature::GetWeight()
85
86 inline void FaceFeature::SetContour(void * lpContour)
87 {
88         m_lpContour = lpContour;
89 }//inline void FaceFeature::SetContour(void * lpContour)
90
91 inline void FaceFeature::SetWeight(double  dWeight)
92 {
93         m_dWeight = dWeight;
94 }//inline void FaceFeature::SetWeight(double * dWeight)
95
96
97
98 class FaceTemplate
99 {
100 public:
101         FaceTemplate(long lFeatureCount) {m_lFeturesCount = lFeatureCount;      m_lpFeaturesList = new FaceFeature[lFeatureCount];};
102         virtual ~FaceTemplate();
103         
104         inline long GetCount();
105         inline FaceFeature * GetFeatures();
106
107 protected:
108         FaceFeature * m_lpFeaturesList; 
109 private:
110         long m_lFeturesCount;
111 };//class FaceTemplate
112
113
114 inline long FaceTemplate::GetCount()
115 {
116         return m_lFeturesCount;
117 }//inline long FaceTemplate::GetCount()
118
119
120 inline FaceFeature * FaceTemplate::GetFeatures()
121 {
122         return m_lpFeaturesList;
123 }//inline FaceFeature * FaceTemplate::GetFeatures()
124
125 ////////////
126 //class RFaceTemplate
127 ///////////
128
129 class MouthFaceTemplate:public FaceTemplate
130 {
131 public:
132         inline MouthFaceTemplate(long lNumber,CvRect rect,double dEyeWidth,double dEyeHeight,double dDistanceBetweenEye,double dDistanceEyeAboveMouth);
133         ~MouthFaceTemplate();
134 };//class MouthFaceTemplate:public FaceTemplate
135
136
137 inline MouthFaceTemplate::MouthFaceTemplate(long lNumber,CvRect rect,double dEyeWidth,double dEyeHeight,
138                                                          double dDistanceBetweenEye,double dDistanceEyeAboveMouth):FaceTemplate(lNumber)
139 {
140         
141         CvRect MouthRect = rect;
142         
143         
144         CvRect LeftEyeRect = cvRect(cvRound(rect.x - (dEyeWidth + dDistanceBetweenEye/(double)2 - (double)rect.width/(double)2)),
145                                                         cvRound(rect.y - dDistanceEyeAboveMouth - dEyeHeight),
146                                                         cvRound(dEyeWidth),
147                                                         cvRound(dEyeHeight) );
148
149         CvRect RightEyeRect = cvRect(cvRound(rect.x + (double)rect.width/(double)2 + dDistanceBetweenEye/(double)2),
150                                                              cvRound(rect.y - dDistanceEyeAboveMouth - dEyeHeight),
151                                                              cvRound(dEyeWidth),
152                                                              cvRound(dEyeHeight) );
153
154 //      CvRect NoseRect = cvRect(cvRound(rect.x + (double)rect.width/(double)4),
155 //                                                       cvRound(rect.y - (double)rect.width/(double)2 - (double)rect.height/(double)4),
156 //                                                       cvRound((double)rect.width/(double)2),
157 //                                                       cvRound((double)rect.width/(double)2) );
158 /*      
159         CvRect CheenRect = cvRect(rect.x,rect.y + 3*rect.height/2,rect.width,rect.height);
160                 
161 */      
162         
163         CvRect * lpMouthRect = new CvRect();
164         *lpMouthRect = MouthRect;
165         m_lpFeaturesList[0].SetContour(lpMouthRect);
166         m_lpFeaturesList[0].SetWeight(1);
167         m_lpFeaturesList[0].SetFeature(false);
168
169
170         CvRect * lpLeftEyeRect = new CvRect();
171         *lpLeftEyeRect = LeftEyeRect;
172         m_lpFeaturesList[1].SetContour(lpLeftEyeRect);
173         m_lpFeaturesList[1].SetWeight(1);
174         m_lpFeaturesList[1].SetFeature(true);
175
176         CvRect * lpRightEyeRect = new CvRect();
177         *lpRightEyeRect = RightEyeRect;
178         m_lpFeaturesList[2].SetContour(lpRightEyeRect);
179         m_lpFeaturesList[2].SetWeight(1);
180         m_lpFeaturesList[2].SetFeature(true);
181
182         
183 //      CvRect * lpNoseRect = new CvRect();
184 //      *lpNoseRect = NoseRect;
185 //      m_lpFeaturesList[3].SetContour(lpNoseRect);
186 //      m_lpFeaturesList[3].SetWeight(0);
187 //      m_lpFeaturesList[3].SetFeature(true);
188
189 /*      CvRect * lpCheenRect = new CvRect();
190         *lpCheenRect = CheenRect;
191         m_lpFeaturesList[4].SetContour(lpCheenRect);
192         m_lpFeaturesList[4].SetWeight(1);
193         m_lpFeaturesList[4].SetFeature(false);
194
195 */
196
197 };//constructor MouthFaceTemplate(long lNumFeatures,CvRect rect,double dEyeWidth,double dEyeHeight,double dDistanceBetweenEye,double dDistanceEyeAboveMouth);
198
199
200
201 #endif//__FACETEMPLATE_H__
202