-
-
Notifications
You must be signed in to change notification settings - Fork 207
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
Feature/1187 Read EXR files from memory #1448
base: master
Are you sure you want to change the base?
Feature/1187 Read EXR files from memory #1448
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1448 +/- ##
========================================
Coverage 96.64% 96.65%
========================================
Files 103 105 +2
Lines 7756 7861 +105
========================================
+ Hits 7496 7598 +102
- Misses 260 263 +3 ☔ View full report in Codecov by Sentry. |
#include <vector> | ||
/** | ||
* image file taken from | ||
* https://github.com/AcademySoftwareFoundation/openexr/blob/370db2835843ac75f85e1386c05455f26a6ff58c/website/test_images/Chromaticities/Rec709.rst |
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.
im not sure how that .rst file is related to the .exr file ?
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.
the rst file is just a markdown file on github showing the exr file and it details. I just grabbed it because it was smaller than the other exr files in the repo which made the unit test run a but faster.
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.
I think it would be better to just use an existing one. grayscale.exr
for example is very small.
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.
indeed, better to use an existing one.
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.
you can remove this line, since you list it in data licenses now.
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.
please remove this line
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.
Here are some comments. But overall that looks good.
#include <vector> | ||
/** | ||
* image file taken from | ||
* https://github.com/AcademySoftwareFoundation/openexr/blob/370db2835843ac75f85e1386c05455f26a6ff58c/website/test_images/Chromaticities/Rec709.rst |
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.
I think it would be better to just use an existing one. grayscale.exr
for example is very small.
@Meakk I tried using grayscale.exr but i get the following errors Error reading EXR file: only RGB and RGBA channels are supported (im not sure why but i couldn't reply to your original message in the thread) |
Ok fair enough. Let's use your image then, but please double check the license and add it in |
Small change required for cppcheck job:
|
*/ | ||
uint64_t tellg() override | ||
{ | ||
return pos; |
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.
Why isn't this line covered? Do we need to override this function if it's not called?
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.
from this page
https://openexr.com/en/latest/ReadingAndWritingImageFiles.html#low-level-i-o
it seems like that function needs to be overriden to be a proper interface
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.
not sure to follow that answer
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.
if that method is not used you can just remove it ?
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.
it is a pure virtual function in the base class so i believe it needs an implementation. I can try removing it and see what happens. In the documentation i posted it says it needs an implementation.
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.
ok lets try that. Maybe its needed in some case, but not in our case.
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.
it does not build without that function being implemented
error: cannot declare variable ‘memoryStream’ to be of abstract type ‘MemStream’
198 | MemStream memoryStream("EXRmemoryStream", this->MemoryBuffer, this->MemoryBufferLength);
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.
ok, lets keep it in for now.
please rebase on master |
: Imf::IStream(name) | ||
, buffer(static_cast<const char*>(buff)) | ||
, bufflen(static_cast<size_t>(bufferLen)) | ||
, pos(0) |
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.
you can remove this line
@@ -38,13 +88,15 @@ void vtkF3DEXRReader::ExecuteInformation() | |||
this->ComputeInternalFileName(this->DataExtent[4]); | |||
if (this->InternalFileName == nullptr || this->InternalFileName[0] == '\0') | |||
{ | |||
return; | |||
// If we have no file then maybe we have the file in memory | |||
if (!this->MemoryBuffer) |
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.
can you put this check in the line above ?
|
||
try | ||
{ | ||
assert(this->InternalFileName); |
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.
i think this assert should not be here for the memory stream part. BTW it may be better to make it an actual if test since we now can have an empty InteralFileName, I think.
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.
Yes when loading a USD scene the EXRReader will have an empty filename. Interestingly in the test case TestF3DEXRMemReader, If i omit the filename on line 33 I get an error in vtkImageReader2.cxx:111 for not setting a filename.
*/ | ||
void vtkF3DEXRReader::SetMemoryBuffer(const void* buff) | ||
{ | ||
MemoryBuffer = buff; |
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.
this->MemoryBuffer
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.
this is the mother class implementation, why not just rely on it instead of defining your own ?
void vtkImageReader2::SetMemoryBuffer(const void* membuf)
{
if (this->MemoryBuffer != membuf)
{
this->MemoryBuffer = membuf;
this->Modified();
}
}
//------------------------------------------------------------------------------
void vtkImageReader2::SetMemoryBufferLength(vtkIdType buflen)
{
if (this->MemoryBufferLength != buflen)
{
this->MemoryBufferLength = buflen;
this->Modified();
}
}
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.
I used this for debugging, it can now be removed.
@@ -53,6 +53,7 @@ | |||
- world*: VTK Data: BSD-3-Clause | |||
- 16bits.*: @bisechen: [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | |||
- (ノಠ益ಠ )ノ.vtp: VTK Data: BSD-3-Clause | |||
- Rec709.exr: [Copyright 2006 Industrial Light & Magic](https://github.com/AcademySoftwareFoundation/openexr/blob/370db2835843ac75f85e1386c05455f26a6ff58c/website/test_images/Chromaticities/Rec709.rst): BSD-3-Clause |
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.
please also add `small.usdz: Copyright USD contributors: CC-BY 4.0
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.
with the links please
@@ -212,6 +207,10 @@ void vtkF3DEXRReader::ExecuteDataWithInformation(vtkDataObject* output, vtkInfor | |||
} | |||
else | |||
{ | |||
if (!(this->InternalFileName)) | |||
{ | |||
throw std::invalid_argument("Not filename in EXR Reader when no Memory Buffer is set."); |
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.
can this happen ?
Do you really need to throw here ? you could just error out ?
hey @nabielkandiel , need any help moving forward ? |
Issue for reference
#1187
Below is an image of what currently happens when reading a .usda file in f3d
This is what it looks like on this branch
file is pulled from here
https://github.com/mwestphal/assets/tree/main/full_assets/StandardShaderBall
Please note you have to change some options in the cmake build files to enable USD and EXR
CMakeLists.txt
line 58 turn on module_exr
plugins/CMakeLists.txt
line 6 turn on build_usd
MemStream is a private class created inside F3DEXRReader, this is needed as Imf::RgbaInputFile needs an input that has stream like functionality or is derived from Imf::IStream
https://openexr.com/en/latest/ReadingAndWritingImageFiles.html#low-level-i-o
I'm not sure if this is the best design choice to have it be a private class, i can change that if desired but im not sure if any other class is going to need to use this functionality.