Point Cloud Library (PCL)  1.7.0
dense_quantized_multi_mod_template.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2010-2011, Willow Garage, 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 Willow Garage, Inc. 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 #ifndef PCL_FEATURES_DENSE_QUANTIZED_MULTI_MOD_TEMPLATE
39 #define PCL_FEATURES_DENSE_QUANTIZED_MULTI_MOD_TEMPLATE
40 
41 #include <vector>
42 
43 #include <pcl/recognition/region_xy.h>
44 
45 namespace pcl
46 {
47 
49  {
50  std::vector<unsigned char> features;
51 
52  void
53  serialize (std::ostream & stream) const
54  {
55  const size_t num_of_features = static_cast<size_t> (features.size ());
56  write (stream, num_of_features);
57  for (size_t feature_index = 0; feature_index < num_of_features; ++feature_index)
58  {
59  write (stream, features[feature_index]);
60  }
61  }
62 
63  void
64  deserialize (std::istream & stream)
65  {
66  features.clear ();
67 
68  size_t num_of_features;
69  read (stream, num_of_features);
70  features.resize (num_of_features);
71  for (size_t feature_index = 0; feature_index < num_of_features; ++feature_index)
72  {
73  read (stream, features[feature_index]);
74  }
75  }
76  };
77 
79  {
80  std::vector<DenseQuantizedSingleModTemplate> modalities;
82 
84 
85  void
86  serialize (std::ostream & stream) const
87  {
88  const size_t num_of_modalities = static_cast<size_t> (modalities.size ());
89  write (stream, num_of_modalities);
90  for (size_t modality_index = 0; modality_index < num_of_modalities; ++modality_index)
91  {
92  modalities[modality_index].serialize (stream);
93  }
94 
95  region.serialize (stream);
96  }
97 
98  void
99  deserialize (std::istream & stream)
100  {
101  modalities.clear ();
102 
103  size_t num_of_modalities;
104  read (stream, num_of_modalities);
105  modalities.resize (num_of_modalities);
106  for (size_t modality_index = 0; modality_index < num_of_modalities; ++modality_index)
107  {
108  modalities[modality_index].deserialize (stream);
109  }
110 
111  region.deserialize (stream);
112  }
113  };
114 
115 }
116 
117 #endif