Author Topic: [pro] timeline through api  (Read 2635 times)


  • Newbie
  • *
  • Posts: 23
    • View Profile
[pro] timeline through api
« on: August 20, 2012, 02:44:03 PM »
Expose timeline functionnality through the python api:
- query first, last, current frame
- set current frame


  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: [pro] timeline through api
« Reply #1 on: August 20, 2012, 05:47:44 PM »
Hi Nico,

Is this a suggestion or a question? You are not really clear on that. Nevertheless, it is already part of the api. I use the following code (based on the documentation), I hope it is usefull for others.

# first load a document, 'photoScanFile' is set to a .psz file in my case
document = PhotoScan.Document()

# set frame for the first (0) chunk, i is desired frame (in my case this is part of a loop):
i = 2
document.chunks[0].frame = i

# The first frame is always frame 0
first_frame = 0
# the last name is the number of frames
last_frame = document.chunks[0].frame_count

The loop I use if for exporting all frames, it looks like this:

    for i in range(0,document.chunks[0].frame_count):
        # export file names
        outputDEM = '%s/DEM_%04i.tif' % (outputDir, i+1)
        outputOrtho = '%s/Ortho_%04i.tif' % (outputDir, i+1)
        # set current frame
        document.chunks[0].frame = i   
        # export dem and orthophoto
        document.chunks[0].exportDem(outputDEM, format='tif', region=exportRegion, dx=gridSize, dy=gridSize)
        document.chunks[0].exportOrthophoto(outputOrtho, format='tif', region=exportRegion, dx=gridSize, dy=gridSize)