23 #include "pybind11/pybind11.h"
33 using namespace pybind11::literals;
41 using PyCentroidAlgorithm =
42 py::class_<NaiveCentroidAlgorithm, std::shared_ptr<NaiveCentroidAlgorithm>, SimpleAlgorithm>;
43 using PyCentroidControl = py::class_<NaiveCentroidControl>;
44 using PyCentroidTransform =
45 py::class_<NaiveCentroidTransform, std::shared_ptr<NaiveCentroidTransform>, CentroidTransform>;
47 PyCentroidControl declareCentroidControl(
py::module &mod) {
48 PyCentroidControl
cls(mod,
"NaiveCentroidControl");
50 cls.def(py::init<>());
59 PyCentroidAlgorithm declareCentroidAlgorithm(
py::module &mod) {
60 PyCentroidAlgorithm
cls(mod,
"NaiveCentroidAlgorithm");
62 cls.attr(
"FAILURE") = py::cast(NaiveCentroidAlgorithm::FAILURE);
63 cls.attr(
"NO_COUNTS") = py::cast(NaiveCentroidAlgorithm::NO_COUNTS);
64 cls.attr(
"EDGE") = py::cast(NaiveCentroidAlgorithm::EDGE);
66 cls.def(py::init<NaiveCentroidAlgorithm::Control const &, std::string const &, afw::table::Schema &>(),
67 "ctrl"_a,
"name"_a,
"schema"_a);
70 cls.def(
"fail", &NaiveCentroidAlgorithm::fail,
"measRecord"_a,
"error"_a =
nullptr);
75 PyCentroidTransform declareCentroidTransform(
py::module &mod) {
76 PyCentroidTransform
cls(mod,
"NaiveCentroidTransform");
79 afw::table::SchemaMapper &>(),
80 "ctrl"_a,
"name"_a,
"mapper"_a);
88 py::module::import(
"lsst.afw.table");
89 py::module::import(
"lsst.meas.base.algorithm");
90 py::module::import(
"lsst.meas.base.flagHandler");
91 py::module::import(
"lsst.meas.base.transform");
93 auto clsCentroidControl = declareCentroidControl(mod);
94 auto clsCentroidAlgorithm = declareCentroidAlgorithm(mod);
95 auto clsCentroidTransform = declareCentroidTransform(mod);
97 clsCentroidAlgorithm.attr(
"Control") = clsCentroidControl;
98 clsCentroidTransform.attr(
"Control") = clsCentroidControl;
100 python::declareAlgorithm<NaiveCentroidAlgorithm, NaiveCentroidControl, NaiveCentroidTransform>(
101 clsCentroidAlgorithm, clsCentroidControl, clsCentroidTransform);