Go to the documentation of this file.
42 size_t uextent, vextent;
45 i->read((
char*)&size,
sizeof(size));
49 i->read((
char*)&bbox,
sizeof(bbox));
51 i->read((
char*)&uextent,
sizeof(uextent));
52 i->read((
char*)&vextent,
sizeof(vextent));
54 for (
size_t j = 0; j < size; ++j)
58 i->read((
char*)&numPolys,
sizeof(numPolys));
59 for (
size_t k = 0; k < numPolys; ++k)
63 i->read((
char*)&numPoints,
sizeof(numPoints));
65 for (
size_t l = 0; l < numPoints; ++l)
67 i->read((
char*)&pp,
sizeof(pp));
76 size_t uextent, vextent;
83 (*i) >> bbox.
Min()[0] >> bbox.
Max()[0] >> bbox.
Min()[1] >> bbox.
Max()[1];
85 (*i) >> uextent >> vextent;
87 for (
size_t j = 0; j < size; ++j)
92 for (
size_t k = 0; k < numPolys; ++k)
98 for (
size_t l = 0; l < numPoints; ++l)
100 (*i) >> pp[0] >> pp[1];
159 WrapBitmap(bitmapInfo.
bbox, epsilon, &uwrap, &vwrap);
180 if (labels.size() <= 1)
186 bitmapInfo.
bbox, epsilon, bitmapInfo.
uextent, bitmapInfo.
vextent, &componentsImg, &labels);
188 return labels.size();
202 if (AllConnectedComponents(
203 pc, epsilon, bitmapInfo,
indices, componentsImg, labels, doFiltering) <= 1)
213 for (
size_t i = 2; i < labels.
size(); ++i)
214 if (labels[maxComp].second < labels[i].second)
221 std::numeric_limits<float>::infinity());
225 for (
size_t i = 0; i < size; ++i)
227 if (componentsImg[bitmapInfo.
bmpIdx[i]] == labels[maxComp].first)
232 if (bbox.
Min()[0] > bitmapInfo.
params[i].first)
234 bbox.
Min()[0] = bitmapInfo.
params[i].first;
236 if (bbox.
Max()[0] < bitmapInfo.
params[i].first)
238 bbox.
Max()[0] = bitmapInfo.
params[i].first;
240 if (bbox.
Min()[1] > bitmapInfo.
params[i].second)
242 bbox.
Min()[1] = bitmapInfo.
params[i].second;
244 if (bbox.
Max()[1] < bitmapInfo.
params[i].second)
246 bbox.
Max()[1] = bitmapInfo.
params[i].second;
254 int borderPixels = 0;
255 int maxLabel = labels[maxComp].first;
258 char numNeighbours = 0;
262 for (
size_t v = 1;
v < bitmapInfo.
vextent - 1; ++
v)
264 for (
size_t u = 1; u < bitmapInfo.
uextent - 1; ++u)
268 if (componentsImg[pos] == maxLabel)
271 numNeighbours = bitmapInfo.
bitmap[pos - 1] + bitmapInfo.
bitmap[pos + 1] +
279 if ((
int)numNeighbours != 8)
290 for (
size_t v = 1;
v < bitmapInfo.
vextent - 1; ++
v)
293 if (componentsImg[row] == maxLabel)
299 if (componentsImg[row + bitmapInfo.
uextent - 1] == maxLabel)
309 for (
size_t u = 0; u < bitmapInfo.
uextent; ++u)
312 if (componentsImg[u] == maxLabel)
318 if (componentsImg[row + u] == maxLabel)
324 *borderRatio =
static_cast<float>(borderPixels) /
static_cast<float>(ccSize);
336 std::deque<ComponentPolygons>* polys)
const
339 size_t uextent, vextent;
340 BuildPolygons(
pc, epsilon, begin, end, &bbox, &uextent, &vextent, polys);
355 size_t uextent, vextent;
379 for (
size_t i = 0; i < vextent * uextent; ++i)
386 if (count >= bmpPc->
size())
388 bmpPc->
resize(2 * count + 1);
390 if (InSpace(i % uextent,
396 &(*bmpPc)[count].pos,
397 &(*bmpPc)[count].normal))
414 std::deque<ComponentPolygons>* polys)
const
439 DilateCross(bitmap, *uextent, *vextent,
false,
false, &tempBmp);
440 ErodeCross(tempBmp, *uextent, *vextent,
false,
false, &bitmap);
445 Components(bitmap, *uextent, *vextent,
false,
false, &componentsImg, &labels);
446 if (labels.
size() <= 1)
452 for (
size_t i = 1; i < labels.
size(); ++i)
454 polys->resize(polys->size() + 1);
461 &(*polys)[polys->size() - 1]);
void DilateCross(const MiscLib::Vector< char > &bitmap, size_t uextent, size_t vextent, bool uwrap, bool vwrap, MiscLib::Vector< char > *dilated)
size_t AllConnectedComponents(const PointCloud &pc, float epsilon, BitmapInfo &bitmapInfo, MiscLib::Vector< size_t > *indices, MiscLib::Vector< int > &componentsImg, MiscLib::Vector< std::pair< int, size_t >> &labels, bool doFiltering=true)
MiscLib::Vector< std::pair< float, float > > params
virtual void PreWrapBitmap(const GfxTL::AABox< GfxTL::Vector2Df > &bbox, float epsilon, size_t uextent, size_t vextent, MiscLib::Vector< char > *bmp) const
void resize(size_type s, const value_type &v)
void ComponentLoops(const MiscLib::Vector< int > &componentImg, size_t uextent, size_t vextent, int label, bool uwrap, bool vwrap, MiscLib::Vector< MiscLib::Vector< GfxTL::VectorXD< 2, size_t >>> *polys)
MiscLib::Vector< size_t > bmpIdx
GfxTL::AABox< GfxTL::Vector2Df > bbox
void BuildPolygons(const PointCloud &pc, float epsilon, size_t begin, size_t end, GfxTL::AABox< GfxTL::Vector2Df > *bbox, size_t *uextent, size_t *vextent, std::deque< ComponentPolygons > *polys) const
void swap(SubscriptionHandle &first, SubscriptionHandle &second)
void GenerateBitmapPoints(const PointCloud &pc, float epsilon, size_t begin, size_t end, PointCloud *bmpPc) const
void TrimmingPolygons(const PointCloud &pc, float epsilon, size_t begin, size_t end, std::deque< ComponentPolygons > *polys) const
pcl::PointIndices::Ptr indices(const PCG &g)
Retrieve the indices of the points of the point cloud stored in a point cloud graph that actually bel...
bool Init(bool binary, std::istream *i)
for(;yybottom<=yytop;yybottom++)
virtual void WrapComponents(const GfxTL::AABox< GfxTL::Vector2Df > &bbox, float epsilon, size_t uextent, size_t vextent, MiscLib::Vector< int > *componentImg, MiscLib::Vector< std::pair< int, size_t >> *labels) const
void ErodeCross(const MiscLib::Vector< char > &bitmap, size_t uextent, size_t vextent, bool uwrap, bool vwrap, MiscLib::Vector< char > *eroded)
double v(double t, double v0, double a0, double j)
size_t ConnectedComponent(const PointCloud &pc, float epsilon, MiscLib::Vector< size_t > *indices, bool doFiltering=true, float *borderRatio=0)
VectorXD< 2, float > Vector2Df
MiscLib::Vector< char > bitmap
Introduction Thank you for taking interest in our work and downloading this software This library implements the algorithm described in the paper R R R Klein Efficient RANSAC for Point Cloud Shape in Computer Graphics Blackwell June If you use this software you should cite the aforementioned paper in any resulting publication Please send comments or bug reports to Ruwen Roland BUT NOT LIMITED THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY OR CONSEQUENTIAL WHETHER IN STRICT OR EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE Example usage This section shows how to use the library to detect the shapes in a point cloud PointCloud pc
void Components(const MiscLib::Vector< char > &bitmap, size_t uextent, size_t vextent, bool uwrap, bool vwrap, MiscLib::Vector< int > *componentsImg, MiscLib::Vector< std::pair< int, size_t >> *labels)