1 /*M///////////////////////////////////////////////////////////////////////////////////////
\r
3 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
\r
5 // By downloading, copying, installing or using the software you agree to this license.
\r
6 // If you do not agree to this license, do not download, install,
\r
7 // copy or use the software.
\r
10 // Intel License Agreement
\r
11 // For Open Source Computer Vision Library
\r
13 // Copyright (C) 2000, Intel Corporation, all rights reserved.
\r
14 // Third party copyrights are property of their respective owners.
\r
16 // Redistribution and use in source and binary forms, with or without modification,
\r
17 // are permitted provided that the following conditions are met:
\r
19 // * Redistribution's of source code must retain the above copyright notice,
\r
20 // this list of conditions and the following disclaimer.
\r
22 // * Redistribution's in binary form must reproduce the above copyright notice,
\r
23 // this list of conditions and the following disclaimer in the documentation
\r
24 // and/or other materials provided with the distribution.
\r
26 // * The name of Intel Corporation may not be used to endorse or promote products
\r
27 // derived from this software without specific prior written permission.
\r
29 // This software is provided by the copyright holders and contributors "as is" and
\r
30 // any express or implied warranties, including, but not limited to, the implied
\r
31 // warranties of merchantability and fitness for a particular purpose are disclaimed.
\r
32 // In no event shall the Intel Corporation or contributors be liable for any direct,
\r
33 // indirect, incidental, special, exemplary, or consequential damages
\r
34 // (including, but not limited to, procurement of substitute goods or services;
\r
35 // loss of use, data, or profits; or business interruption) however caused
\r
36 // and on any theory of liability, whether in contract, strict liability,
\r
37 // or tort (including negligence or otherwise) arising in any way out of
\r
38 // the use of this software, even if advised of the possibility of such damage.
\r
40 //M*/#if !defined(_GESTURE_RECOGNIZER_H_)
\r
41 #define _GESTURE_RECOGNIZER_H_
\r
45 #endif // _MSC_VER > 1000
\r
47 #pragma warning(disable:4786)
\r
50 #if defined(GESTREC_EXPORTS)
\r
51 #define DLL_EXPORT __declspec(dllexport)
\r
56 // FindHandCtl.h : Declaration of the CFindHandCtrl ActiveX Control class.
\r
58 /////////////////////////////////////////////////////////////////////////////
\r
59 // CFindHandCtrl : See FindHandCtl.cpp for implementation.
\r
61 #define GR_NOTHING 0
\r
63 #define GR_RECOGNIZE 2
\r
64 #define GR_RESEACH 1
\r
66 //#define GR_CONTOUR
\r
67 //#define GR_IMPROVING // improving of the initial hand mask by the using previous result hand mask
\r
72 using namespace std;
\r
74 typedef vector<CvHuMoments> feature_vector;
\r
75 typedef vector<float> fvector;
\r
76 typedef struct _gr_pose : public fvector
\r
82 class DLL_EXPORT CFindHandCtrl
\r
90 // ClassWizard generated virtual function overrides
\r
91 //{{AFX_VIRTUAL(CFindHandCtrl)
\r
93 /* virtual void OnDraw(CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid);*/
\r
99 /* Some user stuff*/
\r
100 vector<feature_vector> m_features;
\r
101 feature_vector m_avgs;
\r
102 vector<string> m_gestureNames;
\r
103 vector<fvector> m_covMatrices;
\r
104 vector<bool> m_isCovMatCalculated;
\r
105 long m_gestureCode;
\r
107 vector<IplImage*> m_dgMasks;
\r
108 vector<gr_pose> m_geomParams;
\r
110 long m_minPointCount;
\r
111 CvPoint3D32f* m_pointCloudBuffer;
\r
115 string m_errString;
\r
119 BOOL m_dynamicGesture;
\r
120 string m_dGestureName;
\r
121 string GetGestureName();
\r
122 void SetGestureName(std::string name);
\r
123 BOOL m_dynGestureFixed;
\r
124 BOOL m_saveDynGest;
\r
126 long GetGestureCode();
\r
127 void SetGestureCode(long nNewValue);
\r
128 long GetRecognizedCode();
\r
129 void SetRecognizedCode(long nNewValue);
\r
131 BOOL FindHand(_int64 _time, BOOL ForCenterOnly);
\r
132 BOOL LoadGestures(LPCTSTR FileName);
\r
133 BOOL SaveGestures(LPCTSTR FileName);
\r
134 void UpdateDynGest();
\r
137 CvMemStorage* m_storage;
\r
138 void StoreDynGesture(IplImage* mask_rez, __int64 _time);
\r
139 string GetRecognizedName();
\r
140 string m_recognizedGesture;
\r
142 int m_trainFrameCount;
\r
144 void ClearGesture(string name);
\r
145 BOOL IsGestureFixed() {return m_dynGestureFixed; }
\r
146 void ReleaseFixedGesture() { m_dynGestureFixed = FALSE; ClearDynGest(); }
\r
148 void SetTask(long task);
\r
149 BOOL m_staticGesture;
\r
151 IplImage* m_disparityImage;
\r
152 IplImage* m_outputImage;
\r
153 IplImage* m_inputImage;
\r
155 void SetPointBuffer(CvPoint3D32f* buffer);
\r
156 //int m_dgFrameCount;
\r
157 BOOL m_dgFrameFound;
\r
158 BOOL _FindHand(_int64 _time, BOOL ForCenterOnly);
\r
159 BOOL _RectifyInputMask(BOOL ForCenterOnly);
\r
160 void CalculateCovarianceMatrix();
\r
162 int m_maskImprovigFlag; // flag for the initial mask improving (0 for default)
\r
163 int m_convexDefCount; // counter of the convexity defects
\r
164 vector<float> m_DefectsDepth;
\r
168 void ClearDynGest();
\r
169 int m_dgFrameThreshold;
\r
171 BOOL InitModulePath();
\r
173 void SaveDynGestures();
\r
176 IplImage* m_maskPre; // pointer to the previous initial hand mask
\r
177 IplImage* m_resPre; // pointer to the previous result hand mask
\r
179 int m_gestureIndex;
\r
180 string Recognize(IplImage* image);
\r
182 string LogClassification(); // logical classification of the static gestures
\r
184 long m_recognizedCode;
\r
185 CvHuMoments CalculateHuMoments(IplImage* image);
\r
188 //{{AFX_INSERT_LOCATION}}
\r
189 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
\r
191 #endif // !defined(_GESTURE_RECOGNIZER_H_)
\r