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 #pragma once
39 
40 #include <vector>
41 
42 #include <pcl/recognition/region_xy.h>
43 
44 namespace pcl
45 {
46 
47   struct DenseQuantizedSingleModTemplate
48   {
49     std::vector<unsigned char> features;
50 
51     void
serializeDenseQuantizedSingleModTemplate52     serialize (std::ostream & stream) const
53     {
54       const std::size_t num_of_features = static_cast<std::size_t> (features.size ());
55       write (stream, num_of_features);
56       for (std::size_t feature_index = 0; feature_index < num_of_features; ++feature_index)
57       {
58         write (stream, features[feature_index]);
59       }
60     }
61 
62     void
deserializeDenseQuantizedSingleModTemplate63     deserialize (std::istream & stream)
64     {
65       features.clear ();
66 
67       std::size_t num_of_features;
68       read (stream, num_of_features);
69       features.resize (num_of_features);
70       for (std::size_t feature_index = 0; feature_index < num_of_features; ++feature_index)
71       {
72         read (stream, features[feature_index]);
73       }
74     }
75   };
76 
77   struct DenseQuantizedMultiModTemplate
78   {
79     std::vector<DenseQuantizedSingleModTemplate> modalities;
80     float response_factor;
81 
82     RegionXY region;
83 
84     void
serializeDenseQuantizedMultiModTemplate85     serialize (std::ostream & stream) const
86     {
87       const std::size_t num_of_modalities = static_cast<std::size_t> (modalities.size ());
88       write (stream, num_of_modalities);
89       for (std::size_t modality_index = 0; modality_index < num_of_modalities; ++modality_index)
90       {
91         modalities[modality_index].serialize (stream);
92       }
93 
94       region.serialize (stream);
95     }
96 
97     void
deserializeDenseQuantizedMultiModTemplate98     deserialize (std::istream & stream)
99     {
100       modalities.clear ();
101 
102       std::size_t num_of_modalities;
103       read (stream, num_of_modalities);
104       modalities.resize (num_of_modalities);
105       for (std::size_t modality_index = 0; modality_index < num_of_modalities; ++modality_index)
106       {
107         modalities[modality_index].deserialize (stream);
108       }
109 
110       region.deserialize (stream);
111     }
112   };
113 
114 }
115