1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
//
// libavg - Media Playback Engine.
// Copyright (C) 2003-2014 Ulrich von Zadow
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Current versions can be found at www.libavg.de
//
#ifndef _TrackerInputDevice_H_
#define _TrackerInputDevice_H_
#include "../api.h"
#include "CursorEvent.h"
#include "IInputDevice.h"
#include "TrackerCalibrator.h"
#include "../imaging/TrackerThread.h"
#include "../imaging/Blob.h"
#include "../graphics/Bitmap.h"
#include "../graphics/Filter.h"
#include "../base/Rect.h"
#include <string>
#include <map>
#include <list>
#include <vector>
#include <utility>
namespace avg {
class TrackerTouchStatus;
typedef boost::shared_ptr<TrackerTouchStatus> TrackerTouchStatusPtr;
class AVG_API TrackerInputDevice: public IBlobTarget, public IInputDevice
{
typedef std::map<BlobPtr, TrackerTouchStatusPtr> TouchStatusMap;
public:
TrackerInputDevice();
virtual ~TrackerInputDevice();
void start();
void setParam(const std::string& sElement, const std::string& sValue);
std::string getParam(const std::string& sElement);
void resetHistory();
void setDebugImages(bool bImg, bool bFinger);
void saveConfig();
Bitmap * getImage(TrackerImageID imageID) const;
glm::vec2 getDisplayROIPos() const;
glm::vec2 getDisplayROISize() const;
std::vector<EventPtr> pollEvents(); //main thread
// implement IBlobTarget
// Called from Tracker Thread!
virtual void update(BlobVectorPtr pTrackBlobs, BlobVectorPtr pTouchBlobs,
long long time);
TrackerCalibrator* startCalibration();
void endCalibration();
void abortCalibration();
private:
void setConfig();
void createBitmaps(const IntRect& area);
boost::thread* m_pTrackerThread;
// Used by main thread
void pollEventType(std::vector<EventPtr>& res, TouchStatusMap& events,
CursorEvent::Source source);
void copyRelatedInfo(std::vector<EventPtr> pTouchEvents,
std::vector<EventPtr> pTrackEvents);
void findFingertips(std::vector<EventPtr>& pTouchEvents);
IntRect m_InitialROI;
CameraPtr m_pCamera;
bool m_bSubtractHistory;
DeDistortPtr m_pDeDistort;
DeDistortPtr m_pOldTransformer;
IntPoint m_ActiveDisplaySize;
FRect m_DisplayROI;
FRect m_OldDisplayROI;
TrackerCalibrator * m_pCalibrator;
bool m_bFindFingertips;
// Used by tracker thread
void trackBlobIDs(BlobVectorPtr new_blobs, long long time, bool bTouch);
// Used by both threads
TouchStatusMap m_TouchEvents;
TouchStatusMap m_TrackEvents;
TrackerConfig m_TrackerConfig;
MutexPtr m_pMutex;
BitmapPtr m_pBitmaps[NUM_TRACKER_IMAGES];
TrackerThread::CQueuePtr m_pCmdQueue;
};
typedef boost::shared_ptr<TrackerInputDevice> TrackerInputDevicePtr;
}
#endif
|