+ add segmentation algorithm

This commit is contained in:
wmayer
2016-03-03 18:07:17 +01:00
parent 29229942e0
commit 6b4e1f6b48
4 changed files with 235 additions and 2 deletions

View File

@@ -45,6 +45,7 @@
#include "BSplineFitting.h"
#include "SurfaceTriangulation.h"
#include "RegionGrowing.h"
#include "Segmentation.h"
#include "SampleConsensus.h"
#if defined(HAVE_PCL_FILTERS)
#include <pcl/filters/passthrough.h>
@@ -99,8 +100,11 @@ public:
add_keyword_method("regionGrowingSegmentation",&Module::regionGrowingSegmentation,
"regionGrowingSegmentation()."
);
add_keyword_method("featureSegmentation",&Module::featureSegmentation,
"featureSegmentation()."
);
#endif
#if defined(HAVE_PCL_SEGMENTATION)
#if defined(HAVE_PCL_SAMPLE_CONSENSUS)
add_keyword_method("sampleConsensus",&Module::sampleConsensus,
"sampleConsensus()."
);
@@ -625,10 +629,37 @@ Mesh.show(m)
lists.append(tuple);
}
return lists;
}
Py::Object featureSegmentation(const Py::Tuple& args, const Py::Dict& kwds)
{
PyObject *pts;
int ksearch=5;
static char* kwds_segment[] = {"Points", "KSearch", NULL};
if (!PyArg_ParseTupleAndKeywords(args.ptr(), kwds.ptr(), "O!|i", kwds_segment,
&(Points::PointsPy::Type), &pts, &ksearch))
throw Py::Exception();
Points::PointKernel* points = static_cast<Points::PointsPy*>(pts)->getPointKernelPtr();
std::list<std::vector<int> > clusters;
Segmentation segm(*points, clusters);
segm.perform(ksearch);
Py::List lists;
for (std::list<std::vector<int> >::iterator it = clusters.begin(); it != clusters.end(); ++it) {
Py::Tuple tuple(it->size());
for (std::size_t i = 0; i < it->size(); i++) {
tuple.setItem(i, Py::Long((*it)[i]));
}
lists.append(tuple);
}
return lists;
}
#endif
#if defined(HAVE_PCL_SEGMENTATION)
#if defined(HAVE_PCL_SAMPLE_CONSENSUS)
Py::Object sampleConsensus(const Py::Tuple& args, const Py::Dict& kwds)
{
PyObject *pts;