| 71 | } |
| 72 | |
| 73 | void ExportImageFormat(py::module &m) |
| 74 | { |
| 75 | py::enum_<nvcv::ImageFormat> fmt(m, "Format"); |
| 76 | |
| 77 | #define DEF(F) fmt.value(#F, nvcv::FMT_##F); |
| 78 | // for formats that begin with a number, we must prepend it with underscore to make |
| 79 | // it a valid python identifier |
| 80 | #define DEF_NUM(F) fmt.value("_" #F, nvcv::FMT_##F); |
| 81 | |
| 82 | #include "NVCVPythonImageFormatDefs.inc" |
| 83 | |
| 84 | #undef DEF |
| 85 | #undef DEF_NUM |
| 86 | |
| 87 | fmt.export_values() |
| 88 | .def_property_readonly("planes", &nvcv::ImageFormat::numPlanes, |
| 89 | "Read-only property that returns the number of planes in the image") |
| 90 | .def_property_readonly("channels", &nvcv::ImageFormat::numChannels, |
| 91 | "Read-only property that returns the number of color channels in the image"); |
| 92 | |
| 93 | // Need to do this way because pybind11 doesn't allow enums to have methods. |
| 94 | fmt.attr("__repr__") = py::cpp_function(&ImageFormatToString, py::name("__repr__"), py::is_method(fmt), |
| 95 | "String representation of the image format."); |
| 96 | } |
| 97 | |
| 98 | } // namespace nvcvpy::priv |