Forum

Author Topic: Mixing network and non-network processes  (Read 1776 times)

jgillan

  • Newbie
  • *
  • Posts: 12
    • View Profile
Mixing network and non-network processes
« on: October 08, 2019, 09:06:28 PM »
Hey all,

I'm working on network processing with python scripting, but not all of the commands I want to do fit into the 'tasks.' structure. For example, filtering poor quality sparse points, there doesn't seem to be a 'Metashape.Tasks.Filter()'.

Is it possible to do a network process (e.g., Metashape.Tasks.AlignCameras()) followed by a non-network process?

When I run the following code, the tasks begin being processed by the network. Meanwhile, the filtering code runs, but of course there is no sparse point cloud to filter yet. How do I tell it to run the filtering code on the sparse point cloud after it has been built via network processing?

Thank you in advance.


Code: [Select]
MetashapeProjectFile = ".\\Metashape_Project.psx"

path = "\\1a_u6\\Metashape_Project.psx"

network_tasks = list()

### match photos
task = Metashape.Tasks.MatchPhotos()
task.downscale = Metashape.Accuracy.LowAccuracy
task.keypoint_limit = 50000
task.tiepoint_limit = 0
task.preselection_generic = True
task.preselection_reference = True
task.network_distribute = True
n_task = Metashape.NetworkTask()
n_task.name = task.name
n_task.params = task.encode()
n_task.frames.append((chunk.key, 0))
network_tasks.append(n_task)

###align cameras
task = Metashape.Tasks.AlignCameras()
task.adaptive_fitting = True
task.network_distribute = True

n_task = Metashape.NetworkTask()
n_task.name = task.name
n_task.params = task.encode()
n_task.frames.append((chunk.key,0))   
network_tasks.append(n_task)

client = Metashape.NetworkClient()
client.connect('10.1.2.234')
batch_id = client.createBatch(path, network_tasks)
client.resumeBatch(batch_id)

doc.save()


##Gradual Selection of poor quality points in the sparse cloud are identified and deleted. Cameras are optimized after each filter.
threshold_uncertainty = 13
f = Metashape.PointCloud.Filter()
f.init(chunk, criterion = Metashape.PointCloud.Filter.ReconstructionUncertainty)
f.removePoints(threshold_uncertainty)