Python binding utilities
More...
◆ toPoint()
template<typename T >
CustomPoint<T> Beatmup::Python::toPoint |
( |
const py::tuple & |
tuple | ) |
|
|
inline |
Definition at line 34 of file binding_tools.hpp.
35 if (tuple.size() != 2)
36 throw std::invalid_argument(
"Expected a tuple of 2 elements");
37 return CustomPoint<T>(tuple[0].cast<T>(), tuple[1].cast<T>());
◆ toRectangle()
Definition at line 41 of file binding_tools.hpp.
42 if (tuple.size() != 4)
43 throw std::invalid_argument(
"Expected a tuple of 4 elements");
44 return CustomRectangle<T>(tuple[0].cast<T>(), tuple[1].cast<T>(), tuple[2].cast<T>(), tuple[3].cast<T>());
◆ toTuple() [1/5]
template<typename T >
py::tuple Beatmup::Python::toTuple |
( |
const CustomPoint< T > & |
point | ) |
|
|
inline |
◆ toTuple() [2/5]
template<typename T >
py::tuple Beatmup::Python::toTuple |
( |
const CustomRectangle< T > & |
rectangle | ) |
|
|
inline |
Definition at line 54 of file binding_tools.hpp.
55 return py::make_tuple(rectangle.a.x, rectangle.a.y, rectangle.b.x, rectangle.b.y);
◆ toTuple() [3/5]
template<typename T >
py::tuple Beatmup::Python::toTuple |
( |
const CustomMatrix2< T > & |
matrix | ) |
|
|
inline |
Definition at line 59 of file binding_tools.hpp.
60 return py::make_tuple(
61 py::make_tuple(matrix.getA11(), matrix.getA12()),
62 py::make_tuple(matrix.getA21(), matrix.getA22())
◆ toTuple() [4/5]
py::tuple Beatmup::Python::toTuple |
( |
const color3f & |
color | ) |
|
|
inline |
Definition at line 66 of file binding_tools.hpp.
67 return py::make_tuple(color.r, color.g, color.b);
◆ toTuple() [5/5]
py::tuple Beatmup::Python::toTuple |
( |
const color4i & |
color | ) |
|
|
inline |
Definition at line 70 of file binding_tools.hpp.
71 return py::make_tuple(color.r, color.g, color.b, color.a);
◆ toPixfloat4()
pixfloat4 Beatmup::Python::toPixfloat4 |
( |
const py::tuple & |
tuple | ) |
|
|
inline |
Definition at line 74 of file binding_tools.hpp.
75 if (tuple.size() != 4)
76 throw std::invalid_argument(
"Expected a tuple of 4 elements");
77 return pixfloat4(tuple[0].cast<float>(), tuple[1].cast<float>(), tuple[2].cast<float>(), tuple[3].cast<float>());
◆ toColor3f()
color3f Beatmup::Python::toColor3f |
( |
const py::tuple & |
tuple | ) |
|
|
inline |
Definition at line 80 of file binding_tools.hpp.
81 if (tuple.size() != 3)
82 throw std::invalid_argument(
"Expected a tuple of 3 elements");
83 return color3f{ tuple[0].cast<
float>(), tuple[1].cast<float>(), tuple[2].cast<
float>() };
◆ toColor4f()
color4f Beatmup::Python::toColor4f |
( |
const py::tuple & |
tuple | ) |
|
|
inline |
Definition at line 86 of file binding_tools.hpp.
87 if (tuple.size() != 4)
88 throw std::invalid_argument(
"Expected a tuple of 4 elements");
89 return color4f{ tuple[0].cast<
float>(), tuple[1].cast<float>(), tuple[2].cast<
float>(), tuple[3].cast<float>() };
◆ toColor4i()
color4i Beatmup::Python::toColor4i |
( |
const py::tuple & |
tuple | ) |
|
|
inline |
Definition at line 92 of file binding_tools.hpp.
93 if (tuple.size() != 4)
94 throw std::invalid_argument(
"Expected a tuple of 4 elements");
95 return color4i{ tuple[0].cast<uint8_t>(), tuple[1].cast<uint8_t>(), tuple[2].cast<uint8_t>(), tuple[3].cast<uint8_t>() };
◆ getModelOutputDataByName()
py::object Beatmup::Python::getModelOutputDataByName |
( |
NNets::Model & |
model, |
|
|
const std::string & |
opName, |
|
|
int |
output |
|
) |
| |
Definition at line 40 of file binding_tools.cpp.
py::object getModelOutputDataByOp(NNets::Model &model, const NNets::AbstractOperation &operation, int output)
JNIEnv jlong jobject jstring opName
◆ getModelOutputDataByOp()
Definition at line 22 of file binding_tools.cpp.
24 auto data = model.getOutputData(numSamples, operation, output);
25 auto size = operation.getOutputSize(output);
30 return py::array_t<float>({
size[1] }, {
sizeof(float) }, data);
32 return py::array_t<float>(
34 {
size[0] *
size[2] *
sizeof(float),
size[2] *
sizeof(
float),
sizeof(float) },