Forum

Author Topic: Automatic (batch) export of model with texture?  (Read 3680 times)

JohnyJoe

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
Automatic (batch) export of model with texture?
« on: October 15, 2016, 10:07:39 PM »
Hello i need a code/script allowing me to export automaticaly the generated model/mesh as obj with JPG (or TIF) texture. Im not a scripter but i found this script that allows a lot of batch process i didnt try it yet but i believe it should work:

Code: [Select]
import PhotoScan, os

path = PhotoScan.app.getExistingDirectory("Please choose the folder with .psz files:")

print("Script started")
doc = PhotoScan.app.document
doc.clear()
project_list = os.listdir(path)

for project_name in project_list:
if ".PSZ" in project_name.upper():
doc.open(path + "/" + project_name)
chunk = doc.chunks[0]

chunk.matchPhotos(accuracy=PhotoScan.HighAccuracy, preselection=PhotoScan.GenericPreselection)
chunk.alignCameras()

chunk.buildDenseCloud(quality=PhotoScan.HighQuality)
chunk.buildModel(surface=PhotoScan.Arbitrary, interpolation=PhotoScan.EnabledInterpolation)

chunk.buildUV(mapping=PhotoScan.GenericMapping)
chunk.buildTexture(blending=PhotoScan.MosaicBlending, size=4096)

doc.save()
print("Processed project: " + project_name)

else:
continue

print("Script finished.")

Could someone write additional line that after saving the file, it will also export the mesh as obj with generated texture (tif) for each *.psz file (with the same name as the file (or some unique name).

Is this possible?

Thank you a lot :-)!

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14854
    • View Profile
Re: Automatic (batch) export of model with texture?
« Reply #1 on: October 18, 2016, 06:57:48 PM »
Hello JohnyJoe,

You can add the following line after doc.save() code in the end of the script:

Code: [Select]
chunk.exportModel(path + "/" + project_name[:-3] + "obj", texture_format = 'tif', texture = True, format = "obj")
Best regards,
Alexey Pasumansky,
Agisoft LLC

JohnyJoe

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
Re: Automatic (batch) export of model with texture?
« Reply #2 on: October 20, 2016, 04:01:51 PM »
Thank you :-)!

So it should look like:?

Code: [Select]
doc.save()
print("Processed project: " + project_name)
chunk.exportModel(path + "/" + project_name[:-3] + "obj", texture_format = 'tif', texture = True, format = "obj")

else:
continue
« Last Edit: October 20, 2016, 04:06:12 PM by JohnyJoe »

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14854
    • View Profile
Re: Automatic (batch) export of model with texture?
« Reply #3 on: October 20, 2016, 05:54:13 PM »
Hello JohnyJoe,

Yes, I hope it should work.
Best regards,
Alexey Pasumansky,
Agisoft LLC

JohnyJoe

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
Re: Automatic (batch) export of model with texture?
« Reply #4 on: October 21, 2016, 11:16:19 AM »
Thank you, i will test it ASAP :-).