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

Pages: [1]
1
Python and Java API / Sharing my Python Script collection via Github
« on: October 26, 2021, 05:39:36 PM »
Hello!

I wanted to share my python script collection via github. I learned a lot from this forum and couldn't of created the scripts without the help I got here. I did my best to include the links to the forum in each relevant script, but I'm new to coding so let me know if I should cite them differently. Scripts can be found here:

https://github.com/campbell-ja/MetashapePythonScripts

I work in cultural heritage so that is the focus of my workflow. Hope these help anyone else like me that is just starting out!

What the scripts cover:

1. Automate Alignment/Image Matching
2. Automate Depthmap/Dense cloud
3. Automate locating markers as well as marker error optimization to remove markers with error values over defined threshold  - as well as - remove markers with projections under a specific threshold (my favorite)
4. Automate point cloud filtering and point cloud error optimization to a defined threshold ( my other favorite )
5. Automate generating Mesh along with derivative meshes at set decimated face values for full resolution, rendering, 3D printing, and web use.
6. Automate generating Textures, including Diffuse, Normal Maps, and Ambient Occlusion maps for each mesh in chunk
7. Automate generating Othromosaic renderings.
8. Automate output of all generated models and texture files.


2
Thank you Alexey and thank you Dieter!

I updated to 1.7.1 and applied the advanced setting tweak and it looks great. No more fuzz.

follow up questions :

Is there any general rule of thumb for setting the max_neighbors setting?

and when using python, would there be any negative side effect (other than processing time) of setting this value to something like 1/3rd the total image count? So if I have 900 images i would set max_neighbors to 300 programmatically for example.


Thank you again!

3
Hello,

At the dense cloud phase I am getting wild results I've never seen before. the sparse cloud is clean after optimization and gradual selection, but the subject matter in the dense cloud is surrounded by a chaotic mess of points. Please see attached images for visual which also includes the chunk info and analysis showing all the processing options I used.

I did not use Masks when processing, which I assume would resolve some of the issue. but I am curious to know why this happens at all.

About the data set:

  • The source images are from a Canon 5D MK IV with 35mm, 50mm and 100mm lenses ( testing 100mm lens for fine details on object ).  All camera and lens combinations were imaged from roughly the same measured distance, but this was not a turntable setup. so the camera moved around the object and there is some minor variance in the distance between subject and sensor among the images.
  • The RAW files were converted as 16bit tiff using Rawtherapee and AMAZE demosaicing. Only adjustments were to lighten shadows and minor input sharpening to remove blur from anti-aliasing filter built into camera.
  • The sparse cloud is cleaned via Gradual selection. First reprojection uncertainty ( threshold 10), Second projection accuracy (threshold 3.0), finally reprojection error is iterated until Max RMS error for the chunk is 0.3 or less. Between each gradual selection filter step the cameras are optimized.

When I run the dense cloud with Aggressive filtering, it helps, but doesn't fix completely. I am used to getting some 'fuzz'  in the dense cloud but never like this before.

If I can do a better job of explaining the issue then please let me know. Attached screen shots are here to help.

Thanks!





4
Thank you Paulo!

This was very helpful and makes complete sense to the difference I was seeing. I appreciate the code as it helped spell out some of the logic I was missing as well.

My only question about all of this, is how to conceptualize the 'track_id' and what exactly are camera tracks? I thought they were a path the camera travels around an object or through a space. but I dont understand the relation to the point_cloud under the hood in Metashape and the need to access a projection track_id for this scenario.

If you have time, could you elaborate on the need for the track_id?

Specifically, I am not 100% sure why we would need the track_id here:

Code: [Select]
for point_id in range(0, npoints):
    point_ids[points[point_id].track_id] = point_id


and here:

Code: [Select]
for proj in projections[camera]:
track_id = proj.track_id
point_id = point_ids[track_id]
if point_id < 0:
continue
if not points[point_id].valid:
continue


thank you again for your time.



5
Hello,

I have found this post very useful while working on a similar process:

https://www.agisoft.com/forum/index.php?topic=10564.msg47949#msg47949

The script defined in the post will give you the RMS reprojection error and the MAX reprojection error. which you can also find in the GUI by right clicking the active chunk -> show info


Best,
joacampb

6
Hello,

I've been digging through the forum and documentation for a day or so, and I am wondering if its possible to get the count of projections per camera? Which would be the value reported in the Reference pane under 'Projections'.

My goal, is to disable any camera with a projection count less than 200.

So something like:
Code: [Select]
for camera in chunk.cameras:
    if (point_cloud.projections[camera]) < 200:
        camera.enabled = False


I am pulling from this post as inspiration: https://www.agisoft.com/forum/index.php?topic=10564.msg47949#msg47949

Code: [Select]
for camera_id, camera in enumerate(Metashape.app.document.chunks[1].cameras):
    projections = Metashape.app.document.chunks[1].point_cloud.projections[camera]
    print(camera, len(projections))

Output:
Quote
2020-11-15 13:00:58 <Camera '_SPK4758'> 1272
2020-11-15 13:00:58 <Camera '_SPK4759'> 972
2020-11-15 13:00:58 <Camera '_SPK4760'> 716
2020-11-15 13:00:58 <Camera '_SPK4761'> 937


I've tried different variations, such as looping through the projections per camera but its the same result as above using the len() function. the value at the end of each loop never matches the Reference Pane

the attached image shows the reference pane next to the console output for the above code. The reference pane says 810 projections for camera _SPK4758, whereas the code says 1272 projections.


So it seems obvious I don't fully understand the point_cloud.projections class and data

Any guidance would be appreciated.



7
Thank you for clarifying Alexey!

the additional code worked.

8
Thanks for the response, afraid I get a NameError when trying that:

Code: [Select]
>>> doc.chunks[1].model
2020-10-07 09:35:49 <Model '290979 faces, 147674 vertices'>
>>> doc.chunks[1].model = none
2020-10-07 09:36:05 Traceback (most recent call last):
2020-10-07 09:36:05   File "<console>", line 1, in <module>
2020-10-07 09:36:05 NameError: name 'none' is not defined

Is this something that needs to happen before ANY model is created?

9
Python and Java API / How to build multiple models for single chunk?
« on: October 06, 2020, 07:48:53 PM »
Hello,

I would like to create a High-res model, and then also create a Low-res model. but running the .buildModel() method twice, always overwrites the existing 3D model. When using

Code: [Select]
chunk.buildModel(face_count=Metashape.LowFaceCount)

How do you prevent overwriting any pre-existing 3D models in a chunk?


From the documentation :
Quote
New components can be created using corresponding addXXX methods (addSensor, addCamera, addCamera-Group, addMarker, addScalebar, addFrame). Removal of components is supported by a single remove method,which can accept lists of various component types.


So I would need to use '.addModel()' to add a second model to the chunk? Which would make sense, but how do I then build the second model into the new 'empty' reference created by .addModel()?

Also, is there a definition of the concept of 'frames' for Metashape Python somwhere? I am also trying to figure out if I have to create a new frame for the second model to reside in? -I found an explanation in the official manual so I get frames now.

Any guidance would be appreciated.



* I am using Metashape 1.6.2 and Windows 10.





10
Hello,

new to 3D but I can get around in Blender/Maya and have been using Photoscan for just under a year.

In Photoscan, when you set scale with the scale markers, how does that change or effect the coordinate system? Does the set scale travel with an exported model? Or is it lost in other programs..like a 3D Printer program for example.

What is the difference in the coordinate system before and after the scale markers are applied? do they change the local coordinate system, the global, or both?

Very curious to know what is exactly going on when scale is set via markers.

Thanks.

Using Photoscan 1.4

11
Thanks for looking into this.

I attached the output from the console. Hope that is enough.

During processing , photoscan is the only major program running. background processes include MSI Afterburner, a monitor calibration program ( dispcal/ argyllCMS) and Windows Defender.

I will have to run a report from NVIDIA-SMI later today when I am with the machine.

thank You!

12
New to Photoscan.

Working with about 900 images of a statue.

I broke the images up into two chunks.

I can align and then optimize cameras just fine.

However, during the dense cloud workflow step for either chunk I keep getting the following error:

Quote
2017-06-15 09:08:47 Depth reconstruction devices performance:
2017-06-15 09:08:47  - 2%    done by CPU
2017-06-15 09:08:47  - 97%    done by GeForce GTX 1070
2017-06-15 09:08:47 Total time: 280.894 seconds
2017-06-15 09:08:47
2017-06-15 09:08:47 Warning: all CUDA-capable devices are busy or unavailable
2017-06-15 09:08:48 Warning: all CUDA-capable devices are busy or unavailable
2017-06-15 09:08:49 Error: 2017-06-15 09:08:49 Saving project...
unspecified launch failure at line 217
2017-06-15 09:08:49 saved project in 0.016 sec


Its not every time. But its enough to prevent me from completing this model for the last two weeks.

I have successfully created over 10 models, and sometimes this will happen. but for this specific model I am really having a hard time.

Any idea where I can start trouble shooting?

My machine:

Windows 10 Pro.
AMD FX-8350 CPU
GeForce GTX 1070 graphics card
MSI Gamining 970 mother board
32 GB RAM
All SSD

I am using the newest version of Photoscan.

Thanks.

Pages: [1]