test_wrapper.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013, Willow Garage, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of the Willow Garage, Inc. nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  *
29  * Author: Julius Kammerl (jkammerl@willowgarage.com)
30  */
31 
34 
35 #include <boost/date_time/posix_time/posix_time.hpp>
36 #include <boost/thread/thread.hpp>
37 #include <boost/foreach.hpp>
38 
39 #include <iostream>
40 
41 using namespace std;
42 using namespace openni2_wrapper;
43 
44 int ir_counter_ = 0;
47 
48 void IRCallback(sensor_msgs::ImagePtr image)
49 {
50  ++ir_counter_;
51 }
52 
53 void ColorCallback(sensor_msgs::ImagePtr image)
54 {
56 }
57 
58 void DepthCallback(sensor_msgs::ImagePtr image)
59 {
61 }
62 
63 int main()
64 {
65  OpenNI2DeviceManager device_manager;
66 
67  std::cout << device_manager;
68 
69  boost::shared_ptr<std::vector<std::string> > device_uris = device_manager.getConnectedDeviceURIs();
70 
71  BOOST_FOREACH(const std::string& uri, *device_uris)
72  {
73  boost::shared_ptr<OpenNI2Device> device = device_manager.getDevice(uri);
74 
75  std::cout << *device;
76 
77  device->setIRFrameCallback(boost::bind(&IRCallback, _1));
78  device->setColorFrameCallback(boost::bind(&ColorCallback, _1));
79  device->setDepthFrameCallback(boost::bind(&DepthCallback, _1));
80 
81  ir_counter_ = 0;
82  color_counter_ = 0;
83  depth_counter_ = 0;
84 
85  device->startColorStream();
86  device->startDepthStream();
87 
88  boost::this_thread::sleep(boost::posix_time::milliseconds(1000));
89 
90  device->stopAllStreams();
91 
92  std::cout<<std::endl;
93 
94  std::cout<<"Number of called to IRCallback: "<< ir_counter_ << std::endl;
95  std::cout<<"Number of called to ColorCallback: "<< color_counter_ << std::endl;
96  std::cout<<"Number of called to DepthCallback: "<< depth_counter_ << std::endl;
97  }
98 
99 
100  return 0;
101 }
int main()
void IRCallback(sensor_msgs::ImagePtr image)
void DepthCallback(sensor_msgs::ImagePtr image)
int color_counter_
int depth_counter_
void ColorCallback(sensor_msgs::ImagePtr image)
int ir_counter_


openni2_camera
Author(s): Julius Kammerl
autogenerated on Wed Feb 3 2021 03:18:41