Skip to content
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

Cleanup image metadata reading #1252

Closed
wants to merge 6 commits into from

Conversation

p12tic
Copy link
Contributor

@p12tic p12tic commented Oct 1, 2022

This PR removes a couple of functions from mvsData that do the same thing as functions in image module. Additionally, readImageSpec function has been introduced and all functions were redefined in terms of it, which makes them simplier (no need to define additional variables just to satisfy an interface like before). Finally, there is now a way to get whatever attributes needed without writing any more getter functions.

The objective is to have a single place for all metadata access.

The new readImageSpec() function is not strictly necessary. However, there was void readImageSpec(const std::string& path, int& width, int& height, int& nchannels); overload before, so given that nchannels was needed at least at some point in the past, it seems logical to expose the underlying OIIO ImageSpec without restrictions to satisfy similar accesses in the future.

Copy link
Member

@simogasp simogasp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just some constness here and there ;-)

src/aliceVision/fuseCut/Fuser.cpp Outdated Show resolved Hide resolved
src/aliceVision/image/io.cpp Outdated Show resolved Hide resolved
src/aliceVision/image/io.cpp Outdated Show resolved Hide resolved
src/aliceVision/image/io.cpp Outdated Show resolved Hide resolved
src/aliceVision/mvsUtils/MultiViewParams.cpp Outdated Show resolved Hide resolved
src/aliceVision/mvsUtils/fileIO.cpp Outdated Show resolved Hide resolved
src/aliceVision/sfmDataIO/viewIO.cpp Outdated Show resolved Hide resolved
src/samples/texturing/main_evcorrection.cpp Outdated Show resolved Hide resolved
@p12tic
Copy link
Contributor Author

p12tic commented Oct 1, 2022

Addressed constness comments. It would have been enough to point just one case and add "and elsewhere", I would have fixed all occurrences.

About constness itself, personally I don't like splattering const to local non-reference non-pointer variables, because it prevents few bugs, yet leads to real issues down the road. For example, const auto x = ...; return x; - const here forbids compiler to use move-constructor for the return value. If x is of expensive type then the code will be unnecessarily slower. In cases of virtual functions, const arguments forces the overriding functions to copy variables in case modification was sensible in that particular overriding function. And overall, too much const causes visual clutter. Const pointer must become const T* const x for consistency and so on.

But I understand why you would like to have const everywhere as a matter of policy, so feel free to disregard my comment :-) I will try to use const more in subsequent PRs.

This function performs the same thing as image::getMetadataFromMap().
@fabiencastan
Copy link
Member

IMO, const helps readability. Each declaration without a const means that it will be modified, that's very useful to quickly read an algorithm.

I like the simplification that this PR is providing! Just need to see if it's not a problem to start creating dependencies between "mvsData/mvsUtils" and "image". When we fuse the image duplication, we will obviously have this dependency. In the meantime, I'm not sure if it's good to create dependencies between modules that contain duplicates.
I would be more confident to do the move in one PR to avoid the indermediate status, that is worse than the current one.
Or if we are sure that we have the bandwidth to do the larger change quickly. But we also have the problem of the depthmap branch that will not be ready before 3 weeks.

@p12tic
Copy link
Contributor Author

p12tic commented Oct 2, 2022

IMO, const helps readability. Each declaration without a const means that it will be modified, that's very useful to quickly read an algorithm.

Fair enough.

I'm not sure if it's good to create dependencies between modules that contain duplicates. I would be more confident to do the move in one PR to avoid the indermediate status, that is worse than the current one.

I think I can perform the refactor without introducing worse intermediate status.

In this particular case there are no real duplicates, the functions are all named differently or in different namespaces, except that they do similar things. So looking from C++ code perspective there is no risk.

I have fixed all real duplicate symbols when preparing #1208.

@p12tic
Copy link
Contributor Author

p12tic commented Oct 2, 2022

I will prepare a single PR with all changes.

@p12tic p12tic closed this Oct 2, 2022
@p12tic p12tic deleted the cleanup-image-metadata-io branch October 2, 2022 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants