Skip to content

Commit

Permalink
Merge pull request #924 from doronhi/fix_W10
Browse files Browse the repository at this point in the history
force infrared stream to choose stable Y8 format.
  • Loading branch information
doronhi authored Sep 16, 2019
2 parents 4c9fafb + 0c3ce64 commit 2a45f09
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions realsense2_camera/include/base_realsense_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ namespace realsense2_camera
std::map<stream_index_pair, int> _width;
std::map<stream_index_pair, int> _height;
std::map<stream_index_pair, int> _fps;
std::map<rs2_stream, int> _format;
std::map<stream_index_pair, bool> _enable;
std::map<rs2_stream, std::string> _stream_name;
bool _publish_tf;
Expand Down
5 changes: 4 additions & 1 deletion realsense2_camera/src/base_realsense_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ BaseRealSenseNode::BaseRealSenseNode(ros::NodeHandle& nodeHandle,
_depth_aligned_encoding[RS2_STREAM_DEPTH] = sensor_msgs::image_encodings::TYPE_16UC1;

// Infrared stream
_format[RS2_STREAM_INFRARED] = RS2_FORMAT_Y8;

_image_format[RS2_STREAM_INFRARED] = CV_8UC1; // CVBridge type
_encoding[RS2_STREAM_INFRARED] = sensor_msgs::image_encodings::MONO8; // ROS message type
_unit_step_size[RS2_STREAM_INFRARED] = sizeof(uint8_t); // sensor_msgs::ImagePtr row step size
Expand Down Expand Up @@ -917,6 +919,7 @@ void BaseRealSenseNode::enable_devices()
(_width[elem] == 0 || video_profile.width() == _width[elem]) &&
(_height[elem] == 0 || video_profile.height() == _height[elem]) &&
(_fps[elem] == 0 || video_profile.fps() == _fps[elem]) &&
(_format.find(elem.first) == _format.end() || video_profile.format() == _format[elem.first] ) &&
video_profile.stream_index() == elem.second)
{
_width[elem] = video_profile.width();
Expand All @@ -927,7 +930,7 @@ void BaseRealSenseNode::enable_devices()

_image[elem] = cv::Mat(_height[elem], _width[elem], _image_format[elem.first], cv::Scalar(0, 0, 0));

ROS_INFO_STREAM(STREAM_NAME(elem) << " stream is enabled - width: " << _width[elem] << ", height: " << _height[elem] << ", fps: " << _fps[elem]);
ROS_INFO_STREAM(STREAM_NAME(elem) << " stream is enabled - width: " << _width[elem] << ", height: " << _height[elem] << ", fps: " << _fps[elem] << ", " << "Format: " << video_profile.format());
break;
}
}
Expand Down

0 comments on commit 2a45f09

Please sign in to comment.