Question about applyTexture()

Hi,

I had a question about the applyTexture() function. How can I save the generated texture? When using mesh.save() the texture file is missing.

Thanks in advance!

Greetings Niek

Hi Niek,

the texture should be saved if you use PLY or OBJ format. STL doesn’t support texture. Are you using the mentioned formats?

Bet regards,
Olga

Hi Olga,

Yes, I am using the PLY format. My code looks as follows:

std::cout << "Reconstructed mesh (" << mesh.vertexCount() << " vertices, " << mesh.triangleCount() << " triangles)" << std::endl;
ok = mesh.applyTexture();
if(!ok)
	std::cout << "Re-texturing failed" << std::endl;
mesh.save("mesh.ply", RecFusion::Mesh::PLY);

When opening the mesh in Meshlab, the following message is shown:

Also, I noticed that in RecFusion Pro the mesh colors are improved after generating a mesh (which happens much faster than re-texturing). Is this also available in the SDK?

Greetings Niek

Hi Niek,

I’m not sure what could be the reason for this. Can you try to save mesh in OBJ? Is it the same problem then? Are there any error messages in the log?

Currently SDK does not have the same option as RecFusion for improving mesh colors.

Best regards,
Olga

Hi Olga,

I have tried to save as a .obj file. The same problem occurs.

image

Here is the full log.

Image recorder thread started
Added keyframe (0,-1) R inf T inf 
Added keyframe (1,-1) R inf T inf 
Added keyframe (2,-1) R inf T inf 
Added keyframe (3,-1) R inf T inf 
Image recorder thread terminated
[RGBDMultiSequence] Timestamps of at least one sequence are all zero. Frames will be matched by position instead of timestamps
Reconstructed mesh (94820 vertices, 177599 triangles)
[Texturing] Loading data: 658.164 ms
[Texturing] Preparing mesh: 405.625 ms
        Adding edges 100%... done. (Took 0.966s)
        247461 total edges.
[Texturing] Buidling Adjacency graph: 977.036 ms
        Building BVH from 167213 faces... done. (Took: 179 ms)
        Calculating face qualities 100%... done. (Took 0.577s)
        Postprocessing face infos 100%... done. (Took 0.342s)
        Maximum quality of a face within an image: 6.24411
        Clamping qualities to 1.02226 within normalization.
[Texturing] Calculating data costs: 1191.11 ms
        Optimizing:
                Time[s] Energy
                0       316397
                0       315661
                0       287478
                0       273517
                0       267230
                1       263284
                1       260612
                1       259414
                1       258131
                1       256650
                1       255860
                2       255036
                2       254427
                2       254327
                2       253822
                2       253536
                2       253230
                3       252907
                3       252528
                3       252005
                3       251843
                3       251586
                4       251384
                4       251283
                4       251181
                4       251181
                4       251100
                5       251016
                5       250954
                5       250811
                5       250708
                5       250708
                6       250648
                6       250588
                6       250547
                6       250487
                6       250487
                7       250487
                7       250449
                7       250429
                7       250350
                8       250310
                8       250310
                8       250310
                8       250290
                9       250269
                9       250249
                9       250232
                9       250232
                10      250232
                10      250232
                10      250215
                10      250195
                10      250195
                11      250194
                11      250156
                11      250156
                11      250156
                12      250156
                12      250137
                12      250119
                12      250080
                12      250060
                13      250000
                13      249980
                13      249940
                13      249940
                13      249920
                14      249901
                14      249881
                14      249861
                14      249861
                14      249861
                15      249861
                15      249861
        43847 faces have not been seen
[Texturing] Optimization: 15466.3 ms
        Running... done. (Took 0.357s)
        496 texture patches.
[Texturing] Generating texture patches: 366.302 ms
        Create matrices for optimization...  done.
        Lhs dimensionality: 71335 x 71335
        Calculating adjustments:
                Color channel 0: CG took 80 iterations. Residual is 9.364e-05
                Color channel 1: CG took 100 iterations. Residual is 9.38216e-05
                Color channel 2: CG took 111 iterations. Residual is 9.63961e-05
                Took 0.202 seconds
        Adjusting texture patches 100%... done. (Took 0.646s)
[Texturing] Global seam leveling: 1119.45 ms
        Blending texture patches 100%... done. (Took 1.067s)
[Texturing] Local seam leveling: 1148.11 ms
[Texturing] Unseen face inpainting: 2019.23 ms
        Sorting texture patches... done.
        Working on atlas 99%... [Texturing] Texture atlas generation: 1186.09 ms
[Texturing] Building mesh: 52.2028 ms
[Texturing] Texturing: 23953.3 ms

Greetings Niek

Hi Niek,

it seems that we have some issues when saving a mesh with a relative path. Could you try to specify the absolute path, for example like in here:
mesh.save("D:/mesh.ply", RecFusion::Mesh::PLY);
and see whether that works?
We will address the issue with the relative paths in the next release.

Best regards,
Olga

Hi Olga,

Saving the mesh to an absolute path resolves the issue, thanks!

Greetings Niek