Closed OneGneissGuy closed 5 years ago
You need to create new document and use it instead of the Metashape.app.document
:
import Metashape
doc = Metashape.Document()
chunk = doc.addChunk()
chunk.addPhotos(["IMG_0001.jpg", "IMG_0002.jpg"])
camera = chunk.cameras[0]
camera.photo.meta["Exif/FocalLength"]
This is because Metashape.app.document
represents the project visible from GUI, and so it is None
in stand-alone python wheel.
And yes, we should update documentation :)
I am getting the following error after following your direction and defining the following. doc = Metashape.document AttributeError: module 'Metashape.Metashape' has no attribute 'document'
I am using the following code. Please let me know if I am missing something. Also, please correct other mistakes in the code if there are any. import os import Metashape import numpy as np pa='/home/nys09/' pat='/home/nys09/Trial1Beamch_arc/' b=[] c=os.path.join(pa,"arc_imagelist_t1.txt") images = open(c,"r+") a = np.loadtxt(images,dtype=str) for i in range(np.shape(a)[0]): b.append(pat+str(a[i])) doc = Metashape.document chunk = doc.addChunk() chunk.addPhotos(b) camera = chunk.cameras[0] camera.photo.meta["Exif/FocalLength"] chunk.matchPhotos(accuracy=Metashape.HighAccuracy, generic_preselection=True,reference_preselection=False) chunk.alignCameras() doc.save(path = "project.psz", chunks = [doc.chunk])
@PolarNick239
I got another issue when use doc = Metashape.Document()
When I try to export model and camera position by
doc.open('project.psz')
doc.exportCameras()
doc.exportModel()
There is an error, error message is:
doc.exportCameras(path=path) AttributeError: 'Metashape.Metashape.Document' object has no attribute 'exportCameras'
I wonder what's the proper way to do the export?
As you can see in documentation - exportCameras
is a method of Metashape.Chunk
class. So you need to use something like doc.chunk.exportCameras()
.
P.S. Please ask questions about generic python scripting (that is not relevant to scripts from this repository) on forum/Python API.
Every example that calls Metashape.app.document fails because
Metashape.app.document
returnsNoneType
. Expect examples to work as listed in the documentation:System specs: