record3d icon indicating copy to clipboard operation
record3d copied to clipboard

Customize Colormaps on USB Live Streaming Mode

Open LaThanhTrong opened this issue 2 years ago • 4 comments

When I am running demo-main.py, depth from cv2 shows only black, gray and white colormap. I tried to switch other colormaps in the settings, but it does not work. It only works when streaming mode is turned off. Is there anything I have to do in the settings or lines of code can solve this issue?

LaThanhTrong avatar Mar 06 '23 08:03 LaThanhTrong

Do you mean that you see the depth map in shades of gray instead of colored by the currently selected colormap from the Settings section? It is not a bug, but the expected behavior; the USB streaming mode is supposed to stream unaltered RGBD data and it is the responsibility of the receiver (e.g. the Python script) to post-process the raw output into the desired output.

I would advise to adjust the Python script and apply color mapping (or other post-processing you need) to the depth map via Python. Note that the depth map contains float32 numbers and invalid values are stored as NaNs (something to be aware of when implementing color mapping).

marek-simonik avatar Mar 07 '23 17:03 marek-simonik

Do you mean that you see the depth map in shades of gray instead of colored by the currently selected colormap from the Settings section? It is not a bug, but the expected behavior; the USB streaming mode is supposed to stream unaltered RGBD data and it is the responsibility of the receiver (e.g. the Python script) to post-process the raw output into the desired output.

I would advise to adjust the Python script and apply color mapping (or other post-processing you need) to the depth map via Python. Note that the depth map contains float32 numbers and invalid values are stored as NaNs (something to be aware of when implementing color mapping).

Do python also support shading aswell?

LaThanhTrong avatar Mar 08 '23 22:03 LaThanhTrong

You can implement arbitrary post-processing in Python, but there is no out-of-the-box support for shading per se; you will have to implement your own filters/post-processing from scratch (it is unrelated to Record3D).

marek-simonik avatar Mar 10 '23 13:03 marek-simonik

An example of color mapping:

self.max_depth_ever = max(self.max_depth_ever, np.nanmax(depth))
depth[np.isnan(depth)] = self.max_depth_ever
depth = depth / self.max_depth_ever * 255
depth = depth.astype(np.uint8)

depth = cv2.applyColorMap(depth, cv2.COLORMAP_JET)

pcktm avatar Mar 31 '23 19:03 pcktm