Forum

Author Topic: looping throuh all chunks in document  (Read 9630 times)

xabierr

  • Jr. Member
  • **
  • Posts: 84
    • View Profile
looping throuh all chunks in document
« on: July 12, 2013, 06:03:31 AM »
I'm new to python and was wondering what is the best way to loop through all the chunks in a document. Thought about using the "index" function but cant even make it work (error: NameError: name 'index' is not defined). Appreciate any help on this topic.

cheers,

Javier

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14927
    • View Profile
Re: looping throuh all chunks in document
« Reply #1 on: July 12, 2013, 10:00:18 AM »
Hello Javier,

I suggest the following:

Code: [Select]
doc = PhotoScan.app.document
for chunk in doc.chunks:
...
Best regards,
Alexey Pasumansky,
Agisoft LLC

xabierr

  • Jr. Member
  • **
  • Posts: 84
    • View Profile
Re: looping throuh all chunks in document
« Reply #2 on: July 12, 2013, 10:28:40 AM »
Thanks Alexey. Is that supposed to iterate through all chunks in doc? When I run the following, only getting results for first chunk... how do I make it go through all chunks and use the name for output filenames?

doc = PhotoScan.app.document
proj = PhotoScan.Matrix([[-1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, -1.0, 0.0],  [0.0, 0.0, 0.0, 1.0]]) #Bottom XY

for chunk in doc.chunks:
    filename = chunk.label
    pathd = "C:\photoscan\DEM_"+filename+".tif"
    pathm = "C:\photoscan\Mos_"+filename+".tif"
    chunk.exportDem(pathd, dx=1, dy=1, projection = proj)
    chunk.exportOrthophoto(pathm, projection = proj, blending="mosaic", dx=1, dy=1)

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14927
    • View Profile
Re: looping throuh all chunks in document
« Reply #3 on: July 12, 2013, 11:29:31 AM »
Hello Javier,

And are there any error messages in the console pane?
Best regards,
Alexey Pasumansky,
Agisoft LLC

xabierr

  • Jr. Member
  • **
  • Posts: 84
    • View Profile
Re: looping throuh all chunks in document
« Reply #4 on: July 12, 2013, 11:40:56 AM »
No errors.  The two chunks are:

PhotoScan.Chunks(doc)
[<Chunk 'Chunk 33_110-209'>, <Chunk 'Chunk 33_16_109'>]


Attached is output from console and only outputs are:

Mos_Chunk 33_110-209.tif and Dem_Chunk 33_110-209.tif

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14927
    • View Profile
Re: looping throuh all chunks in document
« Reply #5 on: July 12, 2013, 12:09:55 PM »
Hello Javier,

And are the resulting images for the first chunk adequate? Looks like the export resolution is very low and mosaic size is very-very small.
Best regards,
Alexey Pasumansky,
Agisoft LLC

xabierr

  • Jr. Member
  • **
  • Posts: 84
    • View Profile
Re: looping throuh all chunks in document
« Reply #6 on: July 12, 2013, 12:25:11 PM »
set resolution to 1 to accelerate process but now that set it back to 0.001 it is working... thanks for that

yulback

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: looping throuh all chunks in document
« Reply #7 on: September 25, 2013, 07:36:39 AM »
Is that supposed to iterate through all chunks in doc?