BrunoLevy / geogram

a programming library with geometric algorithms
Other
1.8k stars 122 forks source link

Texturing mesh from images? #59

Closed dzak83 closed 1 year ago

dzak83 commented 1 year ago

Hi, Thanks for working on this and making it available for us. I've been trying to get Poisson reconstruction for some time and I couldn't be happier to see it's working in your implementations!

I have a question about texturing from here. I am trying to texture the surface from the photos. I have a depth map form the Lidar scan and corresponding RGB images. I can use your pipeline to convert it from depth map to point cloud to mesh and generate mesh atlas. Is geogram supporting texture mapping from the images?

BrunoLevy commented 1 year ago

Hi,

See Graphite sources, MeshGrobSurfaceCommands::bake_colors this file line 871. It works like that (click on header file names below to see the documentation):

            #include [<geogram/mesh/mesh_baking.h>](https://brunolevy.github.io/geogram/mesh__baking_8h.html)
            #include [<geogram/image/image_library.h>](https://brunolevy.github.io/geogram/image__library_8h.html)
            #include [<geogram/image/morpho_math.h>](https://brunolevy.github.io/geogram/morpho__math_8h.html)
...

            // Step 1: create a geometry image
            Image_var geometry_image = new Image(
        Image::RGB, Image::FLOAT64, size, size
        );
        bake_mesh_geometry(mesh_grob(),geometry_image);

        //   Step 2: create the color map by looking up the high res
        // point nearest to each point from the geometry image.
        bake_mesh_points_attribute_indirect(
         geometry_image, color_map, highres, color
        );

            // Step 3: dilate a bit (to avoid "gutters" between the charts)
          MorphoMath mm(color_map);
      mm.dilate(nb_dilate);
      ImageLibrary::instance()->save_image(image, color_map);

It works like that:

BrunoLevy commented 1 year ago

TODO:

dzak83 commented 1 year ago

Thank you! I will go deeper into that part of code. Do I understand it correctly that MeshGrobSurfaceCommands::bake_colors is baking just colors at the verts but void MeshGrobSurfaceCommands::bake_texture is mapping the whole texture?

I also found this project: https://github.com/nmoehrle/mvs-texturing (PDF) which is mapping textures on 3D objects. They are doing a lot of post applying improvements for texture differences. Does Geogram doing additional post processing?

Thanks again for replying so quickly!

BrunoLevy commented 1 year ago

For atlas generation from multi-view image, yes with my group we developed an efficient solution, something that shares some similarities with the link you sent, but with several original algorithms that we developed, to hide the seams, to fill the zones that were not captured, to improve the contrast, to correct small registration errors...

This solution is part of Vorpaline, a proprietary software library developed on top of geogram, marketed by the Tessael company. See also this press release. Do not hesitate to contact them if you are interested.