Click here to Skip to main content
15,896,201 members
Articles / Desktop Programming / MFC

TrackEye : Real-Time Tracking Of Human Eyes Using a Webcam

Rate me:
Please Sign up or sign in to vote.
4.95/5 (117 votes)
12 Jun 2008CPOL6 min read 1.2M   78K   367  
Real-Time Tracking of Human Eyes in video sequences for Human-Computer Interaction using a webcam
// TrackEyeDlg.h : header file
//

#if !defined(AFX_TRACKEYEDLG_H__2BC33066_A217_11D9_938B_C61810E7E065__INCLUDED_)
#define AFX_TRACKEYEDLG_H__2BC33066_A217_11D9_938B_C61810E7E065__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "TrackingParameters.h"
#include "TrackingSettings.h"	// Added by ClassView
#include "IconButton.h"
#include "FilenameDlg.h"
//
#ifdef _CH_
#define WIN32
#error "The file needs cvaux, which is not wrapped yet. Sorry"
#endif

#ifndef _EiC
#include "cvaux.h"

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <math.h>
#include <float.h>
#include <limits.h>
#include <time.h>
#include <ctype.h>
#endif

#ifdef _EiC
#define WIN32
#endif

#define ORIG_WIN_SIZE  24

#include <time.h>
//

/////////////////////////////////////////////////////////////////////////////
// CTrackEyeDlg dialog

class CTrackEyeDlg : public CDialog
{
// Construction
public:
	bool ChooseDirectory(char*);
	CString recordFileName;
	bool record;
	
	float FPSTimer;
	float FPS;
	CToolTipCtrl tips;
	IplImage* headTrajectory;
	IplImage* resizedheadTrajectory;
	CvBox2D trajectoryBuffer[3];
	
	void initializeGUI(void);
	void drawHeadTrajectory(IplImage*, CvBox2D*);
	void DisplayEyeStatus(TrackingSettings*);
	void displayBlinkStatus();
	
	// Haar Face Detection
	CvMemStorage* storage;
	CvHidHaarClassifierCascade* hid_cascade;
	void HaarFaceDetect(IplImage*, CvBox2D*);
	int NumOfHaarFaces;
			
	IplImage* hueFrame;
	IplImage* backProject;
	int trackControl;
	IplImage* CameraFrame;
	CvCapture* Camera;
	TrackingSettings* TrackSettings;
	CTrackEyeDlg(CWnd* pParent = NULL);	// standard constructor

	int delay;

	clock_t start;
	clock_t finish;


// Dialog Data
	//{{AFX_DATA(CTrackEyeDlg)
	enum { IDD = IDD_TRACKEYE_DIALOG };
	CIconButton	m_write2AVI;
	CIconButton	m_StopRecord;
	CIconButton	m_Record;
	CEdit	m_blinkStatus;
	CIconButton	m_UpdateEyeDatabase;
	CIconButton	m_ExtractTrajectory;
	CIconButton	m_StopTracking;
	CIconButton	m_StartTracking;
	CIconButton	m_TrackerSettings;
	CIconButton	m_ExitProgram;
	CProgressCtrl	m_progress;
	CSliderCtrl	m_sliderYplane;
	CSliderCtrl	m_sliderXplane;
	CButton	m_headTrajectory;
	CSliderCtrl	m_sliderRight;
	CSliderCtrl	m_sliderLeft;
	CString	m_leyedist;
	CString	m_reyedist;
	CString	m_hWnd;
	int		m_LPR;
	int		m_LPX;
	int		m_LPY;
	int		m_RPR;
	int		m_RPX;
	int		m_RPY;
	int		m_LEX;
	int		m_LEY;
	int		m_REX;
	int		m_REY;
	int		m_counter;
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CTrackEyeDlg)
	public:
	virtual BOOL PreTranslateMessage(MSG* pMsg);
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	HICON m_hIcon;

	// Generated message map functions
	//{{AFX_MSG(CTrackEyeDlg)
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	afx_msg void OnHelpAbouttrackeye();
	afx_msg void OnTrackeyemenuPcasettings();
	afx_msg void OnTrackeyemenuFacetrackersettings();
	afx_msg void OnTrackeyemenuAdjustcapturedevicesettings();
	afx_msg void OnStartTracking();
	afx_msg void OnTrackeyemenuExit();
	afx_msg void OnStopTracking();
	afx_msg void OnExitprogram();
	afx_msg void OnEyeTrackerSettings();
	afx_msg void OnClearHT();
	afx_msg void OnExtractTrajectory();
	afx_msg void OnUpdateEyeDatabase();
	afx_msg void OnDatabaseExploredatabase();
	afx_msg void OnTrackeyemenuStarttracking();
	afx_msg void OnTrackeyemenuStoptracking();
	afx_msg void OnTrackeyemenuSelectprogramcolors();
	afx_msg void OnHelpShowtrackeyehelpfile();
	afx_msg void OnTimer(UINT nIDEvent);
	afx_msg void OnDatabaseCleardatabase();
	afx_msg void OnRecord();
	afx_msg void OnStoprecord();
	afx_msg void OnWrite2avi();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_TRACKEYEDLG_H__2BC33066_A217_11D9_938B_C61810E7E065__INCLUDED_)

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Engineer ASELSAN A.S.
Turkey Turkey
Zafer is an electronics engineer living in Ankara/Turkey and working for ASELSAN A.S./TMM.
He has been coding for about 12 years, and can't think a life without C/C++.

He likes
- MS Visual C++ 6.0 and MFC
- .NET C#
- All kinds of electronics stuff
- Machine Vision projects

Also he enjoys
- Listening to "The Cranberries" & "The Glorious Dolores"
- Travelling

E-mail : zafersavas@yahoo.com

Comments and Discussions