Forum

Author Topic: Photoscan + Anaconda  (Read 4417 times)

mat

  • Newbie
  • *
  • Posts: 1
    • View Profile
Photoscan + Anaconda
« on: March 29, 2018, 03:32:13 PM »
Can I use Photoscan library in Python Anaconda as an external modul?
« Last Edit: March 29, 2018, 03:59:15 PM by mat »

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15177
    • View Profile
Re: Photoscan + Anaconda
« Reply #1 on: March 29, 2018, 05:11:35 PM »
Hello mat,

PhotoScan functionality via Python can be accessed only via PhotoScan itself, i.e. PhotoScan is not provided as external library or module.

In headless mode you can all the script execution via command line call:
Code: [Select]
photoscan.exe -r script.py
Best regards,
Alexey Pasumansky,
Agisoft LLC

howcanoewang

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Photoscan + Anaconda
« Reply #2 on: March 22, 2021, 05:22:43 AM »
Hello mat,

PhotoScan functionality via Python can be accessed only via PhotoScan itself, i.e. PhotoScan is not provided as external library or module.

In headless mode you can all the script execution via command line call:
Code: [Select]
photoscan.exe -r script.py

Currently, it is now supported without Photoscan itself.

First, download and pip install Metashape...whl module in anaconda environment: https://agisoft.freshdesk.com/support/solutions/articles/31000148930-how-to-install-metashape-stand-alone-python-module

Then, set the folder of Metashape lincense file (metashape.lic) as "agisoft_LICENSE" enviromental variable
e.g. agisoft_LICENSE="D:\\...\\Agisoft\\Metashape Pro\\ "

And then restart computer, and using the following code to check whether the envorment variable be correctly set.
Code: [Select]
>>> import os
>>> os.environ['agisoft_LICENSE']
'D:\\...\\Agisoft\\Metashape Pro\\'

And then you can call the API directly:
Code: [Select]
PS C:\Users\xxx> conda activate lab
(lab) PS C:\Users\xxx> python
Python 3.7.7 (default, May  6 2020, 11:45:54) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import Metashape
>>> 

Without giving any license not found error.

And a demo for creating a metashape project:
Code: [Select]
>>> doc = Metashape.Document()
>>> chunk = doc.addChunk()
>>> path = r"E:\...\PyAPI_Test.psx"
>>> doc.save(path=path)
SaveProject: path = E:/.../PyAPI_Test.psx
saved project in 0.148 sec
LoadProject: path = E:/.../PyAPI_Test.psx
loaded project in 0.021 sec