Introduced pattern class

This commit is contained in:
Erik Frojdh
2020-11-27 10:03:15 +01:00
parent 8ca1d9c50c
commit d9b2a90651
22 changed files with 384 additions and 118 deletions

42
python/src/pattern.cpp Normal file
View File

@ -0,0 +1,42 @@
#include <pybind11/chrono.h>
#include <pybind11/numpy.h>
#include <pybind11/operators.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include "sls/Pattern.h"
#include "sls/sls_detector_defs.h"
namespace py = pybind11;
void init_pattern(py::module &m) {
using pat = sls::patternParameters;
py::class_<pat> patternParameters(m, "patternParameters");
PYBIND11_NUMPY_DTYPE(pat, word, ioctrl, limits, loop, nloop, wait,
waittime);
patternParameters.def(py::init());
patternParameters.def("numpy_view", [](py::object &obj) {
pat &o = obj.cast<pat &>();
return py::array_t<pat>(1, &o, obj);
});
// m.def("get_memoryview1d", []() {
// return py::memoryview::from_memory(
// buffer, // buffer pointer
// sizeof(uint8_t) * 8 // buffer size
// );
// })
// patternParameters.def("load", &pat::load);
py::class_<sls::Pattern> Pattern(m, "Pattern");
Pattern.def(py::init());
Pattern.def("load", &sls::Pattern::load);
Pattern.def("data", (pat * (sls::Pattern::*)()) & sls::Pattern::data, py::return_value_policy::reference);
// m.def("get_memoryview1d", []() {
// return py::memoryview::from_memory(data(), // buffer pointer
// sizeof(pat) // buffer size
// );
// });
}