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

[sfm] Reduce code duplication in sequential sfm triangulation #1217

Merged
merged 1 commit into from
Sep 29, 2022

Conversation

p12tic
Copy link
Contributor

@p12tic p12tic commented Sep 10, 2022

This PR includes a relatively simple and small refactor.

The current code recomputes the same source data for both 2 and N observation cases. Due to the code being structured differently it's hard to see that in both cases a lot of the same operations are being performed. By extracting the code into separate function we make this fact explicit.

@p12tic
Copy link
Contributor Author

p12tic commented Sep 10, 2022

Unrelated question: I saw a lot of code added with 2-space style indentation as well as 4-space style indentation. Is any of these preferred and new code should be written in that style with the intention that whole codebase will be migrated eventually?

@fabiencastan
Copy link
Member

Yes that's the idea, new code should be 4-space style.

@fabiencastan
Copy link
Member

What's the status?

@fabiencastan
Copy link
Member

@p12tic Could you have a look to Simone's review?

@p12tic
Copy link
Contributor Author

p12tic commented Sep 29, 2022

@fabiencastan Sorry for taking so long to address the issues. Everything is fixed now.


if (!camPinHole) {
ALICEVISION_LOG_ERROR("Camera is not pinhole in triangulate_multiViewsLORANSAC");
return {nullptr, nullptr, {}, {}, {}, {}};
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return {nullptr, nullptr, {}, {}, {}, {}};
return {nullptr, {}, {}, {}, {}};

as the raw pointer has been removed.

I was also wondering if it'd be worth it to have a method isEmpty(){return cam == nullptr} in ObservationData so that it is easier to test the result. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, didn't commit everything. I agree about new method.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed now. I also changed indentation of new code.

@p12tic p12tic force-pushed the sequential-sfm-duplication branch 2 times, most recently from ee9544b to d17f870 Compare September 29, 2022 09:16
The current code recomputes the same source data for both 2 and N
observation cases. Due to the code being structured differently it's
hard to see that in both cases the same operations are being performed.
By extracting the code into separate function we make this fact
explicit.
@simogasp simogasp added this to the 2.6.0 milestone Sep 29, 2022
@fabiencastan fabiencastan modified the milestones: 2.6.0, 2.5.0 Sep 29, 2022
@fabiencastan fabiencastan merged commit 741c2dd into alicevision:develop Sep 29, 2022
@p12tic p12tic deleted the sequential-sfm-duplication branch October 1, 2022 11:54
@fabiencastan fabiencastan changed the title [sfm] Reduce code duplication in sequantial sfm triangulation [sfm] Reduce code duplication in sequential sfm triangulation Mar 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants