IntelRealSense / librealsense

Intel® RealSense™ SDK
https://www.intelrealsense.com/
Apache License 2.0
7.63k stars 4.83k forks source link

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

Closed ysh625 closed 6 years ago

ysh625 commented 6 years ago

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 commented 6 years ago

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

20181012121831

MartyG-RealSense commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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

ysh625 commented 6 years ago

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 commented 6 years ago

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

lramati commented 6 years ago

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 commented 6 years ago

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

ysh625 commented 6 years ago

[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 commented 6 years ago

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!