Click here to Skip to main content
15,888,142 members
Articles / Desktop Programming / MFC

Real-Time Object Tracker in C++

Rate me:
Please Sign up or sign in to vote.
4.93/5 (54 votes)
18 Dec 2007GPL37 min read 376.7K   26.3K   255  
This article describes an object tracking approach by estimating a time averaged background scene for tracking static and moving objects in real-time on down-scaled image data.
// VidCapDlg.h : header file
//

#pragma once
#include "afxwin.h"

#include "lib\motiondetector.h"
#include "lib\imageblobs.h"

// CVidCapDlg dialog
class CVidCapDlg : public CDialog
{
// Construction
public:
        CVidCapDlg(CWnd* pParent = NULL);	// standard constructor        

// Dialog Data
        enum { IDD = IDD_VIDCAP_DIALOG };

protected:
        virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support


// Implementation
protected:
        HICON m_hIcon;

        // Generated message map functions
        virtual BOOL OnInitDialog();
        afx_msg void OnPaint();
        afx_msg HCURSOR OnQueryDragIcon();
        DECLARE_MESSAGE_MAP()

private:
        enum CaptureState {HALT, GET_BACKGROUND, BLOB_TRACKER} m_CaptureState;
        unsigned int* m_Background;
        unsigned int m_BackgroundFramesNumber;

        float m_Zoom;
        unsigned int m_MinBlobElements;
        MotionDetector m_MotionDetector;
        ImageBlobs m_Blobs;

        unsigned int m_Width;
        unsigned int m_Height;
        unsigned int m_Channels;

        UINT_PTR m_nTimer;
        double m_FpsRate;
        unsigned int m_MsPerFrame;
        unsigned int m_TotalFrames;
        unsigned int m_FramesProcessed;
        unsigned int m_Ms;

        CStatic m_PrvStatic;
        CStatic m_CapImgStatic;
        CComboBox m_AdapterCombo;
        UINT m_TimerInterval;
        CButton m_RunButton;
        CStatic m_VideoFormat;                
        CString m_TrackingStatus;
        bool m_TakeSnapshot;
        

        CLSID pBmpEncoder;
        int GetEncoderClsid(const WCHAR* format, CLSID* pClsid);
        
        void DrawData(unsigned char *pData);        


        afx_msg LRESULT OnGraphMessage(WPARAM wParam, LPARAM lParam);
        afx_msg void OnBnClickedEnumadaptorsButton();
        afx_msg void OnBnClickedRunButton();
        afx_msg void OnTimer(UINT_PTR nIDEvent);
        afx_msg void OnClose();
        afx_msg void OnWindowPosChanged(WINDOWPOS* lpwndpos);
        afx_msg void OnBnClickedFdetectCheck();       
        afx_msg void OnStnDblclickCapimgStatic();
        afx_msg void OnBnClickedBackgroundRadio();
        afx_msg void OnBnClickedTrackobjectsRadio();

};

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 GNU General Public License (GPLv3)


Written By
Engineer
Russian Federation Russian Federation
Highly skilled Engineer with 14 years of experience in academia, R&D and commercial product development supporting full software life-cycle from idea to implementation and further support. During my academic career I was able to succeed in MIT Computers in Cardiology 2006 international challenge, as a R&D and SW engineer gain CodeProject MVP, find algorithmic solutions to quickly resolve tough customer problems to pass product requirements in tight deadlines. My key areas of expertise involve Object-Oriented
Analysis and Design OOAD, OOP, machine learning, natural language processing, face recognition, computer vision and image processing, wavelet analysis, digital signal processing in cardiology.

Comments and Discussions