| 1101 | } |
| 1102 | |
| 1103 | void Image::Export(py::module &m) |
| 1104 | { |
| 1105 | using namespace py::literals; |
| 1106 | |
| 1107 | py::class_<Image, std::shared_ptr<Image>, Container>(m, "Image", "Image") |
| 1108 | .def(py::init(&Image::Create), "size"_a, "format"_a, "rowalign"_a = 0, |
| 1109 | "Constructor that takes a size, format and optional row align of the image") |
| 1110 | .def(py::init(&Image::CreateHost), "buffer"_a, "format"_a = nvcv::FMT_NONE, "rowalign"_a = 0, |
| 1111 | "Constructor that takes a host buffer, format and optional row align") |
| 1112 | .def(py::init(&Image::CreateHostVector), "buffer"_a, "format"_a = nvcv::FMT_NONE, "rowalign"_a = 0, |
| 1113 | "Constructor that takes a host buffer vector, format and optional row align") |
| 1114 | .def_static("zeros", &Image::Zeros, "size"_a, "format"_a, "rowalign"_a = 0, |
| 1115 | "Create an image filled with zeros with a given size, format and optional row align") |
| 1116 | .def("__repr__", &util::ToString<Image>) |
| 1117 | .def("cuda", &Image::cuda, "layout"_a = std::nullopt, "The image on the CUDA device") |
| 1118 | .def("cpu", &Image::cpu, "layout"_a = std::nullopt, "The image on the CPU") |
| 1119 | .def_property_readonly("size", &Image::size, "Read-only property that returns the size of the image") |
| 1120 | .def_property_readonly("width", &Image::width, "Read-only property that returns the width of the image") |
| 1121 | .def_property_readonly("height", &Image::height, "Read-only property that returns the height of the image") |
| 1122 | .def_property_readonly("format", &Image::format, "Read-only property that returns the format of the image"); |
| 1123 | |
| 1124 | // Make sure buffer lifetime is tied to image's (keep_alive) |
| 1125 | m.def("as_image", &Image::WrapExternalBuffer, "buffer"_a, "format"_a = nvcv::FMT_NONE, py::keep_alive<0, 1>(), |
| 1126 | "Wrap an external buffer as an image and tie the buffer lifetime to the image"); |
| 1127 | m.def("as_image", &Image::WrapExternalBufferVector, py::arg_v("buffer", std::vector<py::object>{}), |
| 1128 | "format"_a = nvcv::FMT_NONE, py::keep_alive<0, 1>(), |
| 1129 | "Wrap a vector of external buffers as an image and tie the buffer lifetime to the image"); |
| 1130 | } |
| 1131 | |
| 1132 | } // namespace nvcvpy::priv |
nothing calls this directly
no outgoing calls
no test coverage detected