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

How to use the function colorlizer in matlab or python? #2520

Closed
ysh625 opened this issue Oct 12, 2018 · 17 comments
Closed

How to use the function colorlizer in matlab or python? #2520

ysh625 opened this issue Oct 12, 2018 · 17 comments
Assignees

Comments

@ysh625
Copy link

ysh625 commented Oct 12, 2018

  • Before opening a new issue, we wanted to provide you with some useful suggestions (Click "Preview" above for a better view):

  • All users are welcomed to report bugs, ask questions, suggest or request enhancements and generally feel free to open new issue, even if they haven't followed any of the suggestions above :)


Required Info
Camera Model { R200 / F200 / SR300 / ZR300 / D400 }
Firmware Version (Open RealSense Viewer --> Click info)
Operating System & Version {Win (8.1/10) / Linux (Ubuntu 14/16/17) / MacOS
Kernel Version (Linux Only) (e.g. 4.14.13)
Platform PC/Raspberry Pi/ NVIDIA Jetson / etc..
SDK Version { legacy / 2.. }
Language {C/C#/labview/nodejs/opencv/pcl/python/unity }
Segment {Robot/Smartphone/VR/AR/others }

Issue Description

<Describe your issue / question / feature request / etc..>

@ysh625
Copy link
Author

ysh625 commented Oct 12, 2018

It's default value is(Jet),how can I set the value in matlab or python?
Thank you

20181012121831

@MartyG-RealSense
Copy link
Collaborator

Would the information linked to below about colorizing in MATLAB be of any use to you, please?

https://communities.intel.com/message/556782#556782

@ysh625
Copy link
Author

ysh625 commented Oct 12, 2018

Would the information linked to below about colorizing in MATLAB be of any use to you, please?

https://communities.intel.com/message/556782#556782

I just want to visualize depth data in matlab ,and I need the type "White to Black",not "Jet".
Is there any easy way to do it?
thank you.

@MartyG-RealSense
Copy link
Collaborator

You can select White To Black mode from a drop-down menu in the RealSense Viewer or set it with scripting.

https://communities.intel.com/message/562179#562179

@ysh625
Copy link
Author

ysh625 commented Oct 12, 2018

You can select White To Black mode from a drop-down menu in the RealSense Viewer or set it with scripting.

https://communities.intel.com/message/562179#562179

I selected White To Black mode and recorded.Then I use "realsense.rosbag_example" to read the .bag file,
which shows in mode Jet like that
20181012153032
Still in mode Jet
I know there is a class colorizer and it can be used well in C++
20181012121611
How can I use it in matlab?

@MartyG-RealSense
Copy link
Collaborator

Apologies for the delay in responding, I was investigating your case further.

In my own test, although the bag defaulted back to Jet when opened in the RealSense Viewer, I was able to change the bag back to White To Black by selecting this mode again in the Depth Visualization section of the Viewer's options panel.

You can playback a bag in the Viewer instead of rosbag_example by going to the Add Source menu at the top of the Viewer's options panel and selecting the Load Recorded Sequence option. Or you can just drag-and-drop the bag file onto the Viewer's center panel.

@MartyG-RealSense
Copy link
Collaborator

It is possible you may also be able to change the visualization mode through the SDK's MATLAB wrapper, but I do not have the scripting code for doing that. Hopefully one of the Intel team can help you with that later.

https://github.com/IntelRealSense/librealsense/tree/master/wrappers/matlab

@dorodnic
Copy link
Contributor

Hi @ysh6 @MartyG-RealSense
Based on user report (#2487) there seems to be a bug in setting processing options right now for the Matlab wrapper. We are looking into it.
This can be done with the python wrapper, by calling colorizer.set_option and choosing a different color-scheme.
That said, both python (via numpy and opencv) and Matlab have plenty of work-around ways to do this.

@ysh625
Copy link
Author

ysh625 commented Oct 12, 2018

Hi @ysh6 @MartyG-RealSense
Based on user report (#2487) there seems to be a bug in setting processing options right now for the Matlab wrapper. We are looking into it.
This can be done with the python wrapper, by calling colorizer.set_option and choosing a different color-scheme.
That said, both python (via numpy and opencv) and Matlab have plenty of work-around ways to do this.

I saw the set_option but I don't know how to use it....
I am new to python.
Could you please show me more details or an example?

@dorodnic
Copy link
Contributor

Certainly:

import matplotlib.pyplot as plt   
import pyrealsense2 as rs   
...
colorizer = rs.colorizer()
colorizer.set_option(rs.option.color_scheme, 2); // white to black
colorized_depth = np.asanyarray(colorizer.colorize(depth_frame).get_data())
plt.imshow(colorized_depth)

There is no closed enumeration for the different color schemes, but you can play around with different values and other options. You can also test it in an interactive notebook Binder

@dorodnic
Copy link
Contributor

We also have additional notebook explaining post-processing and post-processing options, but it is missing the colorizer options

@ysh625
Copy link
Author

ysh625 commented Oct 12, 2018

Certainly:

import matplotlib.pyplot as plt   
import pyrealsense2 as rs   
...
colorizer = rs.colorizer()
colorizer.set_option(rs.option.color_scheme, 2); // white to black
colorized_depth = np.asanyarray(colorizer.colorize(depth_frame).get_data())
plt.imshow(colorized_depth)

There is no closed enumeration for the different color schemes, but you can play around with different values and other options. You can also test it in an interactive notebook Binder
That works,
I really appreciate your help

@RealSense-Customer-Engineering
Copy link
Collaborator

[Realsense Customer Engineering Team Comment]
@ysh6 Any other questions about this ticket? Please update. Thanks!

@lramati
Copy link
Contributor

lramati commented Oct 29, 2018

PR #2492 Added the missing constructor argument to matlab's colorizer class, so the ability to set the color scheme should be working there too

@RealSense-Customer-Engineering
Copy link
Collaborator

[Realsense Customer Engineering Team Comment]
@ysh6 Any other questions for this ticket? Please update. Thanks!

@ysh625
Copy link
Author

ysh625 commented Oct 30, 2018

[Realsense Customer Engineering Team Comment]
@ysh6 Any other questions for this ticket? Please update. Thanks!
Apologies for the delay in responding,My problem was settled.

@ysh625
Copy link
Author

ysh625 commented Oct 30, 2018

PR #2492 Added the missing constructor argument to matlab's colorizer class, so the ability to set the color scheme should be working there too

That's good news.
Thank you!

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

No branches or pull requests

5 participants