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

Customize Colormaps on USB Live Streaming Mode #57

Open
LaThanhTrong opened this issue Mar 6, 2023 · 4 comments
Open

Customize Colormaps on USB Live Streaming Mode #57

LaThanhTrong opened this issue Mar 6, 2023 · 4 comments

Comments

@LaThanhTrong
Copy link

LaThanhTrong commented Mar 6, 2023

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?

@marek-simonik
Copy link
Owner

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).

@LaThanhTrong
Copy link
Author

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?

@marek-simonik
Copy link
Owner

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).

@pcktm
Copy link

pcktm commented Mar 31, 2023

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)

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

No branches or pull requests

3 participants