lsst.afw  13.0-98-g5a654715e+2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
transformFactory.cc
Go to the documentation of this file.
1 /*
2  * LSST Data Management System
3  * See COPYRIGHT file at the top of the source tree.
4  *
5  * This product includes software developed by the
6  * LSST Project (http://www.lsst.org/).
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the LSST License Statement and
19  * the GNU General Public License along with this program. If not,
20  * see <http://www.lsstcorp.org/LegalNotices/>.
21  */
22 #include "pybind11/pybind11.h"
23 #include "pybind11/stl.h"
24 
25 #include "numpy/arrayobject.h"
26 #include "ndarray/pybind11.h"
27 
28 #include "lsst/afw/geom/Endpoint.h"
30 
31 namespace py = pybind11;
32 using namespace py::literals;
33 
34 namespace lsst {
35 namespace afw {
36 namespace geom {
37 namespace {
38 
39 PYBIND11_PLUGIN(transformFactory) {
40  py::module mod("transformFactory");
41 
42  py::module::import("lsst.afw.geom.transform");
43 
44  // Need to import numpy for ndarray and eigen conversions
45  if (_import_array() < 0) {
46  PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray failed to import");
47  return nullptr;
48  }
49 
50  mod.def("linearizeTransform",
51  (AffineTransform(*)(TransformPoint2ToPoint2 const &, Point2D const &)) & linearizeTransform,
52  "original"_a, "point"_a);
53  mod.def("makeTransform", (TransformPoint2ToPoint2(*)(AffineTransform const &)) & makeTransform,
54  "affine"_a);
55  mod.def("makeRadialTransform",
56  (TransformPoint2ToPoint2(*)(std::vector<double> const &)) & makeRadialTransform, "coeffs"_a);
57  mod.def("makeRadialTransform",
58  (TransformPoint2ToPoint2(*)(std::vector<double> const &, std::vector<double> const &)) &
59  makeRadialTransform,
60  "forwardCoeffs"_a, "inverseCoeffs"_a);
61  mod.def("makeIdentityTransform", &makeIdentityTransform);
62 
63  return mod.ptr();
64 }
65 
66 } // namespace
67 } // namespace geom
68 } // namespace afw
69 } // namespace lsst
TransformPoint2ToPoint2 makeTransform(AffineTransform const &affine)
Wrap an AffineTransform as a Transform.
Transform< Point2Endpoint, Point2Endpoint > TransformPoint2ToPoint2
Definition: Transform.h:284
AffineTransform linearizeTransform(TransformPoint2ToPoint2 const &original, Point2D const &inPoint)
Approximate a Transform by its local linearization.
PYBIND11_PLUGIN(_cameraPoint)
Definition: cameraPoint.cc:35
TransformPoint2ToPoint2 makeIdentityTransform()
Trivial Transform x → x.
Point< double, 2 > Point2D
Definition: Point.h:273
double const _a
Definition: RandomImage.cc:77
TransformPoint2ToPoint2 makeRadialTransform(std::vector< double > const &coeffs)
A purely radial polynomial distortion.