openni2_convert.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/make_shared.hpp>
36 
37 #include <string>
38 
39 namespace openni2_wrapper
40 {
41 
42 const OpenNI2DeviceInfo openni2_convert(const openni::DeviceInfo* pInfo)
43 {
44  if (!pInfo)
45  THROW_OPENNI_EXCEPTION("openni2_convert called with zero pointer\n");
46 
47  OpenNI2DeviceInfo output;
48 
49  output.name_ = pInfo->getName();
50  output.uri_ = pInfo->getUri();
51  output.vendor_ = pInfo->getVendor();
52  output.product_id_ = pInfo->getUsbProductId();
53  output.vendor_id_ = pInfo->getUsbVendorId();
54 
55  return output;
56 }
57 
58 
59 const OpenNI2VideoMode openni2_convert(const openni::VideoMode& input)
60 {
61  OpenNI2VideoMode output;
62 
63  output.x_resolution_ = input.getResolutionX();
64  output.y_resolution_ = input.getResolutionY();
65  output.frame_rate_ = input.getFps();
66  output.pixel_format_ = static_cast<PixelFormat>(input.getPixelFormat());
67 
68  return output;
69 }
70 
71 const openni::VideoMode openni2_convert(const OpenNI2VideoMode& input)
72 {
73 
74  openni::VideoMode output;
75 
76  output.setResolution(input.x_resolution_, input.y_resolution_);
77  output.setFps(input.frame_rate_);
78  output.setPixelFormat(static_cast<openni::PixelFormat>(input.pixel_format_));
79 
80  return output;
81 }
82 
83 
84 const std::vector<OpenNI2VideoMode> openni2_convert(const openni::Array<openni::VideoMode>& input)
85 {
86  std::vector<OpenNI2VideoMode> output;
87 
88  int size = input.getSize();
89 
90  output.reserve(size);
91 
92  for (int i=0; i<size; ++i)
93  output.push_back(openni2_convert(input[i]));
94 
95  return output;
96 }
97 
98 }
99 
100 
#define THROW_OPENNI_EXCEPTION(format,...)
const OpenNI2DeviceInfo openni2_convert(const openni::DeviceInfo *pInfo)


openni2_camera
Author(s): Julius Kammerl
autogenerated on Fri Jun 7 2019 22:05:43