21 float epsilon,
size_t uextent,
size_t vextent,
33 size_t uextent, vextent;
36 i->read((
char*)&size,
sizeof(size));
40 i->read((
char*)&bbox,
sizeof(bbox));
42 i->read((
char*)&uextent,
sizeof(uextent));
43 i->read((
char*)&vextent,
sizeof(vextent));
45 for (
size_t j = 0; j < size; ++j)
49 i->read((
char*)&numPolys,
sizeof(numPolys));
50 for (
size_t k = 0; k < numPolys; ++k)
54 i->read((
char*)&numPoints,
sizeof(numPoints));
56 for (
size_t l = 0; l < numPoints; ++l)
58 i->read((
char*)&pp,
sizeof(pp));
67 size_t uextent, vextent;
74 (*i) >> bbox.
Min()[0] >> bbox.
Max()[0]
75 >> bbox.
Min()[1] >> bbox.
Max()[1];
77 (*i) >> uextent >> vextent;
79 for (
size_t j = 0; j < size; ++j)
84 for (
size_t k = 0; k < numPolys; ++k)
90 for (
size_t l = 0; l < numPoints; ++l)
92 (*i) >> pp[0] >> pp[1];
137 WrapBitmap(bitmapInfo.
bbox, epsilon, &uwrap, &vwrap);
151 if (labels.size() <= 1)
156 WrapComponents(bitmapInfo.
bbox, epsilon, bitmapInfo.
uextent, bitmapInfo.
vextent, &componentsImg, &labels);
158 return labels.size();
169 if (AllConnectedComponents(
pc, epsilon, bitmapInfo,
indices, componentsImg, labels, doFiltering) <= 1)
179 for (
size_t i = 2; i < labels.
size(); ++i)
180 if (labels[maxComp].second < labels[i].second)
187 std::numeric_limits< float >::infinity(),
188 std::numeric_limits< float >::infinity());
192 for (
size_t i = 0; i < size; ++i)
194 if (componentsImg[bitmapInfo.
bmpIdx[i]] == labels[maxComp].first)
199 if (bbox.
Min()[0] > bitmapInfo.
params[i].first)
201 bbox.
Min()[0] = bitmapInfo.
params[i].first;
203 if (bbox.
Max()[0] < bitmapInfo.
params[i].first)
205 bbox.
Max()[0] = bitmapInfo.
params[i].first;
207 if (bbox.
Min()[1] > bitmapInfo.
params[i].second)
209 bbox.
Min()[1] = bitmapInfo.
params[i].second;
211 if (bbox.
Max()[1] < bitmapInfo.
params[i].second)
213 bbox.
Max()[1] = bitmapInfo.
params[i].second;
221 int borderPixels = 0;
222 int maxLabel = labels[maxComp].first;
225 char numNeighbours = 0;
229 for (
size_t v = 1;
v < bitmapInfo.
vextent - 1; ++
v)
231 for (
size_t u = 1; u < bitmapInfo.
uextent - 1; ++u)
235 if (componentsImg[pos] == maxLabel)
238 numNeighbours = bitmapInfo.
bitmap[pos - 1] + bitmapInfo.
bitmap[pos + 1] +
243 if ((
int)numNeighbours != 8)
254 for (
size_t v = 1;
v < bitmapInfo.
vextent - 1; ++
v)
257 if (componentsImg[row] == maxLabel)
263 if (componentsImg[row + bitmapInfo.
uextent - 1] == maxLabel)
273 for (
size_t u = 0; u < bitmapInfo.
uextent; ++u)
276 if (componentsImg[u] == maxLabel)
282 if (componentsImg[row + u] == maxLabel)
288 *borderRatio =
static_cast<float>(borderPixels) /
static_cast<float>(ccSize);
296 float epsilon,
size_t begin,
size_t end,
297 std::deque< ComponentPolygons >* polys)
const
300 size_t uextent, vextent;
301 BuildPolygons(
pc, epsilon, begin, end, &bbox, &uextent, &vextent, polys);
305 float epsilon,
size_t begin,
size_t end,
PointCloud* bmpPc)
const
312 size_t uextent, vextent;
314 &bbox, &bitmap, &uextent, &vextent, &bmpIdx);
328 for (
size_t i = 0; i < vextent * uextent; ++i)
335 if (count >= bmpPc->
size())
337 bmpPc->
resize(2 * count + 1);
339 if (InSpace(i % uextent, i / uextent, epsilon, bbox, uextent,
340 vextent, &(*bmpPc)[count].pos, &(*bmpPc)[count].normal))
351 size_t* uextent,
size_t* vextent,
352 std::deque< ComponentPolygons >* polys)
const
365 bbox, &bitmap, uextent, vextent, &bmpIdx);
369 DilateCross(bitmap, *uextent, *vextent,
false,
false, &tempBmp);
370 ErodeCross(tempBmp, *uextent, *vextent,
false,
false, &bitmap);
375 Components(bitmap, *uextent, *vextent,
false,
false, &componentsImg,
377 if (labels.
size() <= 1)
383 for (
size_t i = 1; i < labels.
size(); ++i)
385 polys->resize(polys->size() + 1);
386 ComponentLoops(componentsImg, *uextent, *vextent, labels[i].first,
387 false,
false, &(*polys)[polys->size() - 1]);