22 #include "pybind11/pybind11.h" 23 #include "pybind11/eigen.h" 24 #include "pybind11/stl.h" 26 #include "ndarray/pybind11.h" 43 [](
auto & mod,
auto &
cls) {
46 cls.attr(
"XX") = py::cast(int(LinearTransform::Parameters::XX));
47 cls.attr(
"YX") = py::cast(int(LinearTransform::Parameters::YX));
48 cls.attr(
"XY") = py::cast(int(LinearTransform::Parameters::XY));
49 cls.attr(
"YY") = py::cast(int(LinearTransform::Parameters::YY));
52 cls.def(py::init<>());
53 cls.def(py::init<LinearTransform::Matrix const &>(),
"matrix"_a);
57 py::overload_cast<Point2D const &>(&LinearTransform::operator(), py::const_));
59 py::overload_cast<Extent2D const &>(&LinearTransform::operator(), py::const_));
60 cls.def(
"__getitem__",
61 [](LinearTransform const &self, int i) { return self[utils::python::cppIndex(4, i)]; });
65 return self.getMatrix()(
row,
col);
67 cls.def(
"__mul__", &LinearTransform::operator*, py::is_operator());
68 cls.def(
"__add__", &LinearTransform::operator+, py::is_operator());
69 cls.def(
"__sub__", &LinearTransform::operator-, py::is_operator());
70 cls.def(
"__iadd__", &LinearTransform::operator+=);
71 cls.def(
"__isub__", &LinearTransform::operator-=);
74 cls.def_static(
"makeScaling",
75 py::overload_cast<double>(&LinearTransform::makeScaling),
77 cls.def_static(
"makeScaling",
78 py::overload_cast<double, double>(&LinearTransform::makeScaling));
79 cls.def_static(
"makeRotation",
80 py::overload_cast<Angle>(LinearTransform::makeRotation),
82 cls.def(
"getParameterVector", &LinearTransform::getParameterVector);
84 py::overload_cast<>(& LinearTransform::getMatrix, py::const_));
85 cls.def(
"inverted", &LinearTransform::inverted);
86 cls.def(
"computeDeterminant", &LinearTransform::computeDeterminant);
87 cls.def(
"isIdentity", &LinearTransform::isIdentity);
91 self[LinearTransform::XX] = xx;
92 self[LinearTransform::XY] = xy;
93 self[LinearTransform::YX] = yx;
94 self[LinearTransform::YY] = yy;
96 "xx"_a,
"yx"_a,
"xy"_a,
"yy"_a);
99 return py::str(py::cast(
self.getMatrix()));
102 return py::str(
"LinearTransform(\n{}\n)").format(py::cast(
self.getMatrix()));
105 return py::make_tuple(
cls, py::make_tuple(py::cast(
self.getMatrix())));
std::size_t cppIndex(std::ptrdiff_t size, std::ptrdiff_t i)
Compute a C++ index from a Python index (negative values count from the end) and range-check.
pybind11::module module
The module object passed to the PYBIND11_MODULE block that contains this WrapperCollection.
void wrapLinearTransform(WrapperCollection &wrappers)
A base class for image defects.
A helper class for subdividing pybind11 module across multiple translation units (i.e.
PyType wrapType(PyType cls, ClassWrapperCallback function, bool setModuleName=true)
Add a type (class or enum) wrapper, deferring method and other attribute definitions until finish() i...