25 #include <pybind11/pybind11.h>
26 #include <pybind11/numpy.h>
28 namespace py = pybind11;
35 if (tuple.size() != 2)
36 throw std::invalid_argument(
"Expected a tuple of 2 elements");
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>());
50 return py::make_tuple(point.
x, point.
y);
55 return py::make_tuple(rectangle.
a.x, rectangle.
a.y, rectangle.
b.x, rectangle.
b.y);
60 return py::make_tuple(
67 return py::make_tuple(color.
r, color.
g, color.
b);
71 return py::make_tuple(color.
r, color.
g, color.
b, color.
a);
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>());
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>() };
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>() };
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>() };
2D affine transformation.
2D rectangle class All the utilities assume that the rectangle is normalized, e.g.
Abstract neural net operation (layer).
py::tuple toTuple(const CustomPoint< T > &point)
color4f toColor4f(const py::tuple &tuple)
color4i toColor4i(const py::tuple &tuple)
pixfloat4 toPixfloat4(const py::tuple &tuple)
color3f toColor3f(const py::tuple &tuple)
py::object getModelOutputDataByOp(NNets::Model &model, const NNets::AbstractOperation &operation, int output)
CustomRectangle< T > toRectangle(const py::tuple &tuple)
py::object getModelOutputDataByName(NNets::Model &model, const std::string &opName, int output)
CustomPoint< T > toPoint(const py::tuple &tuple)
4-channel floating point arithmetic
JNIEnv jlong jobject jstring opName