Forum

Author Topic: Image Textures for Exported Files  (Read 40533 times)

Nathan Craig

  • Newbie
  • *
  • Posts: 18
    • View Profile
    • AnthSpace
Image Textures for Exported Files
« on: July 24, 2010, 07:53:44 PM »
Creating a textured mesh with PhotoScan is a real snap. Often times, I want to export a model to another program for further processing. Registering more than one mesh is a common example of these additional processing requirements.

I have exported from PhotoScan models that are in the ply, obj, and 3ds formats. My real preference is for ply. When I open any of these files (ply, obj, 3ds) only the mesh opens in the external program. So far I have used MeshLab (which was suggested on a separate thread of this website) and VRMesh Studio. When I open an exported ply file, there is no texture displayed in either MeshLab or VRMesh Studio. I see that PhotoScan creates a jpg texture file, but for some reason this does not seem to be linked to the mesh in other programs. Can you give me any suggestions as to how I can open in MeshLab a textured mesh created in PhotoScan?

Any help on this front would be greatly appreciated.
Regards,
Nathan

Dmitry Semyonov

  • Agisoft Technical Support
  • Full Member
  • *****
  • Posts: 182
    • View Profile
Re: Image Textures for Exported Files
« Reply #1 on: July 25, 2010, 09:52:17 PM »
Hello, Nathan,

The models exported with PhotoScan include all the required information for texture mapping, that is both the texture image itself and the texture coordinates.

Unfortunately, I've noticed that MeshLab don't load the external texture automatically for OBJ or PLY files.

I need some time to investigate the problem, I'll post back when I have more information.

With best regards,
Dmitry Semyonov
AgiSoft LLC
With best regards,
Dmitry Semyonov
Agisoft

Dmitry Semyonov

  • Agisoft Technical Support
  • Full Member
  • *****
  • Posts: 182
    • View Profile
Loading textured OBJ files into MeshLab
« Reply #2 on: July 30, 2010, 03:22:13 PM »
Hello, Nathan,

Here is the solution for OBJ files:

Assuming that you are saving an OBJ model named model.obj with a texture named model.jpg, please do the following:

1. Create the file named model.mtl with the following contents


newmtl Textured
Ka  0.6 0.6 0.6
Kd  0.6 0.6 0.6
Ks  0.9 0.9 0.9
d  1.0
Ns  0.0
illum 2
map_Kd model.jpg


and place it in the folder with your model.

2. Add the following line in the beginning of the model.obj file:

mtllib model.mtl

After these modifications MeshLab will correctly load and display textured models. The reason is that Wavefront OBJ file format requires a special .mtl file with material definitions, which is not currently exported by PhotoScan. We will fix it in the next PhotoScan release.

Notes: If your model is named differently, you should replace all file names (model.obj, model.mtl, model.jpg) with the real file names you are using.

With best regards,
Dmitry
With best regards,
Dmitry Semyonov
Agisoft

Dmitry Semyonov

  • Agisoft Technical Support
  • Full Member
  • *****
  • Posts: 182
    • View Profile
Notes on loading textured PLY files
« Reply #3 on: July 30, 2010, 03:51:41 PM »
Hello, Nathan,

Stanford PLY file format doesn't define a single standard for storing texture UV coordinates inside the PLY file.

Different programs use different names for storing UV coordinates:

Blender: s, t (with a note that u, v should be used in the future versions)
MeshLab: texture_u, texture_v
PhotoScan: u, v

This leads to incompatibilities when loading PLY files exported with a different program.

It is possible to change the names in the PLY file header using a text editor. Not every text editor is suitable, as the majority of the data in PLY files is stored in binary format and should be left unchanged. The internal text editors of the FAR file manager worked for me.

After these changes MeshLab loads PLY files with texture coordinates properly.

The second problem is loading a texture itself. As the PLY file doesn't store internal reference to the texture file, the texture should be loaded manually. Unfortunately, I was unable to find how to load a texture from a specified file in MeshLab.

We will add the option to select the names for storing UV coordinates in the next PhotoScan version.

With best regards,
Dmitry
With best regards,
Dmitry Semyonov
Agisoft

Nathan Craig

  • Newbie
  • *
  • Posts: 18
    • View Profile
    • AnthSpace
Re: Loading textured OBJ files into MeshLab
« Reply #4 on: August 04, 2010, 02:18:57 AM »
Dear Dmitry,

With this method, I was able to load into MeshLab v1.2.3 a model exported from PhotoScan. To edit the obj file, I used Notepad++.

An additional note for novice users (I made the same mistake the first time around): be sure to replace the text "model" with the actual name of the model that is being modified. There are three places where the name of the model must be inserted: 1) the name of the .mtl file, the final line of the text in the .mtl file, and the text line that is added to the .obj file. When these three values are properly formatted, the file opened with out problem.

Regards,
Nathan

Geo

  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: Re: Loading textured OBJ files into MeshLab
