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

Is there a way to specify color stream type? #1670

Closed
ulassbin opened this issue Feb 5, 2021 · 3 comments
Closed

Is there a way to specify color stream type? #1670

ulassbin opened this issue Feb 5, 2021 · 3 comments
Labels

Comments

@ulassbin
Copy link

ulassbin commented Feb 5, 2021

Specifically I am interested in getting Y16 encoding because my application needs unrectified image. I have seen from
https://community.intel.com/t5/Items-with-no-label/How-to-enable-both-Y16-unrectified-streams-from-D435-in-SDK2-0/td-p/618843
that Y16 stream is unrectified.

@ulassbin ulassbin changed the title Is there a way to specificy to color stream type? Is there a way to specify to color stream type? Feb 5, 2021
@ulassbin ulassbin changed the title Is there a way to specify to color stream type? Is there a way to specify color stream type? Feb 5, 2021
@MartyG-RealSense
Copy link
Collaborator

MartyG-RealSense commented Feb 5, 2021

Hi @ulassbin In the RealSense ROS wrapper you can set stream format (infra, color, fisheye, depth, gyro, accel, pose) and its height, width and FPS but not the mode used for that format.

The ROS wrapper file base_realsense_node.cpp provides information about how the streams are defined in the wrapper.

https://github.com/IntelRealSense/realsense-ros/blob/ros1-legacy/realsense2_camera/src/base_realsense_node.cpp#L93-L119


The Y16 format can be defined using code in the librealsense SDK. The link below provides information about this and a link to Python scripting for doing so for the left and right infrared streams.

IntelRealSense/librealsense#6741 (comment)

I believe that for Y16 color from the RGB sensor the equivalent Python instruction in librealsense would be:

config.enable_stream(rs.stream.color, 1280, 720, rs.format.y16, 30)

image

@ulassbin
Copy link
Author

ulassbin commented Feb 5, 2021

Changing the lines:

_image_format[RS2_STREAM_COLOR] = CV_8UC3; // CVBridge type
_encoding[RS2_STREAM_COLOR] = sensor_msgs::image_encodings::RGB8; // ROS message type

to

    _format[RS2_STREAM_COLOR] = RS2_FORMAT_Y16; // Adding this line.
    _image_format[RS2_STREAM_COLOR] = CV_16UC1;    // CVBridge type
    _encoding[RS2_STREAM_COLOR] = sensor_msgs::image_encodings::MONO16; // ROS message type

and lines:

std::set<rs2_format> available_formats{ rs2_format::RS2_FORMAT_RGB8, rs2_format::RS2_FORMAT_Y8 };

to

std::set<rs2_format> available_formats{ rs2_format::RS2_FORMAT_Y16, rs2_format::RS2_FORMAT_Y8 };

worked for me. When I have the time, I can make this format a parameter and send a pr.

Thanks!

@ulassbin ulassbin closed this as completed Feb 5, 2021
@MartyG-RealSense
Copy link
Collaborator

Awesome to hear that you were able to develop a solution that worked for you @ulassbin - thanks very much for sharing your method and the offer of a PR contribution :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants