Point Cloud Library (PCL)
1.15.1
Toggle main menu visibility
Loading...
Searching...
No Matches
pcl
io
depth_sense
depth_sense_device_manager.h
1
/*
2
* Software License Agreement (BSD License)
3
*
4
* Point Cloud Library (PCL) - www.pointclouds.org
5
* Copyright (c) 2014-, Open Perception, Inc.
6
*
7
* All rights reserved.
8
*
9
* Redistribution and use in source and binary forms, with or without
10
* modification, are permitted provided that the following conditions
11
* are met:
12
*
13
* * Redistributions of source code must retain the above copyright
14
* notice, this list of conditions and the following disclaimer.
15
* * Redistributions in binary form must reproduce the above
16
* copyright notice, this list of conditions and the following
17
* disclaimer in the documentation and/or other materials provided
18
* with the distribution.
19
* * Neither the name of the copyright holder(s) nor the names of its
20
* contributors may be used to endorse or promote products derived
21
* from this software without specific prior written permission.
22
*
23
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34
* POSSIBILITY OF SUCH DAMAGE.
35
*
36
*/
37
38
#pragma once
39
40
#include <boost/utility.hpp>
41
42
#include <pcl/pcl_exports.h>
43
44
#include <DepthSense.hxx>
45
46
#include <memory>
47
#include <thread>
48
49
namespace
pcl
50
{
51
52
namespace
io
53
{
54
55
namespace
depth_sense
56
{
57
58
struct
DepthSenseGrabberImpl
;
59
60
/** A helper class for enumerating and managing access to DepthSense
61
* devices. */
62
class
PCL_EXPORTS DepthSenseDeviceManager : boost::noncopyable
63
{
64
65
public
:
66
67
using
Ptr
= std::shared_ptr<DepthSenseDeviceManager>;
68
69
static
Ptr
&
70
getInstance
()
71
{
72
static
Ptr
instance;
73
if
(!instance)
74
{
75
std::lock_guard<std::mutex> lock (mutex_);
76
if
(!instance)
77
instance.reset (
new
DepthSenseDeviceManager);
78
}
79
return
(instance);
80
}
81
82
/** Get the number of connected DepthSense devices. */
83
inline
std::size_t
84
getNumDevices
()
85
{
86
return
(context_.getDevices ().size ());
87
}
88
89
/** Capture first available device and associate it with a given
90
* grabber instance. */
91
std::string
92
captureDevice
(
DepthSenseGrabberImpl
* grabber);
93
94
/** Capture the device with given index and associate it with a given
95
* grabber instance. */
96
std::string
97
captureDevice
(
DepthSenseGrabberImpl
* grabber, std::size_t index);
98
99
/** Capture the device with given serial number and associate it with
100
* a given grabber instance. */
101
std::string
102
captureDevice
(
DepthSenseGrabberImpl
* grabber,
const
std::string& sn);
103
104
/** Release DepthSense device with given serial number. */
105
void
106
releaseDevice
(
const
std::string& sn);
107
108
/** Reconfigure DepthSense device with given serial number. */
109
void
110
reconfigureDevice
(
const
std::string& sn);
111
112
/** Start data capturing for a given device. */
113
void
114
startDevice
(
const
std::string& sn);
115
116
/** Stop data capturing for a given device. */
117
void
118
stopDevice
(
const
std::string& sn);
119
120
~DepthSenseDeviceManager
();
121
122
private
:
123
124
DepthSenseDeviceManager ();
125
126
std::string
127
captureDevice
(
DepthSenseGrabberImpl
* grabber, DepthSense::Device
device
);
128
129
inline
bool
130
isCaptured (
const
std::string& sn)
const
131
{
132
return
(captured_devices_.count (sn) != 0);
133
}
134
135
DepthSense::Context context_;
136
137
static
std::mutex mutex_;
138
139
/// Thread where the grabbing takes place.
140
std::thread depth_sense_thread_;
141
142
struct
CapturedDevice
143
{
144
DepthSenseGrabberImpl
* grabber;
145
DepthSense::DepthNode depth_node;
146
DepthSense::ColorNode color_node;
147
};
148
149
std::map<std::string, CapturedDevice> captured_devices_;
150
151
};
152
153
}
// namespace depth_sense
154
155
}
// namespace io
156
157
}
// namespace pcl
pcl::io::depth_sense::DepthSenseDeviceManager::releaseDevice
void releaseDevice(const std::string &sn)
Release DepthSense device with given serial number.
pcl::io::depth_sense::DepthSenseDeviceManager::reconfigureDevice
void reconfigureDevice(const std::string &sn)
Reconfigure DepthSense device with given serial number.
pcl::io::depth_sense::DepthSenseDeviceManager::~DepthSenseDeviceManager
~DepthSenseDeviceManager()
pcl::io::depth_sense::DepthSenseDeviceManager::startDevice
void startDevice(const std::string &sn)
Start data capturing for a given device.
pcl::io::depth_sense::DepthSenseDeviceManager::captureDevice
std::string captureDevice(DepthSenseGrabberImpl *grabber)
Capture first available device and associate it with a given grabber instance.
pcl::io::depth_sense::DepthSenseDeviceManager::getInstance
static Ptr & getInstance()
Definition
depth_sense_device_manager.h:70
pcl::io::depth_sense::DepthSenseDeviceManager::stopDevice
void stopDevice(const std::string &sn)
Stop data capturing for a given device.
pcl::io::depth_sense::DepthSenseDeviceManager::captureDevice
std::string captureDevice(DepthSenseGrabberImpl *grabber, const std::string &sn)
Capture the device with given serial number and associate it with a given grabber instance.
pcl::io::depth_sense::DepthSenseDeviceManager::getNumDevices
std::size_t getNumDevices()
Get the number of connected DepthSense devices.
Definition
depth_sense_device_manager.h:84
pcl::io::depth_sense::DepthSenseDeviceManager::captureDevice
std::string captureDevice(DepthSenseGrabberImpl *grabber, std::size_t index)
Capture the device with given index and associate it with a given grabber instance.
pcl::io::depth_sense::DepthSenseDeviceManager::Ptr
std::shared_ptr< DepthSenseDeviceManager > Ptr
Definition
depth_sense_device_manager.h:67
pcl::device
Definition
device_array.h:315
pcl::io::depth_sense
Definition
depth_sense_device_manager.h:56
pcl::io
Definition
io.h:517
pcl
Definition
convolution.h:46
pcl::io::depth_sense::DepthSenseGrabberImpl
Definition
depth_sense_grabber_impl.h:59