Forum

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - jgillan

Pages: [1]
1
Python and Java API / 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)         


2
Python and Java API / batch network processing
« on: September 28, 2019, 03:23:32 AM »
Hello All,

I'm having a difficult time getting network processing to run with headless python. I can get it to work for a single command (e.g., MatchPhotos).

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

### match photos
task = Metashape.Tasks.MatchPhotos()
task.downscale = Metashape.Accuracy.MediumAccuracy
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))

client = Metashape.NetworkClient()
client.connect('10.1.2.234')
batch_id = client.createBatch(path, [n_task])
client.resumeBatch(batch_id)

doc.save()



But am unable to execute multiple commands (e.g., MatchPhotos + AlignCameras) using Alexey's code:


path = "/1a_u6/Metashape_Project.psx"
root = "/xdisk/jgillan"

network_tasks = list()

### match photos
task = Metashape.Tasks.MatchPhotos()
task.downscale = Metashape.Accuracy.MediumAccuracy
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)
network_tasks.append(n_task)

client = Metashape.NetworkClient()
client.connect('10.1.2.234')
batch_id = client.createBatch(path[len(root):], network_tasks)
client.resumeBatch(batch_id)

doc.save()


The 'client.createBatch' line appears to be the problem. I've tried writing that line of code a hundred different ways and tried changing the formatting of the path and root a hundred different ways. It always throws the error 'value is a not a tuple'.

I'm using Linux version 1.5.5.9097
Python 3.7

Please help. :'(


3
Hi All,
I developed a python script (in headless mode) to process all my imagery. The idea being that I could run many projects back-to-back without having to manually start a new one each time the previous finished. It is successful, but the time it takes to generate the dense point clouds is much, much longer using the python script compared with opening the GUI and pressing the buttons. Why is this happening? Is there a way around this problem?

4
Python and Java API / python script to Invert selection
« on: August 14, 2019, 04:19:59 AM »
Hello All,

I'm just looking for a python command to invert the selection of points in headless mode. There appears to be a GUI command but I can't find a python command in the Metashape Python API doc. My interest is to use a color threshold to identify ground points, but then invert the selection so I can delete non-ground points. I find the 'classify ground points' very useful, but I think structure + color would make a better filter for my application.

Thank you!

5
Python and Java API / Script to disable cameras based on camera pitch
« on: July 18, 2019, 09:58:30 PM »
Hi Agisoft Community,
I am trying to write a headless mode script to identify and disable all cameras with a certain pitch. I want to do this because I use many nadir and oblique images to build 3D models of desert landscapes. I also build orthomosaics, but only need the nadir images to do so (to reduce processing time). This is the logic:

if Metashape.Camera.rotation(pitch) > 10:
    Metashape.Camera.enabled = False
else:
    Metashape.Camera.enabled = True

I just don't know how to correctly code this and refer to the pitch rotation.

Can anybody help?

6
General / MicaSense image import
« on: April 09, 2016, 08:13:23 AM »
Hello PhotoScan Community,

I am very excited about the addition of multi-spectral camera rigs such as Micasense Rededge. I am currently having problems loading the images into a chunk. I have read the user manual part that describes the instructions to get multiple planes assigned to each camera position. The manual says with RedEdge photos, I can simply select them all and pull them into the chunk and based on metadata know which 5 bands belong together in an image stack. I can't seem to accomplish this. When I add all the image files, it does recognize that that these are multispectral and asks me if i would like to add them as such. However, when the images are in the chunk it doesn't seem to recognize that each camera has 5 frames. So my question is, how do I make this important work correctly? Photoscan doesn't seem to be reading the images and metadata correctly.

I also attempted variant b in the user manual where I put each group of 5 bands into a separate folder before import. Photoscan seems to recognize and do this correctly. But alas, separating all the cameras into different folders is a pain I'd like to avoid.

Any help would be appreciated!

Pages: [1]