Point Cloud Library (PCL)  1.11.0
mask_map.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 #pragma once
39 
40 #include <pcl/pcl_macros.h>
41 
42 #include <cstring>
43 #include <vector>
44 
45 namespace pcl {
47 public:
48  MaskMap() = default;
49 
50  MaskMap(std::size_t width, std::size_t height);
51 
52  virtual ~MaskMap() = default;
53 
54  void
55  resize(std::size_t width, std::size_t height);
56 
57  inline std::size_t
58  getWidth() const
59  {
60  return (width_);
61  }
62 
63  inline std::size_t
64  getHeight() const
65  {
66  return (height_);
67  }
68 
69  inline unsigned char*
71  {
72  return (data_.data());
73  }
74 
75  inline const unsigned char*
76  getData() const
77  {
78  return (data_.data());
79  }
80 
81  PCL_DEPRECATED(1, 12, "Use new version diff getDifferenceMask(mask0, mask1)")
82  static void
83  getDifferenceMask(const MaskMap& mask0, const MaskMap& mask1, MaskMap& diff_mask);
84 
86  static MaskMap
87  getDifferenceMask(const MaskMap& mask0, const MaskMap& mask1);
88 
89  inline void
90  set(const std::size_t x, const std::size_t y)
91  {
92  data_[y * width_ + x] = 255;
93  }
94 
95  inline void
96  unset(const std::size_t x, const std::size_t y)
97  {
98  data_[y * width_ + x] = 0;
99  }
100 
101  inline bool
102  isSet(const std::size_t x, const std::size_t y) const
103  {
104  return (data_[y * width_ + x] != 0);
105  }
106 
107  inline void
109  {
110  data_.assign(data_.size(), 0);
111  }
112 
113  inline unsigned char&
114  operator()(const std::size_t x, const std::size_t y)
115  {
116  return (data_[y * width_ + x]);
117  }
118 
119  inline const unsigned char&
120  operator()(const std::size_t x, const std::size_t y) const
121  {
122  return (data_[y * width_ + x]);
123  }
124 
125  void
126  erode(MaskMap& eroded_mask) const;
127 
128 private:
129  std::vector<unsigned char> data_;
130  std::size_t width_ = 0;
131  std::size_t height_ = 0;
132 };
133 
134 } // namespace pcl
pcl::MaskMap::isSet
bool isSet(const std::size_t x, const std::size_t y) const
Definition: mask_map.h:102
pcl_macros.h
Defines all the PCL and non-PCL macros used.
pcl
Definition: convolution.h:46
pcl::MaskMap::getWidth
std::size_t getWidth() const
Definition: mask_map.h:58
pcl::MaskMap::~MaskMap
virtual ~MaskMap()=default
pcl::MaskMap::erode
void erode(MaskMap &eroded_mask) const
pcl::MaskMap::unset
void unset(const std::size_t x, const std::size_t y)
Definition: mask_map.h:96
PCL_NODISCARD
#define PCL_NODISCARD
Definition: pcl_macros.h:447
pcl::MaskMap::MaskMap
MaskMap(std::size_t width, std::size_t height)
pcl::MaskMap::reset
void reset()
Definition: mask_map.h:108
pcl::MaskMap::getHeight
std::size_t getHeight() const
Definition: mask_map.h:64
PCL_DEPRECATED
#define PCL_DEPRECATED(Major, Minor, Message)
macro for compatibility across compilers and help remove old deprecated items for the Major....
Definition: pcl_macros.h:150
pcl::MaskMap::MaskMap
MaskMap()=default
pcl::MaskMap::getData
const unsigned char * getData() const
Definition: mask_map.h:76
pcl::MaskMap::getData
unsigned char * getData()
Definition: mask_map.h:70
pcl::MaskMap
Definition: mask_map.h:46
pcl::MaskMap::operator()
const unsigned char & operator()(const std::size_t x, const std::size_t y) const
Definition: mask_map.h:120
pcl::MaskMap::resize
void resize(std::size_t width, std::size_t height)
PCL_EXPORTS
#define PCL_EXPORTS
Definition: pcl_macros.h:331
pcl::MaskMap::operator()
unsigned char & operator()(const std::size_t x, const std::size_t y)
Definition: mask_map.h:114