1 | // Copyright (C) 2009 foam |
---|
2 | // |
---|
3 | // This program is free software; you can redistribute it and/or modify |
---|
4 | // it under the terms of the GNU General Public License as published by |
---|
5 | // the Free Software Foundation; either version 2 of the License, or |
---|
6 | // (at your option) any later version. |
---|
7 | // |
---|
8 | // This program is distributed in the hope that it will be useful, |
---|
9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
11 | // GNU General Public License for more details. |
---|
12 | // |
---|
13 | // You should have received a copy of the GNU General Public License |
---|
14 | // along with this program; if not, write to the Free Software |
---|
15 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
16 | |
---|
17 | #include <iostream> |
---|
18 | #include <map> |
---|
19 | #include <yarp/os/all.h> |
---|
20 | |
---|
21 | #ifndef SCENE_STATE |
---|
22 | #define SCENE_STATE |
---|
23 | |
---|
24 | ///////////////////////////////////////////////////////////////////////////////// |
---|
25 | // This class records who is present in the scene and keeps a record |
---|
26 | // from frame to frame in order to send changes over yarp |
---|
27 | |
---|
28 | class SceneState |
---|
29 | { |
---|
30 | public: |
---|
31 | SceneState(); |
---|
32 | ~SceneState(); |
---|
33 | |
---|
34 | // User information. Not much here yet, maybe more one day |
---|
35 | class User |
---|
36 | { |
---|
37 | public: |
---|
38 | User() : m_Confidence(0) {} |
---|
39 | User(float c) : m_Confidence(c) {} |
---|
40 | ~User() {} |
---|
41 | |
---|
42 | float m_Confidence; |
---|
43 | }; |
---|
44 | |
---|
45 | // Call this each frame with each detected user |
---|
46 | void AddPresent(unsigned int id, const User &u); |
---|
47 | |
---|
48 | // Call this once per frame to process and dispatch yarp bottles |
---|
49 | void Update(); |
---|
50 | |
---|
51 | private: |
---|
52 | |
---|
53 | void SendAppeared(unsigned int ID, const User &u); |
---|
54 | void SendDisappeared(unsigned int ID); |
---|
55 | |
---|
56 | yarp::os::Network m_YarpNetwork; |
---|
57 | yarp::os::Port m_YarpPort; |
---|
58 | |
---|
59 | std::map<unsigned int, User> m_CurrentFrame; |
---|
60 | std::map<unsigned int, User> m_LastFrame; |
---|
61 | }; |
---|
62 | |
---|
63 | #endif |
---|