+++ /dev/null
-/*M///////////////////////////////////////////////////////////////////////////////////////\r
-//\r
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
-//\r
-// By downloading, copying, installing or using the software you agree to this license.\r
-// If you do not agree to this license, do not download, install,\r
-// copy or use the software.\r
-//\r
-//\r
-// Intel License Agreement\r
-// For Open Source Computer Vision Library\r
-//\r
-// Copyright (C) 2000, Intel Corporation, all rights reserved.\r
-// Third party copyrights are property of their respective owners.\r
-//\r
-// Redistribution and use in source and binary forms, with or without modification,\r
-// are permitted provided that the following conditions are met:\r
-//\r
-// * Redistribution's of source code must retain the above copyright notice,\r
-// this list of conditions and the following disclaimer.\r
-//\r
-// * Redistribution's in binary form must reproduce the above copyright notice,\r
-// this list of conditions and the following disclaimer in the documentation\r
-// and/or other materials provided with the distribution.\r
-//\r
-// * The name of Intel Corporation may not be used to endorse or promote products\r
-// derived from this software without specific prior written permission.\r
-//\r
-// This software is provided by the copyright holders and contributors "as is" and\r
-// any express or implied warranties, including, but not limited to, the implied\r
-// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
-// In no event shall the Intel Corporation or contributors be liable for any direct,\r
-// indirect, incidental, special, exemplary, or consequential damages\r
-// (including, but not limited to, procurement of substitute goods or services;\r
-// loss of use, data, or profits; or business interruption) however caused\r
-// and on any theory of liability, whether in contract, strict liability,\r
-// or tort (including negligence or otherwise) arising in any way out of\r
-// the use of this software, even if advised of the possibility of such damage.\r
-//\r
-//M*/// GestRec.cpp : implementation file\r
-//\r
-\r
-#include "stdafx.h"\r
-#include "stereogr.h"\r
-#include "GestMan.h"\r
-\r
-#ifdef _DEBUG\r
-#define new DEBUG_NEW\r
-#undef THIS_FILE\r
-static char THIS_FILE[] = __FILE__;\r
-#endif\r
-\r
-/////////////////////////////////////////////////////////////////////////////\r
-// CGestRec dialog\r
-\r
-\r
-CGestRec::CGestRec(CWnd* pParent /*=NULL*/)\r
- : CDialog(CGestRec::IDD, pParent)\r
-{\r
- //{{AFX_DATA_INIT(CGestRec)\r
- // NOTE: the ClassWizard will add member initialization here\r
- //}}AFX_DATA_INIT\r
-}\r
-\r
-\r
-void CGestRec::DoDataExchange(CDataExchange* pDX)\r
-{\r
- CDialog::DoDataExchange(pDX);\r
- //{{AFX_DATA_MAP(CGestRec)\r
- // NOTE: the ClassWizard will add DDX and DDV calls here\r
- //}}AFX_DATA_MAP\r
-}\r
-\r
-\r
-BEGIN_MESSAGE_MAP(CGestRec, CDialog)\r
- //{{AFX_MSG_MAP(CGestRec)\r
- ON_BN_CLICKED(IDC_RTRAIN, OnRtrain)\r
- ON_BN_CLICKED(IDC_RRECO, OnRreco)\r
- ON_LBN_SELCHANGE(IDC_GESTLIST, OnSelchangeGestlist)\r
- ON_WM_CLOSE()\r
- ON_BN_CLICKED(IDC_RNOTHING, OnRnothing)\r
- ON_BN_CLICKED(IDC_BCLEARGEST, OnBcleargest)\r
- ON_BN_CLICKED(IDC_BSAVEGEST, OnBsavegest)\r
- ON_BN_CLICKED(IDC_BLOADGEST, OnBloadgest)\r
- //}}AFX_MSG_MAP\r
-END_MESSAGE_MAP()\r
-\r
-/////////////////////////////////////////////////////////////////////////////\r
-// CGestRec message handlers\r
-\r
-void CGestRec::OnRtrain() \r
-{\r
- STEREOGRAPP(app);\r
- app->m_findHand.SetTask(GR_TRAIN);\r
-}\r
-\r
-void CGestRec::OnRreco() \r
-{\r
- STEREOGRAPP(app);\r
- app->m_findHand.SetTask(GR_RECOGNIZE);\r
-}\r
-\r
-void CGestRec::OnSelchangeGestlist() \r
-{\r
- STEREOGRAPP(app);\r
- CListBox* pList = (CListBox*)GetDlgItem(IDC_GESTLIST);\r
- int sel = pList->GetCurSel();\r
- string buffer("", pList->GetTextLen(sel));\r
- pList->GetText(sel, buffer.begin());\r
- app->m_findHand.SetGestureName(buffer);\r
-}\r
-\r
-BOOL CGestRec::OnInitDialog() \r
-{\r
- CDialog::OnInitDialog();\r
- \r
- CListBox* pList = (CListBox*)GetDlgItem(IDC_GESTLIST);\r
- pList->AddString("Ok");\r
- pList->AddString("Open");\r
- pList->AddString("Three");\r
- pList->AddString("Peace");\r
- pList->AddString("Point");\r
- pList->AddString("Thumb");\r
- pList->SetCurSel(0);\r
-\r
- CButton* pTrain = (CButton*)GetDlgItem(IDC_RTRAIN);\r
- pTrain->SetCheck(1);\r
- STEREOGRAPP(app);\r
- app->m_findHand.SetTask(GR_TRAIN);\r
- string buffer("", pList->GetTextLen(0));\r
- pList->GetText(0, buffer.begin());\r
- app->m_findHand.SetGestureName(buffer);\r
-\r
- ShowWindow(SW_SHOW);\r
-\r
- return TRUE; // return TRUE unless you set the focus to a control\r
- // EXCEPTION: OCX Property Pages should return FALSE\r
-}\r
-\r
-void CGestRec::OnClose() \r
-{\r
- STEREOGRAPP(app);\r
- app->m_findHand.SetTask(GR_NOTHING);\r
- \r
- CDialog::OnClose();\r
-}\r
-\r
-void CGestRec::UpdateStatus()\r
-{\r
- STEREOGRAPP(app);\r
- int task = app->m_findHand.m_task;\r
- CStatic* pStatus = (CStatic*)GetDlgItem(IDC_GRINFO);\r
- CListBox* pList = (CListBox*)GetDlgItem(IDC_GESTLIST);\r
- int current = pList->GetCurSel();\r
- string recognized = app->m_findHand.GetRecognizedName();\r
- CString info;\r
-\r
- pList->GetText(current, info);\r
- string str = LPCTSTR(info);\r
- app->m_findHand.SetGestureName(str);\r
-\r
- switch(task)\r
- {\r
- case GR_TRAIN:\r
- if(!app->m_findHand.m_isCovMatCalculated[current])\r
- info.Format("Collected %d samples for training...", app->m_findHand.m_features[current].size());\r
- else\r
- info.Format("Collected all samples.");\r
- break;\r
-\r
- case GR_RECOGNIZE:\r
- if(recognized.empty())\r
- {\r
- info.Format("Not recognized.");\r
- }\r
- else\r
- {\r
- info.Format("Recognized as \"%s\".", recognized.c_str());\r
- }\r
- break;\r
-\r
- case GR_NOTHING:\r
- info = "Do nothing";\r
- }\r
-\r
- pStatus->SetWindowText(info);\r
- pStatus->Invalidate();\r
- pStatus->UpdateWindow();\r
- RECT rect;\r
- pStatus->GetWindowRect(&rect);\r
- ScreenToClient(&rect);\r
- InvalidateRect(&rect);\r
- UpdateWindow();\r
- ASSERT(iplGetErrStatus() >= 0);\r
-}\r
-\r
-void CGestRec::OnRnothing() \r
-{\r
- STEREOGRAPP(app)\r
- app->m_findHand.SetTask(GR_NOTHING);\r
-}\r
-\r
-void CGestRec::OnBcleargest() \r
-{\r
- CListBox* pList = (CListBox*)GetDlgItem(IDC_GESTLIST);\r
- int index = pList->GetCurSel();\r
- CString str;\r
- pList->GetText(index, str);\r
- string buffer = LPCTSTR(str);\r
- STEREOGRAPP(app)\r
- app->m_findHand.ClearGesture(buffer);\r
-}\r
-\r
-void CGestRec::OnBsavegest() \r
-{\r
- CFileDialog dlg(FALSE, 0, 0, OFN_OVERWRITEPROMPT, "Statis training set (*.pos)|*.pos");\r
- if(dlg.DoModal() == IDOK)\r
- {\r
- STEREOGRAPP(app)\r
- app->m_findHand.SaveGestures(dlg.GetPathName());\r
- }\r
-}\r
-\r
-void CGestRec::OnBloadgest() \r
-{\r
- CFileDialog dlg(TRUE, 0, 0, 0, "Statis training set (*.pos)|*.pos");\r
- if(dlg.DoModal() == IDOK)\r
- {\r
- STEREOGRAPP(app)\r
- app->m_findHand.LoadGestures(dlg.GetPathName());\r
- }\r
-}\r