-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Fix model_cropper not resetting image.num_points3D of cropped_rec #2557
Conversation
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.
Thanks for the fix. Small suggestions for consistency in the code base.
src/colmap/scene/reconstruction.cc
Outdated
@@ -452,8 +452,8 @@ Reconstruction Reconstruction::Crop( | |||
for (const auto& image : images_) { | |||
auto new_image = image.second; | |||
new_image.SetRegistered(false); | |||
for (auto& point2D : new_image.Points2D()) { | |||
point2D.point3D_id = kInvalidPoint3DId; | |||
for (point2D_t pid = 0; pid < new_image.NumPoints2D(); ++pid) { |
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.
for (point2D_t pid = 0; pid < new_image.NumPoints2D(); ++pid) { | |
const num_points2D = new_image.NumPoints2D(); | |
for (point2D_t point2D_idx = 0; point2D_idx < num_points2D; ++point2D_idx) { |
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.
Added with type specifier in 6f716b8
src/colmap/scene/reconstruction.cc
Outdated
for (auto& point2D : new_image.Points2D()) { | ||
point2D.point3D_id = kInvalidPoint3DId; | ||
for (point2D_t pid = 0; pid < new_image.NumPoints2D(); ++pid) { | ||
new_image.ResetPoint3DForPoint2D(pid); |
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.
new_image.ResetPoint3DForPoint2D(pid); | |
new_image.ResetPoint3DForPoint2D(p oint2D_idx); |
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.
Changed and removed white space in 6f716b8
While investigating the model_splitter issue for the current revision 1f95f3e described in #2096 I found a code regression introduced with commit 67029ad
This affects model_cropper and model_splitter tools.
As the previous implementation used the Image::ResetPoint3DForPoint2D method inside the loop, the num_points3D member was reset to 0 correctly.
colmap/src/colmap/scene/image.cc
Lines 97 to 103 in 1f95f3e
When directly assigning the kInvalidPoint3DId value, new_image keeps the value of the source num_points3D representing an incorrect state of the newly created cropped_reconstruction and finally leads to a failing check at
colmap/src/colmap/scene/reconstruction.cc
Line 184 in 1f95f3e
Fixing this by adding the call to Image::ResetPoint3DForPoint2D inside the loop again as it was first implemented in 99c7904.
Debugger screenshots:
Current Revision 1f95f3e :
Old implementation: