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.


Messages - boulder1998

Pages: [1]
1
Python and Java API / HeightField in buildModel
« on: September 21, 2023, 12:48:10 PM »
Dear all,

I want to play around with some of the input parameters for certain Metashape functions such as buildModel.
In my script after matchPhotos, alignPhotos and buildDepthMaps I want to use this buildModel function.

While my scripts runs fine when using Metashape.DepthMapsData as source_data, the script does not work with Metshape.PointCloudData[/b. This seems reasonable since no Pointcloud has been created beforehand (I do this later in my script).

The same approach I use for the surface_type. While Metashape.Arbitrary works, it does not work with Metashape.HeightField. Unfortunately, I could not find any further details what is behind height field.

My question therefore is: What does HeightField mean and most importantly depend on in Python?

Cheers, boulder1998

2
Python and Java API / Re: Processing Big Amount of UAV Data
« on: September 20, 2023, 03:31:57 PM »
Dear Alexey

Thank you for your answer.
The problem has been solved.

To complete this topic:
I was running Python on VSC and that on a MacBook Air M2, 2022 with Ventura 13.5.2.
I add the pictures to a chunk in a separate function after opening a psx file and then the match photos part comes in.
Pictures were stored on a local drive.

The issue was that I used progress=progress_print  function that I learnt of in the Post: Topic: Progress Callback function/Progress Bar? (https://www.agisoft.com/forum/index.php?topic=15676.msg67875#msg67875)
This seems to work on my computer for a view pictures but my laptop cannot handle more than 60 pictures when having this running as well.
I got rid of this progress information and now it seems to work as I want also with more pictures.

Cheers, boulder1998

3
Python and Java API / Processing Big Amount of UAV Data
« on: September 10, 2023, 07:32:05 PM »
Dear community,

I am currently working on a project where I use UAV pictures (10 to 15 MB per picture) to gain DEM models of rivers. The goal would be to process about 300 - 500 pictures.
My python code using the workflow (matchPhotos, alignCameras, buildDepthMaps, buildModel)  that I've written struggles when using chunk.matchPhotos when I use about 100 photos. When I use less photos (about 50) it will struggle at the step chunk.buildModel. With struggle I mean that the processing will stop and in my case Visual Studio Code freezes/crashes.
Using over 150 photos will lead to a RuntimeError: too many open files.

I am working with a MacBook Air (Memory 16GB, Apple M2 chip) and with the 1.82 Visual Studio Code version using Python 3.10.9. Not sure if it is a VSC or Metashape problem.

Any ideas how I can fix this and especially how it will be possible to create the 3D models/DEMS with many more pictures?

Thank you!

Cheers boulder1998

4
Python and Java API / Renaming .psx project and the .files folder
« on: July 27, 2023, 06:57:51 PM »
Dear all,

Does somebody know how I can edit the file name of the .psx project and the .files folder after running several Metashape functions?

As far as I understand I have to give the project an initial name to even be able to run the Metashape functions and store all the data needed to produce e.g. an orthomosaic.   

Now, my goal is to rename the project and the folder according to what kind of Metashape products I have generated. Meaning, that the final name of the .psx project and the .file folder should tell me if for example I generated an orthomosaic in this specific project or not. For that I have to change the name of both files. Any suggestions?

Thank you for your help.

Cheers, boulder1998

5
Python and Java API / Progress Callback function/Progress Bar?
« on: July 06, 2023, 03:37:43 PM »
Hello everybody,

I am working on a python Metashape script in Visual Studio Code using Jupyter Notebooks on a MacBook Air M2 with 16GB Memory.
I want to know how long each Metashape task/function (e.g. matchPhotos, buildModel, buildDEM, etc.) in my code is going to take.
I've started to use the following suggestion by Alexey from a few years back:

Hello kingd0559,

The simple example of callback function usage is below:
Code: [Select]
def progress_print(p):
        print('Current task progress: {:.2f}%'.format(p))

chunk = PhotoScan.app.document.chunk
chunk.matchPhotos(progress=progress_print)

It will print the current progress to the console for the image matching operation.

However, applying this function for example to buildUV or buildModel will make VSC go to a kinda "freeze" mode and it's hard to do anything until the task is done, this with only a view pictures as a trial basis. Plus, the cell outputs and hence, also the progress, is not properly displayed anymore.
Has someone experienced a similar situation and knows what one can do about it, especially for bigger projects?

-------------

In the discussion where I found the above, there was also the following idea by Alexey that I like:
And another simple example that may be helpful for those who want also to estimate the time left for the current operation based on the spent time and current progress value:

Code: [Select]
import time, PhotoScan
def progress_print(p):
        elapsed = float(time.time() - start_time)
        if p:
            sec = elapsed / p * 100
print('Current task progress: {:.2f}%, estimated time left: {:.0f} seconds'.format(p, sec))
else:
print('Current task progress: {:.2f}%, estimated time left: unknown'.format(p)) #if 0% progress

chunk = PhotoScan.app.document.chunk
global start_time
start_time = time.time()
chunk.matchPhotos( progress=progress_print)

Changing PhotoScan to Metashape did not the job. Is there an updated way to do this for Metashape version 2.0.1? maybe even with adding a progress bar?  ;)

Thank you for replies.

Cheers, boulder1998

6
Python and Java API / Re: Accessing Function Parameters Information
« on: June 29, 2023, 04:39:54 PM »
Hi Alexey and Paolo

Thanks for your responses.

For the suggestion of Alexey: This goes in the right direction.
it is unfortunately not working for me. Maybe I've missed something additionally. Do I have to consider some further specifications/classes/functions that meta works? And would .meta apply for everything that is related to chunks => e.g. chunk.buildDEM.meta, chunk.point_cloud.meta?

Further, my interest lies also in the "translation" of for example downscale = 1, that would give a certain accuracy =high. I want to extract this translation information. So, the functions do this but I cannot extract it into a log file. So maybe for that there is even a better solution?

For the suggestion of Paolo: similar thing... key() gives me errors.

Thanks.

7
Python and Java API / Accessing Function Parameters Information
« on: June 28, 2023, 10:50:11 AM »
Dear all

I am currently working on a Metashape python workflow to analyse what are the best parameters to use for my project. I've noticed that many functions, such as the following, will put out a summary of the parameters used when finished running. I would like to log this information in a log file.

Example:
Code: [Select]
chunk.matchPhotos(keypoint_limit = 40000, tiepoint_limit = 10000, generic_preselection = True, reference_preselection = True)
doc.save()

This will give me following information that I want to log:
MatchPhotos: accuracy = High, preselection = generic, reference, keypoint limit = 40000, keypoint limit per mpx = 1000, tiepoint limit = 10000, apply masks = 0, filter tie points = 1, filter stationary points = 1, guided matching = 0

How do I access/extract this information to eventually get a list of all the parameters used for the individual functions in my python script?

Thank you!


Pages: [1]