-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathArFrameGrabKinectV2.h
More file actions
132 lines (97 loc) · 4.16 KB
/
Copy pathArFrameGrabKinectV2.h
File metadata and controls
132 lines (97 loc) · 4.16 KB
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
123
124
125
126
127
128
129
130
131
132
/*
Adept MobileRobots Robotics Interface for Applications (ARIA)
Copyright (C) 2015 Adept Technology
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
If you wish to redistribute ARIA under different terms, contact
Adept MobileRobots for information about a commercial version of ARIA at
robots@mobilerobots.com or
Adept MobileRobots, 10 Columbia Drive, Amherst, NH 03031; +1-603-881-7960
*/
#ifndef _ArFrameGrabKinectV2_H_
#define _ArFrameGrabKinectV2_H_
#include "Aria.h"
#include "ArFrameGrabAbstract.h"
#include "libfreenect2/libfreenect2.hpp"
#include "libfreenect2/frame_listener_impl.h"
//namespace libfreenect2 {
// class Freenect2Device;
// class SyncMultiFrameListener;
// class FrameMap;
// struct Frame {
// enum Type;
// };
//}
/** Serve images taken directly from a Kinect Version 2 camera by libfreenect2.
*
* DON'T USE THIS, IT WON'T WORK AS WELL AS READING KINECT DATA SEPERATELY, AND
* PROVIDING IT TO ARVIDEO VIA ArVideoOpenCV OR ArVideoExternalData.
*
* An instance of this class can grab either
* color images, depthmap images, or the IR camera images, and provide them
* through the ArFrameGrabAbstract interface, which can be used by
* ArVideoServer to provide them to remote clients. The three image types
* are "kinectv2_rgb", "kinectv2_depth" and "kinectv2_ir". Specify the image
* type in the constructor. Static methods can be used to initialize the
* connection to the Kinect device in libfreenect2. All instances of this class
* will share a static reference to the device through libfreenect2 but have
* separate "listeners".
*/
class ArFrameGrabKinectV2 : public ArFrameGrabAbstract {
public:
// register this type with ArVideoConnector.
AREXPORT static void init();
/** Constructor
@param imageType specify either "kinectv2_depth", "kinectv2_rgb", or "kinectv2_ir".
*/
AREXPORT ArFrameGrabKinectV2(const char* imageType);
AREXPORT virtual ~ArFrameGrabKinectV2();
const char* getTypeName() { return myTypeName.c_str(); }
/// Open the framegrabber. Determine the parameters later
AREXPORT bool open();
/// Close the framegrabber
AREXPORT void close();
/// Grab a single frame
AREXPORT bool capture();
/// Generic parameter-setting routine
AREXPORT bool setParameter(const char * name, float value);
/// Get the value of a parameter
AREXPORT bool getParameter(const char * name, float & value);
/// Return the number of allowed parameters
AREXPORT unsigned int numParameters();
/// Return a character pointer to a specific parameter
AREXPORT const char * parameterName(unsigned int idx);
/// Return a pointer to the RGB data. May be NULL if there was an error capturing or decoding the image.
AREXPORT unsigned char * dataPtr();
/// A parameter help function that just prints out the information
static void help();
virtual int getWidth() { return myWidth; }
virtual int getHeight() { return myHeight; }
protected:
/// Image source identifier
std::string myTypeName;
libfreenect2::Frame::Type myFrameType;
/// Height of the image in myRgbData
int myHeight;
/// Width of the image in myRgbData
int myWidth;
static ArMutex ourDeviceMutex;
static bool openFreenect();
static bool closeFreenect();
static bool ourNumInstances;
static libfreenect2::Freenect2Device *ourFreenectDevice;
/// A local copy of the image that is formatted in an RGB byte order
unsigned char *myRgbData;
libfreenect2::SyncMultiFrameListener *myFrameListenerPtr;
libfreenect2::FrameMap *myFramesPtr;
};
#endif