Forum

Author Topic: Saving as PSX in Python Script  (Read 4441 times)

ax0n

  • Newbie
  • *
  • Posts: 7
    • View Profile
Saving as PSX in Python Script
« on: July 26, 2017, 11:02:05 PM »
When starting, it seems that PhotoScan requires the project to be a .psz file. (e.g., The following snippet doesnt work if I try to use the '.psx' file suffix.)

Code: [Select]
doc = ps.app.document
project_path = ps.app.getSaveFileName("Specify project filename for saving: ")

if not project_path:
    print("Script aborted")

if project_path[-4:].lower() != ".psz":
    project_path += ".psz"

doc.save(project_path)
ps.app.update()


However, while the process is running, specifically before I can make the DEM, I am promted to save as a .PSX file before I can continue... and the script errors out. as seen here.

Code: [Select]
BuildDem: source data = Dense cloud, interpolation = Enabled, resolution = 0 Please save project in PSX format before processing
Traceback (most recent call last):
File "run.py", line 130, in <module> interpolation=ps.EnabledInterpolation
RuntimeError: Empty frame path


I have tried this...

Code: [Select]

psx_prj = project_path[:-4] + '.psx'
doc.save(psx_prj)
ps.app.update()


but i get an error..

Code: [Select]
Traceback (most recent call last):
File "run.py", line 129, doc.save(psx_prj)
in <module>
RuntimeError: Can't save project

How can I save the project as a PSX so I can continue building raster products?

just to clarify

Code: [Select]
import os
import PhotoScan as ps
doc = ps.app.document
doc.save("test.psz")
ps.app.update()

returns

Code: [Select]
SaveProject
saved project in 0.003522 sec

but

Code: [Select]
import os
import PhotoScan as ps
doc = ps.app.document
doc.save("test.psx")


returns

Code: [Select]
SaveProject
Traceback (most recent call last):
  File "save_script.py", line 8, in <module>
    doc.save("test.psx")
RuntimeError: Can't save project

Any ideas?
« Last Edit: July 27, 2017, 11:29:45 AM by indigo »

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14855
    • View Profile
Re: Saving as PSX in Python Script
« Reply #1 on: July 27, 2017, 03:42:54 PM »
Hello indigo,

This code works fine on our side in the version 1.3.2, just changed PSZ to PSX in two cases:

Code: [Select]
import PhotoScan as ps
doc = ps.app.document
project_path = ps.app.getSaveFileName("Specify project filename for saving: ")

if not project_path:
    print("Script aborted")

if project_path[-4:].lower() != ".psx":
    project_path += ".psx"

doc.save(project_path)
ps.app.update()
Best regards,
Alexey Pasumansky,
Agisoft LLC

ax0n

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Saving as PSX in Python Script
« Reply #2 on: July 27, 2017, 03:59:20 PM »
That is odd Alexey, I saved your example as save.py and tried the following

Code: [Select]
usr@machine:~/project_dir$ /usr/lib/photoscan-pro/photoscan.sh -r save.py -platform offscreen
Specify project filename for saving:
test
SaveProject
Traceback (most recent call last):
  File "save.py", line 11, in <module>
    doc.save(project_path)
RuntimeError: Can't save project

Could this be something in my version? I am using 1.3.2, I will try a re-install perhaps.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14855
    • View Profile
Re: Saving as PSX in Python Script
« Reply #3 on: July 27, 2017, 04:02:48 PM »
Hello indigo,

Can you please add print (project_path) line before saving the project and check if the specified path exists and is valid.
Best regards,
Alexey Pasumansky,
Agisoft LLC

ax0n

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Saving as PSX in Python Script
« Reply #4 on: July 27, 2017, 04:32:01 PM »
Thank you Alexey, the project path was valid but it was not allowing it to make the files in the same directory the script is running in. I created a sub directory and it worked fine. thank you very much...

just to recap,

Code: [Select]
# in project directory
mkdir gis
# from ssh terminal
/usr/lib/photoscan-pro/photoscan.sh -r lib/save.py -platform offscreen


All sorted. thank you again.