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

Adding default point color to SfmTrack to fix equality check #659

Merged
merged 15 commits into from
Jan 7, 2021

Conversation

ayushbaid
Copy link
Contributor

The equals method fails right now when we run bundle adjustment on the same input twice. I checked that all the 2D measurements and 3d point match, but the color comparison fails.

Adding a default value fixes the comparison.

@ayushbaid ayushbaid added bugfix Fixes an issue or bug easy-fix Quick and easy to fix quick-review Quick and easy PR to review labels Jan 6, 2021
Copy link
Collaborator

@varunagrawal varunagrawal left a comment

Choose a reason for hiding this comment

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

LGTM though it would be nice to have methods to set/get those values. Perhaps put in the default values in the constructor?

@@ -221,7 +221,7 @@ struct SfmTrack {
SfmTrack(): p(0,0,0) {}
SfmTrack(const gtsam::Point3& pt) : p(pt) {}
Copy link
Contributor

@johnwlambert johnwlambert Jan 6, 2021

Choose a reason for hiding this comment

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

@varunagrawal @ayushbaid @dellaert perhaps we should do

SfmTrack(float r = 0, float g = 0, float b = 0): p(0,0,0), r(r), g(g), b(b) {}
SfmTrack(const gtsam::Point3& pt, float r = 0, float g = 0, float b = 0) : p(pt), r(r), g(g), b(b) {}

so we can use the RGB values later in rendering?
I'm confused why the r, g, b attributes are float in the class, instead of uint8

Copy link
Contributor

Choose a reason for hiding this comment

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

perhaps unsigned char is more appropriate?

Copy link
Collaborator

Choose a reason for hiding this comment

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

size_t

Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually keeping it float makes sense in case the values aren't in the 0-255 range.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would say it's probably better to rethink this a bit: what if the image is 12bit per channel? What if the input is grayscale? What are the implications of assuming 8bit RGB?

Copy link
Contributor

Choose a reason for hiding this comment

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

totally fair, good points

Copy link
Contributor

Choose a reason for hiding this comment

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

@ProfFan maybe we can discuss this a bit more -- I do think that 8bit is much more common for our use cases in GTSAM and GTSFM, and I also think that if the input is grayscale, they wouldn't use the RGB attributes in the first place. And I think this attribute is purely for 3d point cloud visualization purposes, and I don't think grayscale values would contribute meaningfully to a 3d visualization.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree with John. As this is just used for visualization, we can just stick with float R, G, B values, normalized to [0, 1] range.

Copy link
Collaborator

@varunagrawal varunagrawal left a comment

Choose a reason for hiding this comment

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

Some minor things to complete this PR.

SfmTrack(): p(0,0,0) {}
SfmTrack(const gtsam::Point3& pt) : p(pt) {}
SfmTrack(float r = 0, float g = 0, float b = 0): p(0,0,0), r(r), g(g), b(b) {}
SfmTrack(const gtsam::Point3& pt, float r = 0, float g = 0, float b = 0) : p(pt), r(r), g(g), b(b) {}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Formatting please. Also, a good convention is to have struct/class variables be something like r_ and then have the initializer list be r_(r). This is consistent with Google C++ style which we follow.

Copy link
Contributor

Choose a reason for hiding this comment

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

I like the style suggestion, but this would involve renaming all of the variables in the class, since none adhere to that guideline. @dellaert would you like to see a big change like that?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would vote for it since due to the previous lack of getters, it won't be an API change, so we should be able to maintain backwards compatibility.

Copy link
Member

Choose a reason for hiding this comment

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

Actually, for classes the convention is underscore, for structs it is not (and should not).
It is an API change as these fields are public.

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it, thanks

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah you're right. My mistake.

gtsam/slam/dataset.h Show resolved Hide resolved
Copy link
Member

@dellaert dellaert left a comment

Choose a reason for hiding this comment

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

Approving without the name change for the fields.

SfmTrack(): p(0,0,0) {}
SfmTrack(const gtsam::Point3& pt) : p(pt) {}
SfmTrack(float r = 0, float g = 0, float b = 0): p(0,0,0), r(r), g(g), b(b) {}
SfmTrack(const gtsam::Point3& pt, float r = 0, float g = 0, float b = 0) : p(pt), r(r), g(g), b(b) {}
Copy link
Member

Choose a reason for hiding this comment

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

Actually, for classes the convention is underscore, for structs it is not (and should not).
It is an API change as these fields are public.

@johnwlambert johnwlambert dismissed varunagrawal’s stale review January 7, 2021 16:44

keeping current variable names since struct not class

@johnwlambert johnwlambert merged commit 442cc6d into develop Jan 7, 2021
@johnwlambert johnwlambert deleted the fix/sfmtrack-color branch January 7, 2021 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Fixes an issue or bug easy-fix Quick and easy to fix quick-review Quick and easy PR to review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants