openphotogrammetry / meshroomcl

MeshroomCL: An OpenCL implementation of photogrammetry with the Meshroom interface
Other
174 stars 8 forks source link

Depth map export #39

Open oGrqpez opened 2 years ago

oGrqpez commented 2 years ago

How can I export the depth maps of the images

revisionarian commented 2 years ago

Hi @oGrqpez, you can access the depth maps inside the MeshroomCache folder as soon as the MeshroomStereoCL node has finished processing. If you right click on the MeshroomStereoCL node and select the "Open Folder" menu option, you can navigate to the stereo/depth_maps sub-folder. The depth map files are named *.geometric.bin in that folder.

The *.geometric.bin depth map files are stored in a simple binary format with a text header. The file header contains three ASCII integers describing the width, height, and channels of the depth map, with each integer string terminated by a & character (channels will be 1). The rest of the file is a binary sequence of width*height 4-byte floats that represent the depth values at each pixel (a zero value indicates missing data).

oGrqpez commented 2 years ago

Oh.. wow. Uh how can I get the bin converted to an image? 😅

oGrqpez commented 2 years ago

@revisionarian i am viewing the bin file in notepad++, just a bunch of cursed symbols

oGrqpez commented 2 years ago

@revisionarian there are two. photometric and geometric, which one do I convert to an image

revisionarian commented 2 years ago

Hi @oGrqpez, you want to use the *.geometric.bin depth map files.

Are you skilled with the Python or MATLAB scripting languages? If so, here are a couple scripts that show how to read the *.geometric.bin files and convert them to viewable images:

https://github.com/colmap/colmap/blob/dev/scripts/python/read_write_dense.py https://github.com/colmap/colmap/blob/dev/scripts/matlab/read_depth_map.m

If you are still confused on how to do the conversion, tell me what format you want the depth images converted to, and I can post a Python script.

oGrqpez commented 2 years ago

@revisionarian png

oGrqpez commented 2 years ago

how would i run that python script in the first place

revisionarian commented 2 years ago

Hi @oGrqpez, it sounds like you are not familiar with Python scripting; that's fine. Probably the best solution for you would be if we added an "Export Depth Maps" option to MeshroomCL. We might do that in the future.

In the meantime, here is another way for you to visualize and convert the depth maps from MeshroomCL to PNG format:

1) Download our COLMAP-CL software here: https://github.com/openphotogrammetry/colmap-cl/releases 2) Run the COLMAP-CL software (COLMAP.bat) 3) In the COLMAP-CL GUI, select the menu option Reconstruction → Dense reconstruction 4) In the "Dense reconstruction" window, click the Select button 5) In the "Select workspace path..." window, navigate to the folder that contains your stereo/depth_maps folder, and click the Open button 6) Now the "Dense reconstruction" window should display a list of all your depth maps. Click the Depth map button in the "geometric" column to visualize each depth map. 7) In the window that displays each depth map, you can click the Save image button to save the depth map as a PNG file.

In step 5 above, make sure that you select open for the folder that is one level above your stereo folder. That is, the folder you select will have a long random name, such as MeshroomCache/MultiviewStereoCL/d50c056e4ed1e1e4a0a7a3c78973024d6c3f6276.

Let me know how this works for you.

oGrqpez commented 2 years ago

Perfect, one more thing. How can I export the depth map with a black to white ramp instead of the turbo coloramp.