Point Cloud Library (PCL)  1.11.1-dev
hypothesis.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2010-2012, 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 
39 /*
40  * hypothesis.h
41  *
42  * Created on: Mar 12, 2013
43  * Author: papazov
44  */
45 
46 #pragma once
47 
48 #include <pcl/recognition/ransac_based/model_library.h>
49 #include <pcl/recognition/ransac_based/auxiliary.h>
50 
51 namespace pcl
52 {
53  namespace recognition
54  {
56  {
57  public:
59  : obj_model_ (obj_model)
60  {}
61 
62  HypothesisBase (const ModelLibrary::Model* obj_model, const float* rigid_transform)
63  : obj_model_ (obj_model)
64  {
65  memcpy (rigid_transform_, rigid_transform, 12*sizeof (float));
66  }
67 
68  virtual ~HypothesisBase (){}
69 
70  void
72  {
73  obj_model_ = model;
74  }
75 
76  public:
77  float rigid_transform_[12];
79  };
80 
81  class Hypothesis: public HypothesisBase
82  {
83  public:
84  Hypothesis (const ModelLibrary::Model* obj_model = nullptr)
85  : HypothesisBase (obj_model),
86  match_confidence_ (-1.0f),
87  linear_id_ (-1)
88  {
89  }
90 
91  Hypothesis (const Hypothesis& src)
95  {
96  }
97 
99 
100  const Hypothesis&
101  operator =(const Hypothesis& src)
102  {
103  memcpy (this->rigid_transform_, src.rigid_transform_, 12*sizeof (float));
104  this->obj_model_ = src.obj_model_;
107 
108  return *this;
109  }
110 
111  void
112  setLinearId (int id)
113  {
114  linear_id_ = id;
115  }
116 
117  int
118  getLinearId () const
119  {
120  return (linear_id_);
121  }
122 
123  void
124  computeBounds (float bounds[6]) const
125  {
126  const float *b = obj_model_->getBoundsOfOctreePoints ();
127  float p[3];
128 
129  // Initialize 'bounds'
130  aux::transform (rigid_transform_, b[0], b[2], b[4], p);
131  bounds[0] = bounds[1] = p[0];
132  bounds[2] = bounds[3] = p[1];
133  bounds[4] = bounds[5] = p[2];
134 
135  // Expand 'bounds' to contain the other 7 points of the octree bounding box
136  aux::transform (rigid_transform_, b[0], b[2], b[5], p); aux::expandBoundingBoxToContainPoint (bounds, p);
137  aux::transform (rigid_transform_, b[0], b[3], b[4], p); aux::expandBoundingBoxToContainPoint (bounds, p);
138  aux::transform (rigid_transform_, b[0], b[3], b[5], p); aux::expandBoundingBoxToContainPoint (bounds, p);
139  aux::transform (rigid_transform_, b[1], b[2], b[4], p); aux::expandBoundingBoxToContainPoint (bounds, p);
140  aux::transform (rigid_transform_, b[1], b[2], b[5], p); aux::expandBoundingBoxToContainPoint (bounds, p);
141  aux::transform (rigid_transform_, b[1], b[3], b[4], p); aux::expandBoundingBoxToContainPoint (bounds, p);
142  aux::transform (rigid_transform_, b[1], b[3], b[5], p); aux::expandBoundingBoxToContainPoint (bounds, p);
143  }
144 
145  void
146  computeCenterOfMass (float center_of_mass[3]) const
147  {
149  }
150 
151  public:
153  std::set<int> explained_pixels_;
155  };
156  } // namespace recognition
157 } // namespace pcl
pcl::recognition::Hypothesis::computeBounds
void computeBounds(float bounds[6]) const
Definition: hypothesis.h:124
pcl
Definition: convolution.h:46
pcl::recognition::Hypothesis::match_confidence_
float match_confidence_
Definition: hypothesis.h:152
pcl::recognition::HypothesisBase
Definition: hypothesis.h:55
pcl::recognition::Hypothesis
Definition: hypothesis.h:81
pcl::recognition::HypothesisBase::HypothesisBase
HypothesisBase(const ModelLibrary::Model *obj_model, const float *rigid_transform)
Definition: hypothesis.h:62
pcl::recognition::HypothesisBase::obj_model_
const ModelLibrary::Model * obj_model_
Definition: hypothesis.h:78
pcl::recognition::aux::expandBoundingBoxToContainPoint
void expandBoundingBoxToContainPoint(T bbox[6], const T p[3])
Expands the bounding box 'bbox' such that it contains the point 'p'.
Definition: auxiliary.h:95
pcl::recognition::Hypothesis::computeCenterOfMass
void computeCenterOfMass(float center_of_mass[3]) const
Definition: hypothesis.h:146
pcl::recognition::Hypothesis::operator=
const Hypothesis & operator=(const Hypothesis &src)
Definition: hypothesis.h:101
pcl::recognition::HypothesisBase::HypothesisBase
HypothesisBase(const ModelLibrary::Model *obj_model)
Definition: hypothesis.h:58
pcl::recognition::Hypothesis::~Hypothesis
~Hypothesis()
Definition: hypothesis.h:98
pcl::recognition::Hypothesis::explained_pixels_
std::set< int > explained_pixels_
Definition: hypothesis.h:153
pcl::recognition::ModelLibrary::Model::getOctreeCenterOfMass
const float * getOctreeCenterOfMass() const
Definition: model_library.h:146
pcl::recognition::ModelLibrary::Model
Stores some information about the model.
Definition: model_library.h:64
pcl::recognition::Hypothesis::getLinearId
int getLinearId() const
Definition: hypothesis.h:118
pcl::recognition::HypothesisBase::setModel
void setModel(const ModelLibrary::Model *model)
Definition: hypothesis.h:71
pcl::recognition::Hypothesis::linear_id_
int linear_id_
Definition: hypothesis.h:154
pcl::recognition::HypothesisBase::~HypothesisBase
virtual ~HypothesisBase()
Definition: hypothesis.h:68
pcl::recognition::Hypothesis::Hypothesis
Hypothesis(const Hypothesis &src)
Definition: hypothesis.h:91
pcl::recognition::ModelLibrary::Model::getBoundsOfOctreePoints
const float * getBoundsOfOctreePoints() const
Definition: model_library.h:152
pcl::recognition::Hypothesis::setLinearId
void setLinearId(int id)
Definition: hypothesis.h:112
pcl::recognition::Hypothesis::Hypothesis
Hypothesis(const ModelLibrary::Model *obj_model=nullptr)
Definition: hypothesis.h:84
pcl::recognition::HypothesisBase::rigid_transform_
float rigid_transform_[12]
Definition: hypothesis.h:77
pcl::recognition::aux::transform
void transform(const T t[12], const T p[3], T out[3])
The first 9 elements of 't' are treated as a 3x3 matrix (row major order) and the last 3 as a transla...
Definition: auxiliary.h:304