Agisoft Metashape

Agisoft Metashape => Python and Java API => Topic started by: magic on July 20, 2018, 05:53:15 PM

Title: BuildModel params network
Post by: magic on July 20, 2018, 05:53:15 PM
Hi all,
I have a problem , I cant run my script , I want do BuildMesh and have errors
- Empty surface
- null frame
Did somebody can help I dont know witch parameters put to the function BuildModel nothing works Im on version 1.4.1

Code: [Select]
import PhotoScan

client = PhotoScan.NetworkClient()
doc = PhotoScan.app.document

task = PhotoScan.NetworkTask()
for c in doc.chunks:
    task.chunks.append(c.key )
    task.frames.append((c.key, 0))
task.name = "BuildModel"
task.params['apply'] = task.chunks
task.params['cameras'] = task.frames
#task.params['faces'] = "high"
#task.params['classes'] = [PhotoScan.PointClass.Ground]
task.params['surface'] = PhotoScan.Arbitrary
task.params['interpolation'] = PhotoScan.EnabledInterpolation
task.params['face_count'] = 1000
task.params['source'] = PhotoScan.DataSource.DenseCloudData
task.params['network_distribute'] = True #fine level task distribution key

path = "F:/TEST_PHOTOSCAN/toto2.psx" #relative path from root folder
client.connect('192.168.0.123') #server ip
batch_id = client.createBatch(path, [task])

client.resumeBatch(batch_id)
print("Debut")
Any help will be appreciated...
Title: Re: BuildModel params network
Post by: Alexey Pasumansky on July 20, 2018, 08:17:19 PM
Hello magic,

This code works for me in 1.4 version:

Code: [Select]
import PhotoScan

client = PhotoScan.NetworkClient()
doc = PhotoScan.app.document

task = PhotoScan.NetworkTask()
for c in doc.chunks:
#    task.chunks.append(c.key )
    task.frames.append((c.key, 0))
task.name = "BuildModel"
#task.params['apply'] = task.chunks
task.params['cameras'] = task.frames
#task.params['faces'] = "high"
#task.params['classes'] = [PhotoScan.PointClass.Ground]
task.params['surface'] = PhotoScan.Arbitrary
task.params['interpolation'] = PhotoScan.EnabledInterpolation
task.params['face_count'] = 1000
task.params['source'] = PhotoScan.DataSource.DenseCloudData
task.params['network_distribute'] = True #fine level task distribution key

path = "F:/TEST_PHOTOSCAN/toto2.psx" #relative path from root folder
client.connect('192.168.0.123') #server ip
batch_id = client.createBatch(path, [task])

client.resumeBatch(batch_id)
print("Debut")

I've commented a couple of unnecessary lines.

Can you check, if it works on your side as well.
Title: Re: BuildModel params network
Post by: magic on July 30, 2018, 11:54:49 AM
Hi Alexey
Works fine lovely , how I can start it from .bat file automatically ?? I have that
Code: [Select]
cd "c:\Program Files\Agisoft\PhotoScan Pro"
photoscan F:\TEST_PHOTOSCAN\toto2.psx  | photoscan.exe -r F:/piotrwork/ps_network/network_combine_test.py
??? How to overwrite it ?? My psx file is charged but script not work, first action is ok but I've got a disconnection from server , that what I have , script starts I can see first print and last one and disconnected from server, we have to add something to my script ???
my print from cmd
Code: [Select]
start process
connected to 192.168.0.123:5840
fin
disconnected from server
Title: Re: BuildModel params network
Post by: magic on August 01, 2018, 05:27:12 PM
I've past it for furthers visitors, Its working well I've added sys.argv to run it on network with help Alexey it work
Script:
Code: [Select]
import PhotoScan
import sys

#starting photoscan
app = PhotoScan.Application()
path = sys.argv[1]
#doc = PhotoScan.Document()
doc = PhotoScan.app.document
doc.open(path)
print("start process")

client = PhotoScan.NetworkClient()
#mon_path = PhotoScan.app.getExistingDirectory("dir")
task = PhotoScan.NetworkTask()
for c in doc.chunks:
#    task.chunks.append(c.key )
    task.frames.append((c.key, 0))
task.name = "BuildModel"
#task.params['apply'] = task.chunks
task.params['cameras'] = task.frames
#task.params['faces'] = "high"
#task.params['classes'] = [PhotoScan.PointClass.Ground]
task.params['surface'] = PhotoScan.Arbitrary
task.params['interpolation'] = PhotoScan.EnabledInterpolation
task.params['face_count'] = 1000
task.params['source'] = PhotoScan.DataSource.DenseCloudData
task.params['network_distribute'] = True #fine level task distribution key

path = "F:/TEST_PHOTOSCAN/toto2.psx" #relative path from root folder
client.connect('192.168.0.123') #server ip
batch_id = client.createBatch(path, [task])

client.resumeBatch(batch_id)
print("end")
   
And batch file example:
Code: [Select]
cd "c:\Program Files\Agisoft\PhotoScan Pro"
photoscan.exe -r F:\piotrwork\ps_network\hhh.py "F:\TEST_PHOTOSCAN\toto2.psx"

:-) :-)