-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Frame callbacks #160
Frame callbacks #160
Conversation
1a9223e
to
879eb59
Compare
void BaseNodelet::setStreams() | ||
{ | ||
// Enable streams | ||
for (int stream=0; stream < STREAM_COUNT; stream++) |
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.
Change the type of stream to be type 'rs_stream' and remove the casts.
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.
Since STREAM_COUNT is an int, I can't change stream to an rs_stream type. Instead, I'm using static_cast<rs_stream>(stream) to pass the stream var.
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.
Why not cast STREAM_COUNT once instead of stream twice?
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.
Or can we change STREAM_COUNT to a rs_stream type?
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.
No ++ operator is defined for the enum type rs_stream, so you get this compiler error:
error: no ‘operator++(int)’ declared for postfix ‘++’ [-fpermissive]
for (rs_stream stream; stream < (rs_stream) STREAM_COUNT; stream++)
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.
We cant change STREAM_COUNT to an rs_stream type, since we are setting the value to 5 in constants.h. I would like us to actually remove the constant in a future patch and do this a different way, as I agree this is non-ideal. I would prefer a member variable num_streams_ that isn't hard-coded and varies depending on the camera type, set in the onInit() function for each type to the correct value for that camera. But that's another patch for another day.
image_depth16_ = reinterpret_cast<const uint16_t *>(rs_get_frame_data(rs_device_, stream_index, 0)); | ||
if (depth_scale_meters_ == MILLIMETER_METERS) | ||
image_depth16_ = reinterpret_cast<const uint16_t *>(frame.get_data()); | ||
float depth_scale_meters = rs_get_device_depth_scale(rs_device_, &rs_error_); |
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.
Should this function be called in here? getStreamData is called the most frequently in the code.
Can we initialize this something else? Or make it a local static and initialize it once.
At a minimum we need to add a check error for the rs_error_
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.
The value rs_get_device_depth_scale returns is device.config.depth_scale a member variable in the rs_device_ object. Do you still think it's an issue?
|
||
publishTopics(); | ||
if (rs_is_stream_enabled(rs_device_, (rs_stream) stream_index, 0) == 1) |
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.
Since we are called by the callback, we have to be enabled. We should remove this check.
virtual void publishTopic(rs_stream stream_index); | ||
virtual void getStreamData(rs_stream stream_index); | ||
virtual void publishTopic(rs_stream stream_index, rs::frame & frame); | ||
virtual void getStreamData(rs_stream stream_index, rs::frame & frame); |
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.
Rename to setImageData
@@ -724,81 +726,94 @@ namespace realsense_camera | |||
/* | |||
* Copy frame data from realsense to member cv images. | |||
*/ | |||
void BaseNodelet::getStreamData(rs_stream stream_index) | |||
void BaseNodelet::getStreamData(rs_stream stream_index, rs::frame & frame) |
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.
Rename to setImageData
8aa11da
to
a68ed0c
Compare
I squashed the commits down to 6, this is ready for final review and approval. |
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.
Previous discussion items implemented.
LGTM 👍
a68ed0c
to
6112978
Compare
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.
Approved
Please ensure the above guidelines for contributing are met.
Fixes Issue: #
Changes proposed in this pull request: