Developer Documentation
Loading...
Searching...
No Matches
Python.cc
1/*===========================================================================*\
2* *
3* OpenFlipper *
4 * Copyright (c) 2020, RWTH-Aachen University *
5 * Department of Computer Graphics and Multimedia *
6 * All rights reserved. *
7 * www.openflipper.org *
8 * *
9 *---------------------------------------------------------------------------*
10 * This file is part of OpenFlipper. *
11 *---------------------------------------------------------------------------*
12 * *
13 * Redistribution and use in source and binary forms, with or without *
14 * modification, are permitted provided that the following conditions *
15 * are met: *
16 * *
17 * 1. Redistributions of source code must retain the above copyright notice, *
18 * this list of conditions and the following disclaimer. *
19 * *
20 * 2. Redistributions in binary form must reproduce the above copyright *
21 * notice, this list of conditions and the following disclaimer in the *
22 * documentation and/or other materials provided with the distribution. *
23 * *
24 * 3. Neither the name of the copyright holder nor the names of its *
25 * contributors may be used to endorse or promote products derived from *
26 * this software without specific prior written permission. *
27 * *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39* *
40\*===========================================================================*/
41
42
43#include <pybind11/pybind11.h>
44#include <pybind11/embed.h>
45
46
47#include <ICPPlugin.hh>
48#include <OpenFlipper/BasePlugin/PythonFunctions.hh>
49#include <OpenFlipper/PythonInterpreter/PythonTypeConversions.hh>
50
51namespace py = pybind11;
52
53PYBIND11_EMBEDDED_MODULE(ICP, m) {
54
55 QObject* pluginPointer = getPluginPointer("ICP");
56
57 if (!pluginPointer) {
58 std::cerr << "Error Getting plugin pointer for Plugin-ICP" << std::endl;
59 return;
60 }
61
62 ICPPlugin* plugin = qobject_cast<ICPPlugin*>(pluginPointer);
63
64 if (!plugin) {
65 std::cerr << "Error converting plugin pointer for Plugin-ICP" << std::endl;
66 return;
67 }
68
69 // Export our core. Make sure that the c++ worlds core object is not deleted if
70 // the python side gets deleted!!
71 py::class_< ICPPlugin,std::unique_ptr<ICPPlugin, py::nodelete> > icp(m, "ICP");
72
73 // On the c++ side we will just return the existing core instance
74 // and prevent the system to recreate a new core as we need
75 // to work on the existing one.
76 icp.def(py::init([plugin]() { return plugin; }));
77
78 icp.def("icp", &ICPPlugin::icp,
79 QCoreApplication::translate("PythonDocICP", "Execute the ICP algorithm").toLatin1().data(),
80 py::arg(QCoreApplication::translate("PythonDocICP","Max Iteration count").toLatin1().data()),
81 py::arg(QCoreApplication::translate("PythonDocICP","MSE error threshold").toLatin1().data()),
82 py::arg(QCoreApplication::translate("PythonDocICP","Point distance threshold").toLatin1().data()),
83 py::arg(QCoreApplication::translate("PythonDocICP","Normal dot threshold in percent").toLatin1().data()),
84 py::arg(QCoreApplication::translate("PythonDocICP","Enable debug output").toLatin1().data()),
85 py::arg(QCoreApplication::translate("PythonDocICP","Enable auto resize").toLatin1().data()),
86 py::arg(QCoreApplication::translate("PythonDocICP","Interpolate Normals").toLatin1().data()),
87 py::arg(QCoreApplication::translate("PythonDocICP","Source object id").toLatin1().data()),
88 py::arg(QCoreApplication::translate("PythonDocICP","Target object id").toLatin1().data())
89 );
90}
void icp(int _maxIterations, double _errorThreshold, double _distanceThreshold, double _normalDotThreshold, bool _debugOutput, bool _doResize, bool _interpolateNormals, int _sourceObjectID, int _targetObjectID)
Definition ICPPlugin.cc:658
Namespace for ICP.
Definition ICP.hh:72
void icp(const std::vector< VectorT > &_points1, const std::vector< VectorT > &_points2, VectorT &_cog1, VectorT &_cog2, double &_scale1, double &_scale2, QuaternionT &_rotation)
Compute rigid transformation from first point set to second point set.
Definition ICPT_impl.hh:85