-
Notifications
You must be signed in to change notification settings - Fork 767
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
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.
LGTM though it would be nice to have methods to set/get those values. Perhaps put in the default values in the constructor?
gtsam/slam/dataset.h
Outdated
@@ -221,7 +221,7 @@ struct SfmTrack { | |||
SfmTrack(): p(0,0,0) {} | |||
SfmTrack(const gtsam::Point3& pt) : p(pt) {} |
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.
@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
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.
perhaps unsigned char
is more appropriate?
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.
size_t
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.
Actually keeping it float makes sense in case the values aren't in the 0-255 range.
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 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?
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.
totally fair, good points
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.
@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.
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.
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.
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.
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) {} |
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.
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.
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 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?
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 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.
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.
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.
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.
Got it, thanks
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.
Ah you're right. My mistake.
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.
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) {} |
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.
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.
keeping current variable names since struct not class
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.