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 - DocPopi

Pages: [1]
Python and Java API / Can't work in headless anymore
« on: November 07, 2023, 06:54:38 PM »

I've started working again on my automatic headless processing after a few months, but it seems nothing works anymore. When trying to open and save a document, I have several errors such as "saving disabled" and "no license found". However, the path to AGISOFT_license is set in the environment variables, and the GUI says my Professional license is indeed activated. True, recently I have made some tests with newer versions of Metashape, but I have reinstalled 1.8.4 since. Also, I have moved my script folder from C:/ to F:/, but I'm not sure why this should be a problem. Also, my Python interpreter is 3.8.

At last, inside VScode, I've tried Metashape.License.activate('key') but I have this error

Code: [Select]
    + CategoryInfo          : ObjectNotFound: (Metashape.License.activate:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

How can I fix this and set everything back as it used to work?

EDIT : I think I found the problem : I had to reinstall the proper Python wheel, because the wheel for 2.0 was still up. I'm leaving this here anyway in case someone else encounters the problem!

Thank you

Python and Java API / Select points according to masks
« on: May 15, 2023, 10:51:48 AM »
Hey there!

I am looking for a way to automatically extract the reconstructed model from the artefacts. I was wondering if there's a way to select points from the point cloud according to the masks generated on the images? Like for each mask, ask Metashape to select the points situated in the white part of the image, according to the camera position.

Thank you!

Dr Popi

Hello ! I'm developing a headless process to reconstruct and merge two parts of a shoe. In the align chunk parameters, I would like to use the "Apply Masks = Key points", but I am a bit confused by the API. The two parameters that seem to deal with that are:

• filter_mask (bool) – Filter points by mask.
• mask_tiepoints (bool) – Apply mask filter to tie points.

Must I use the filter mask? Or am I missing something?

Thank you!

Python and Java API / Export model in GLB with ALL maps
« on: April 12, 2023, 03:24:09 PM »
Hello there!

I am trying to make an automatic script that exports my model in .GLB with all the textures (diffuse, but also normal, occlusion and displacement). However, as was noticed in this post (, currently when you export a GLB model manually, it just gives you the diffuse map.

Is there a way to force it to embed the normal, occlusion and displacement as well in the GLB export?

Many thanks!

Best Regards,

General / Decimation / Texture Rebake
« on: February 24, 2023, 12:48:03 PM »
Hi there!

I'm currently testing the possibilities of Metashape in terms of optimization of the mesh. The decimation is very fast, but then I cannot find any other way to bake the texture other than re-building it all over again (and that can take a long time).

I saw in this post ( that there is supposed to be an option to retransfer the texture, but I can't seem to find it. I also have looked into the manual and I still can't find it.

Can anyone tell me where to find this option? Or if it doesn't exist anymore, is there another way to bake the texture after having decimated the object without having to rebuild the texture from scratch?

Thank you :)

Python and Java API / Metashape module not found
« on: January 30, 2023, 05:26:37 PM »
Hi everyone!

So I developed a small batch + python script that allows to drag and drop an image folder on the batch script in order to launch Metashape headlessly and process the object until the 3d export. It used to work well a few months ago. Then I put the project aside, and installed windows 11 in between. Now, I realize that launching Metashape headlessly does not cause any problem when it is done from the Visual Code console. However, when I try to use my old script as it was intended to, that is to say drag and dropping a folder on top of a batch script, I have the message "Metashape module not found'.

I don't really understand what is going on: I have installed the latest API Metashape wheel, I have checked that there agisoft_LICENSE environment variable points to the Agisoft installation folder where my license is activated (I have a pro license, also, so that should work...). But nothing works, the Windows console still considers that 'Metashape module is not found".

Can anybody help me?

Thank you  :)

Python and Java API / Process cloud project through Python
« on: August 17, 2022, 03:39:07 PM »
Hello again  :D

I have another problem concerning the processing of a project on the Cloud. Here is my script:

Code: [Select]
import Metashape
from os import path, listdir

def import_images(chunk):
    img_folder = path.join(My, Path, Joined)
    img_list = listdir(img_folder)
    for i in img_list:
        new_path = path.join(img_folder, i)

def build_task_list(tasks):
    '''Match photos'''
    task = Metashape.Tasks.MatchPhotos()
    task.downscale = 0
    task.keypoint_limit = 40000
    task.tiepoint_limit = 4000
    task.generic_preselection = True
    task.reference_preselection = True

    # '''Compile the match photos task'''
    # n_task = Metashape.NetworkTask()
    # =
    # n_task.params = task.encode()
    # n_task.frames.append((chunk.key, 0))
    # tasks.append(n_task)


    return tasks

def main():

    output_path = path.join(Another, Path, Joined)
    tasks = []
    doc = Metashape.Document()
    chunk = doc.addChunk()
    tasks = build_task_list(tasks)

    client = Metashape.CloudClient()
    client.username = **********
    client.password = ************



The problem is that once the code gets to the "client.processProject' part, I get an error saying that a "Task object is expected".

I found another post on this forum with a similar problem ( but there was no answer. I also tried to follow, but here I get an error saying that the Method is not allowed. Of course, I have also been combing the user reference manual, but I haven't found anything that could help me further.

Thank you in advance for your help :) 


Python and Java API / Cannot generate Occlusion Map through Python
« on: August 17, 2022, 11:58:11 AM »
Hi there! I'm currently testing the Python API for Metashape, and I am in a bit of a pickle regarding the generation of the Occlusion Map.

Everything goes fine with the diffuse map generation, but when getting at the Occlusion map step, I have this error : "Exception : Null model".

Here is my function:

Code: [Select]
def process(doc):
    chunk = doc.addChunk()
    chunk.matchPhotos(downscale=0, generic_preselection=True, reference_preselection=False, keypoint_limit=40000, keypoint_limit_per_mpx=1000, tiepoint_limit=4000,
                        filter_stationary_points=False, guided_matching=False)
    chunk.buildDepthMaps(downscale=4, filter_mode=Metashape.MildFiltering)
    chunk.buildModel(surface_type=Metashape.Arbitrary, interpolation=Metashape.EnabledInterpolation,
    face_count=Metashape.HighFaceCount, source_data=Metashape.DenseCloudData)
    chunk.buildTexture(blending_mode=Metashape.MosaicBlending, texture_size=16384, texture_type=Metashape.Model.TextureType.DiffuseMap,fill_holes=True )
    chunk.buildTexture(texture_size=16384, texture_type=Metashape.Model.TextureType.OcclusionMap)

Note : I noticed that, contrary to what it says on the Reference Manual, you actually have to specify "Metashape.Model.TextureType.[YourTexture]" for it to work.

I also tried to launch the code from another script, this one meant to be launched along the GUI, but I had the same exact error. In last resort, I also tried to launch the feature manually from the GUI and watch what it said in the console, but it doesn't show the actual code being run.

Does anybody have an idea :) ? Thank you so much!

PS : I also tried the codes mentioned here, but I couldn't get them to work either. I have another error "Reference model has no texture of specified type..."


Pages: [1]