Forum

Author Topic: exporting models and point clouds using python (or a help function)  (Read 3457 times)

cvernon3

  • Newbie
  • *
  • Posts: 4
    • View Profile
I am running code from http://www.agisoft.com/pdf/photoscan_python_api_1_1_0.pdf which is the pdf explaining the PhotoScan class that is read by the 'run 'script' button in agisoft. However, while some of the functions seem to work while attempting to automate exporting I have ran into a few problems:

I have tried using:

import PhotoScan

doc = PhotoScan.app.document
chunk = doc.chunk

as well as:

import PhotoScan

# Below are what is needed for the main processing steps on a project

doc = PhotoScan.app.document
chunk = doc.chunk
chunk.matchPhotos(accuracy=PhotoScan.MediumAccuracy, preselection=PhotoScan.GenericPreselection)
chunk.alignCameras()
chunk.optimizeCameras(fit_f=True, fit_cxcy=True, fit_aspect=True, fit_skew=True, fit_k1k2k3=True, fit_p1p2=True, fit_k4=False)
chunk.buildDenseCloud(quality=PhotoScan.MediumQuality)
chunk.buildModel(surface=PhotoScan.Arbitrary, interpolation=PhotoScan.EnabledInterpolation)
chunk.buildUV(mapping=PhotoScan.GenericMapping)
chunk.buildTexture(blending=PhotoScan.MosaicBlending, size=4096)

followed by:

# chunk.exportModel(r"C:\Users\(rest of path I want...)", binary=False, precision=6, texture_format='tif', normals=False, colors=False, cameras=True['']['ply']['NAD83(HARN) / UTM zone 12N (EPSG::3742)'][0,0,0])

# error that string indices must be intergers (this error shows up in other locations as well)
PhotoScan.PointCloud.export(r"C:\Users\(rest of path I want...)", format='ply'['EPSG::3742'])

# comes back as unscriptable 'bool'=False
chunk.exportPoints(r'C:\Users\(rest of path I want...)', binary=False, precision=6, normals=True, colors=False ['']['']['ply']['NAD83(HARN) / UTM zone 12N (EPSG::3742)'][0,0,0])

Unless there is some easy fix, I was thinking that access to a help function or running the python without opening agisoft and using the run script button would help.

Thanks for the Help!


Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14851
    • View Profile
Re: exporting models and point clouds using python (or a help function)
« Reply #1 on: June 07, 2017, 07:06:26 PM »
Hello cvernon3,

It looks like you are incorrectly using arguments in the functions. Square brackets in the API reference and Console pane help are related to the optional arguments, you do not need to use brackets in your code.

Also can you specify, which version of PhotoScan you are using? API Reference from 1.1.0 wouldn't fit latest 1.3.2 version.
Best regards,
Alexey Pasumansky,
Agisoft LLC

cvernon3

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: exporting models and point clouds using python (or a help function)
« Reply #2 on: June 13, 2017, 08:35:40 PM »
Thanks Alexey,

I am using Agisoft PhotoScan version 1.2.6, and found the api for 1_3_0, the code that I got working is:

import PhotoScan
doc = PhotoScan.app.document
chunk = doc.chunk
chunk.exportModel(r"C:\mypath", binary=False, precision=6, texture_format='tif', normals=False, colors=False, cameras=True, udim =False, strip_extensions=False, format='ply', projection=PhotoScan.CoordinateSystem("EPSG::3742"))

Thanks again!

cvernon3