Forum

Author Topic: Can't build DEM in python script  (Read 3637 times)

Geend

  • Newbie
  • *
  • Posts: 12
    • View Profile
Can't build DEM in python script
« on: February 20, 2018, 04:52:54 PM »
Hello,
whenever I try to call buildDem on chunk, a runtime error occures. I'm using Photoscan 1.4 btw

Here is the console output: https://pastebin.com/2yHgkVaY

And here is what my script does: https://pastebin.com/PQ4diYX7

I'm saving the project before calling buildDem as you can see. "RuntimeError: Empty frame path
" doesn't seem to be documented anywhere.

Am I missing something here? Or is this a bug?

---
Torben


Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14846
    • View Profile
Re: Can't build DEM in python script
« Reply #1 on: February 20, 2018, 05:30:04 PM »
Hello Torben,

I suggest to leave doc.save("text.psx") only in it's first occurrence, then use just doc.save().

The reason is related to the fact that doc.save() with the specified path or filename is acting similar to Save As operation from GUI and it re-loads PSX project, but chunk variable is not re-assigned.
Best regards,
Alexey Pasumansky,
Agisoft LLC

Geend

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Can't build DEM in python script
« Reply #2 on: February 20, 2018, 05:34:54 PM »
Hello Alexey,

i tried your suggestion. Saving with only doc.save() doesn't seem to work: "OSError: Document.save(): editing is disabled in read-only mode"

https://pastebin.com/yM88CkdD

---
Torben


Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14846
    • View Profile
Re: Can't build DEM in python script
« Reply #3 on: February 20, 2018, 05:41:48 PM »
Hello Torben,

If you are running the application from GUI, can you please close current PhotoScan Pro instance and start the new one, then modify the order of the first lines as following:

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

chunk = doc.addChunk()
chunk.addPhotos(photos)

doc.save()
So apply all modifications to the document after it is already saved and all document related variables (like chunk) after the document is saved. After that just use doc.save() method.
Best regards,
Alexey Pasumansky,
Agisoft LLC

Geend

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Can't build DEM in python script
« Reply #4 on: February 20, 2018, 05:56:52 PM »
Hello Alexey,

I'm running the script from the command line. No other instance of Photoscan is running.

Code: [Select]
import PhotoScan as ps
import glob

doc = PhotoScan.app.document
doc.save("test.psx")

photos = glob.glob("../testProject/img/*.JPG")

chunk = doc.addChunk()
chunk.addPhotos(photos)
doc.save()

results in

Code: [Select]
SaveProject
saved project in 0.007209 sec
LoadProject
loaded project in 0.000207 sec
AddPhotos
Traceback (most recent call last):
  File "ref.py", line 13, in <module>
    doc.save()
OSError: Document.save(): editing is disabled in read-only mode

---
Torben

Geend

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Can't build DEM in python script
« Reply #5 on: February 20, 2018, 06:02:44 PM »
Well I think i figured it out.

When I use an absoult path for the first doc.save everything works fine.

Code: [Select]
import PhotoScan as ps
import glob

doc = PhotoScan.app.document
doc.save("test.psx")

photos = glob.glob("../testProject/img/*.JPG")

chunk = doc.addChunk()
chunk.addPhotos(photos)
doc.save()

doesn't work, but

Code: [Select]
import PhotoScan as ps
import glob

doc = PhotoScan.app.document
doc.save("/home/torben/script/test.psx")

photos = glob.glob("../testProject/img/*.JPG")

chunk = doc.addChunk()
chunk.addPhotos(photos)
doc.save()

does.

---
Torben




EDIT:

Well it doesn't need to be an absolute path after all.
doc.save("./test.psx") is fine as well.
doc.save("test.psx") is not fine.


« Last Edit: February 20, 2018, 06:10:06 PM by Geend »