MCPcopy Create free account
hub / github.com/CVCUDA/CV-CUDA / ExportImageFormat

Function ExportImageFormat

python/mod_cvcuda/nvcv/ImageFormat.cpp:73–96  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71}
72
73void 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

Callers 1

PYBIND11_MODULEFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected