Agisoft Metashape
Agisoft Metashape => Python and Java API => Topic started by: kaz on March 25, 2019, 02:22:10 PM
-
Dear Agisoft support team,
I started Metashape pro 30-day trial.
I successfully installed both gui and command line tools(Please see attached images).
However I'm not able to import Metashape in python.
It gives the message "No license found. Details: No license for product (-1)"
It is not possible to use command line tool as a trial user?
I hope to test script functionality before purchase.
Environment: macOS High Sierra 10.13.6
Many thanks
Best regards
kaz
-
The command "print(Metashape.__path__)" returned the corrent path.
I successfully imported Metashape, although I received the message "No license found."
Thanks,
-
Hello kaz,
Have you activate the GUI version using a trial license key on the same computer already?
-
Hello Alexey,
Thank you for your reply.
I think I successfully activated GUI version.
Please check attached images on the first post.
I selected the trial mode when I started for the first time.
Best regard,
kaz
-
Additional information:
>>>import Metashape
>>>print(Metashape.app.activated)
False
>>>doc = Metashape.app.document
>>>print(doc)
None
>>>doc = Metashape.Document()
>>>print(doc)
<Document ''>
>>>doc.save()
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
<ipython-input-8-b188bfd64a3d> in <module>
----> 1 doc.save()
OSError: Document.save(): saving is disabled
Best regards,
kaz
-
Additional information:
Please see attached image.
It looks activated as trial mode.
-
Hello kaz,
I can suggest to copy metashape.lic file from the application bundle contents (MetashapePro.app/Contents/MacOS/metashape.lic) to the Python module directory.
Or from Python IDLE console execute the following command with your trial key:
Metashape.License().acitvate("11111-22222-33333-44444-55555")
-
Hello Alexey,
Thank you for the reply.
I copied metashape.lic
because I'm using trial version and don't know my trial key.
Metashape.app.activated became True.
However, I was not able to save model.
My current objective is to save model as like ply in script.
It should be posted as another topic?
Also, I seems strange that Metashape.app.document returns None.
>>> import Metashape
>>> print(Metashape.app.activated)
True
>>> doc = Metashape.app.document
>>> print(doc)
None
>>> doc = Metashape.Document()
>>> doc.open("test.psx")
>>> print(doc)
<Document 'path_to_file/test.psx'>
>>> chunk = doc.chunk
>>> chunk.matchPhotos(accuracy=Metashape.HighAccuracy, generic_preselection=True, reference_preselection=False)
>>> chunk.alignCameras()
>>> point_cloud = chunk.point_cloud
>>> print(point_cloud)
<PointCloud '12580 points'>
>>> print(chunk)
<Chunk 'Chunk 1'>
>>> chunk.exportModel("test.ply", binary=True, texture_format=Metashape.ImageFormatJPEG, texture=True, normals=False, colors=False, cameras=False, markers=False, format=Metashape.ModelFormatPLY)
---------------------------------------------------------------------------
Exception Traceback (most recent call last)
<ipython-input-9-38b20b4982fc> in <module>
----> 1 chunk.exportModel("test.ply", binary=True, texture_format=Metashape.ImageFormatJPEG, texture=True, normals=False, colors=False, cameras=False, markers=False, format=Metashape.ModelFormatPLY)
Exception: Null model
Best regards,
kaz
-
Hello kaz,
According to the script code, there's only point cloud in the chunk, but you are trying to export model (which assumes mesh model).
Metashape.app.document returns None since there's no active project. Use Metashape.Document() assignment instead to create a new project or open existing project.
-
Hello Alexey,
Thank you for your support.
I successfully exported points.
When I want to have dense point cloud as numpy array, it's the only way to save dense point cloud using exportPoints(for examaple, .ply format) function and import it as numpy array?
There is no way to convert directly from Metashape DenseCloud to numpy array?
Best regards,
kaz
-
Hello kaz,
Currently it is not possible to convert dense cloud points internally to numpy array via Metashape Python API, so the only workaround seems to be exporting the cloud in plain text format and reading the file then.
-
Hello Alexey,
I understand and really appreciate your support!
Best regards,
kaz