« Reply #5 on: November 06, 2010, 08:59:34 AM »
Thank you for posting your tips on loading .obj files with textures into MeshLab.  I see that the current version of PhotoScan, Version 0.6.1 beta 64 bit (build 556), which is what I have, creates the necessary .mtl file, as well as the correct parameters for the other files.  I opened the .obj file in MeshLab, however, no texture appears.

The .obj file I created has an 8000x8000 texture .jpg.  In MeshLab, I also tried doing "Filters>Textures>Set Texture, and it only shows the default "Texture" file as "pit8000.png"(pit being the name of my files).  I am not sure why it shows a .png extension.  I assume that MeshLab will open the texturing by default.

I suspect I am overlooking a simple step in the process.

I would appreciate any tips you can provide on making the .obj file open in MeshLab with texturing.

Regards,
Geo

Dmitry Semyonov

  • Agisoft Technical Support
  • Full Member
  • *****
  • Posts: 182
    • View Profile
Re: Loading textured OBJ files into MeshLab
« Reply #6 on: November 08, 2010, 03:05:03 AM »
Hello, Geo,

As you have mentioned, PhotoScan now creates all required files when exporting textured models in the OBJ file format.

Please make sure that file names you specify when exporting model in OBJ file format don't contain spaces and non-latin characters. Wavefront OBJ is a plain ASCII file format and it doesn't support Unicode characters.

Also, it is likely that 64bit version of MeshLab will be required to open high resolution textures, like yours.

If you still have troubles with the 64bit MeshLab version, please post a message to support@agisoft.ru, we will send you a sample OBJ model exported from PhotoScan which is known to be opened properly in MeshLab, so you could try loading it in MeshLab yourself.

With best regards,
Dmitry Semyonov
AgiSoft LLC
With best regards,
Dmitry Semyonov
Agisoft

cappelletto

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: Image Textures for Exported Files
« Reply #7 on: September 20, 2016, 10:05:32 PM »
Hello,
I stumbled upon this topic after searching for a solution to export a textured model from Photoscan into Meshlab 1.3.2 (64 bits).

I've tried using PLY and OBJ files, and in the import process in Meshlab, it fails to load the texture file. While inspecting the PLY file (stored in ASCII). i cannot find the texture_u and texture_v definitions, that seems to match the naming convention required by Meshlab for u-v texture coordinates.

For the OBJ file, it seems to be properly exported, but again Meshlab reports an error while loading the texture file (jpg, png or tif). I've checked for non-standard characters in the path just in case.

If you can, please provide an properly exported ply file to try to load it into Meshlab, so i can figure out at which end of the process is the error (Photoscan or Meshlab)

Kind regards,


wyk

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Image Textures for Exported Files
« Reply #8 on: March 19, 2017, 09:25:58 PM »
Hello,

I need help!
I cant export fron Photoscan to Meshlab...

Failure importing texture....
I try in OBJ and in PLY but anyway : I can't import texture !!

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 13289
    • View Profile
Re: Image Textures for Exported Files
« Reply #9 on: March 19, 2017, 09:27:30 PM »
Hello wyk,

Have you tried short export filename for the mesh?
Best regards,
Alexey Pasumansky,
Agisoft LLC

wyk

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Image Textures for Exported Files
« Reply #10 on: March 19, 2017, 10:24:12 PM »
Hello Alex,

Thanks to be here :)

Yes i try with a 5 letter OBJ name : the same error message (attached capture)

The mesh is ok, but no texture appear.

The OBJ is a 177 Mo file and the texture is a  113 Mo JPG (30000x30000) file.. in the same folder with the MTL file.
All photoscan generated and named.

Same problem with PLY format... unable to load texture.

 :(
« Last Edit: March 19, 2017, 10:51:36 PM by wyk »

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 13289
    • View Profile
Re: Image Textures for Exported Files
« Reply #11 on: March 20, 2017, 01:12:39 AM »
Hello wyk,

Maybe 30k x 30k texture is too much for MeshLab?
Best regards,
Alexey Pasumansky,
Agisoft LLC

wyk

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Image Textures for Exported Files
« Reply #12 on: March 20, 2017, 11:43:29 AM »
Hello,

You right...thank a lot : it's a texture précision's question.

I creat low textures and MeshLab is ok with texture less than 10k (9999 as best).

But quality is bad....
Have any idea to find a good viewer who support high precision texture?

BR
« Last Edit: March 20, 2017, 12:13:53 PM by wyk »

Thibaud Capra

  • Full Member
  • ***
  • Posts: 101
  • Master Student in Geodetic Engineering & Surveying
    • View Profile
    • INSA de Strasbourg, Topography Engineering (French)
Re: Image Textures for Exported Files
« Reply #13 on: March 20, 2017, 11:51:47 AM »
Hello wyk,

I'd try CloudCompare.
Best regards.
--
Thibaud CAPRA
Master Student in Geodetic Engineering, Cartography & Surveying
Master Thesis in Automated Processing of UAV-based Photogrammetric Data (ResearchGate Link)
INSA de Strasbourg, FRANCE
--