source: eviacam/trunk/fuentes/src/visionpipeline.h @ 29

Last change on this file since 29 was 29, checked in by mabarracus, 4 years ago

added eviacam content

  • Property svn:executable set to *
File size: 3.7 KB
Line 
1/////////////////////////////////////////////////////////////////////////////
2// Name:        visionpipeline.h
3// Purpose: 
4// Author:      Cesar Mauri Loba (cesar at crea-si dot com)
5// Modified by:
6// Created:     
7// Copyright:   (C) 2008-14 Cesar Mauri Loba - CREA Software Systems
8//
9//  This program is free software: you can redistribute it and/or modify
10//  it under the terms of the GNU General Public License as published by
11//  the Free Software Foundation, either version 3 of the License, or
12//  (at your option) any later version.
13//
14//  This program is distributed in the hope that it will be useful,
15//  but WITHOUT ANY WARRANTY; without even the implied warranty of
16//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17//  GNU General Public License for more details.
18//
19//  You should have received a copy of the GNU General Public License
20//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
21/////////////////////////////////////////////////////////////////////////////
22
23#ifndef VISIONPIPELINE_H
24#define VISIONPIPELINE_H
25
26#include "crvimage.h"
27#include "crvhistogram.h"
28#include "configbase.h"
29#include "visiblenormroi.h"
30#include "waittime.h"
31
32#include <wx/thread.h>
33
34
35class CVisionPipeline : public CConfigBase, wxThread
36{
37        // Methods
38public:
39        CVisionPipeline (wxThreadKind kind = wxTHREAD_JOINABLE);
40        ~CVisionPipeline();
41
42        enum ECpuUsage {CPU_LOWEST= 0, CPU_LOW, CPU_NORMAL, CPU_HIGH, CPU_HIGHEST};
43
44        // Thread entry point
45        virtual wxThread::ExitCode Entry();
46        virtual wxThreadError Create(unsigned int stackSize = 0);
47
48        bool ProcessImage (CIplImage& image, float& xVel, float& yVel);
49
50        bool GetTrackFace () const { return m_trackFace; }
51        void SetTrackFace (bool state) { m_trackFace= state; }
52       
53        bool GetEnableWhenFaceDetected () const { return m_enableWhenFaceDetected; }
54        void SetEnableWhenFaceDetected (bool state) { m_enableWhenFaceDetected= state; }
55
56        bool GetUseLegacyTracker() const { return m_useLegacyTracker; }
57        void SetUseLegacyTracker(bool state) { m_useLegacyTracker = state; }
58
59        bool IsFaceDetected () const;
60
61        unsigned int GetTimeout () const { return (unsigned int) (m_waitTime.GetWaitTimeMs()/1000); }
62        void SetTimeout (unsigned int timeout) { m_waitTime.SetWaitTimeMs(timeout*1000); }
63       
64        void SetDegradation (int value) { m_trackArea.SetDegradation(value); }
65
66        int GetCpuUsage ();
67        void SetCpuUsage (int value);
68
69        bool IsTrackFaceAllowed () { return (m_faceCascade!= NULL); }   
70
71        CVisibleNormROI* GetTrackAreaControl () { return &m_trackArea; }
72
73        // Configuration methods
74        virtual void InitDefaults();
75        virtual void WriteProfileData(wxConfigBase* pConfObj);
76        virtual void ReadProfileData(wxConfigBase* pConfObj);
77
78private:
79        // Track area
80        CVisibleNormROI m_trackArea;
81
82        bool m_trackFace;
83        bool m_enableWhenFaceDetected;
84        bool m_isRunning;
85        bool m_useLegacyTracker;
86        CWaitTime m_waitTime;
87        CWaitTime m_trackAreaTimeout;
88               
89        CIplImage m_imgThread;
90        CIplImage m_imgPrevProc, m_imgCurrProc;
91        CIplImage m_imgPrev, m_imgCurr;
92        CIplImage m_imgVelX, m_imgVelY;
93        TCrvLookupTable m_prevLut;
94       
95        CvHaarClassifierCascade* m_faceCascade;
96        CvMemStorage* m_storage;
97        int m_threadPeriod;
98       
99        wxCriticalSection m_imageCopyMutex;
100        wxMutex m_mutex;
101        wxCondition m_condition;
102
103        // Face location detection
104        CvRect m_faceLocation;
105        int m_faceLocationStatus; // 0 -> not available, 1 -> available
106
107        // Corner array
108        enum { NUM_CORNERS = 15 };
109        CvPoint2D32f m_corners[NUM_CORNERS];
110        int m_corner_count;
111       
112        // Private methods
113        void AllocWorkingSpace (CIplImage &image);
114        int PreprocessImage ();
115        void ComputeFaceTrackArea (CIplImage &image);
116        void SetThreadPeriod (int value);
117        void OldTracker(CIplImage &image, float &xVel, float &yVel);
118        void NewTracker(CIplImage &image, float &xVel, float &yVel);
119};
120
121#endif
Note: See TracBrowser for help on using the repository browser.