-
Notifications
You must be signed in to change notification settings - Fork 398
Fix Python Interfaces For Image Loaders #2541
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Fix Python Interfaces For Image Loaders #2541
Conversation
- Sample OIIO Loader test added.
@@ -10,11 +10,18 @@ | |||
namespace py = pybind11; | |||
namespace mx = MaterialX; | |||
|
|||
uintptr_t getResourceBuffer(const mx::Image& image) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cannot pass back and forth void pointers for buffer data.
Add a concrete type to wrap.
@@ -18,7 +18,39 @@ void bindPyImageHandler(py::module& mod) | |||
.def_readwrite("filterType", &mx::ImageSamplingProperties::filterType) | |||
.def_readwrite("defaultColor", &mx::ImageSamplingProperties::defaultColor); | |||
|
|||
py::class_<mx::ImageLoader, mx::ImageLoaderPtr>(mod, "ImageLoader") | |||
// Trampoline class for Python overrides |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this glue code was not added, Python loader code would never be called.
void bindPyImage(py::module& mod) | ||
{ | ||
py::enum_<mx::Image::BaseType>(mod, "BaseType") | ||
.value("UINT8", mx::Image::BaseType::UINT8) | ||
.value("INT8", mx::Image::BaseType::INT8) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add missing types.
@@ -0,0 +1,429 @@ | |||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sample code which works for EXR and other image types.
Updates
Tests
ImageHander
interfaceaquireImage
which will check extensions EXR is not by default supported so will find the sample OIIO loaderloadImage
override. Also displays the image usingmatplotlib
if availableImage
is cached in memory after load.saveImage
on theImageHandler
passing the MaterialXImage
which will again check extensions and call back to the OIIO loader.saveImage
override. Also displays the imsage usingmatplotlib
if available.Results:
Possible Integration
This is a possible integration where the loader is used inside of the Graph Editor. Two format not supported by default but available via OIIO shown: EXR and WEBP