GithubHelp home page GithubHelp logo

metashape-scripts's People

Contributors

alexey-pasumansky avatar arbertrary avatar franioli avatar hardway777 avatar jean-roc avatar julesfleury avatar matjash avatar memento42429 avatar pap1956 avatar polarnick239 avatar raj-9952 avatar vineg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

metashape-scripts's Issues

export_for_gaussian_splatting.py "Export Images" checkbox

Would it be possible to add an "Export Images" checkbox in between "Use localframe" and "Image quality" options?

This would be set to true by default but if you need to quickly export the camera files after modifying something then you don't need to export the undistorted images again.

I've duplicated and modified the script by removing the image export params which works, but I'm having trouble editing the script and adding it to the script options, having it included will be very useful.

How to handle import libraries without repeats

I'm running into an issue while testing creating a script similar to those posted here (with the GUI add-ons).

If I import a library (usually one with my utility functions) in my script that is loaded, notice an issue in my code, and then run the script again (creating a second entry in the menu bar, but it's ok for testing), it loads the imported library again as well. This seems to create a mess if I do it a few times in a row with things overwriting each other in a weird manner, but I can't figure out how to stop it.

Right now my code is messy with everything in the single script file to avoid this, but I'd like to know how to compartmentalize it while still being able to test it in the GUI without reopening Metashape each time.

Any suggestions?

python script of the full 3d reconstruction process

Hi, can you share a script of the full process for 3d reconstruction. Maybe the functions are as follows:

  1. In the tool panel -> Workflow → add photos (from a folder)

  2. In the tool panel -> Workflow -> align photos :

  3. In the tool panel -> Workflow -> Build dense cloud :

  4. In the tool panel -> Workflow -> Build Mesh:

  5. In the tool panel -> Workflow -> Build texture:

  6. File → Export → Export mesh→ Export JPEG / TIFF / PNG

or give some detailed explannation for how to use the python API to finish these functions ?

Thanks !

Issue regarding gcp co-ordinate system

I debugged a code, and printed gcp errors individually, i want to know the unit of these errors.
GCP 0 - RMSE_X: 0.213748803, RMSE_Y: 0.285612156, RMSE_Z: 0.000000000
GCP 1 - RMSE_X: 0.672572103, RMSE_Y: 0.653956691, RMSE_Z: 0.000000000
GCP 2 - RMSE_X: 0.649858466, RMSE_Y: 0.552218275, RMSE_Z: 0.000000000
GCP 3 - RMSE_X: 0.223301913, RMSE_Y: 0.362567542, RMSE_Z: 0.000000000

I think these are in pixels, if so how to convert them in meters.Also i want the results in UTM co-ordinate system only.

footprints_to_shapes.py won't work on film camera with fiducial marks

I'm trying to run the footprints to shapes script on older aerial imagery processed using the fiducial marks. I've replaced line 48 to get the pixel coordinates (rounded to the nearest integer) of the fiducial marks in the four outer corners, but the process on line 49 produces coordinates that form a much smaller footprint, often with coordianates that are nearly on top of each other. The script works great on older film imagery I've rotated and cropped in photoshop, so I'm thinking I may need another translational step to account for image rotation and scaling based on the fiducial marks? Any suggestions? FYI, I've been trying this in 1.5.2 and 1.5.3

Thanks.

Split into Chunks Not Building Dense Cloud

Maybe I'm trying to use it incorrectly but it works great to build the mesh once I have my dense cloud. Is there a method to build the dense cloud in the chunks using this script? It just duplicates my chunk once and doesn't build a dense cloud

network_processing.py is incompatible with 1.8.4.14671

line 120 raises the exception:

`AttributeError: 'Metashape.NetworkClient' object has no attribute 'resumeBatch'

I haven't tested older versions, but according to the release notes that method was removed in 1.8.0 so presumably it's been broken for the entire 1.8 series.

setBatchPaused seems to be the replacement for this method and changing it to use that fixes the issue.

footprints_to_shapes.py and pickpoint failure

Hello,
we are trying to use the footprints_to_shapes.py script, but generated footprints are not correct.

The main case where corners are unproject from model fails for many pictures (we are using a model generated from a very sparse point cloud ~ 75 m step with a bounding box that is much wider than the project bouding box as we just need rough footprints, so we would expect that pickpoint is always able to return a ray intersection.)

The fallover case were corners are unprojected from point_cloud do not fai (always return a value)l, but results seems wrong and the resulting footprints do not macth reality at all.

Do you have more details about the pickPont API for both model and dense_cloud ?

Regards

Example Request - A script that Adds text to chunk title or right-click menu

I really like the templates for creating GUI scripts you have made, is it possible to create few more to show how to put items elsewhere in the GUI than the main menu?

I'd really like to add something to the right-click menu for a chunk, or to be able to add custom info to the chunk label (I need the total chunk error displayed on the main label, not in the reference panel).

A few basic examples or the API for adding things to different parts of the GUI would be great. Thanks!

A project will multiple chunks will be deleted except the current chunk

If we have a project with multiple chunks and we set the script as "merge back" it will delete all chunks of the project, regardless they are the ones created for the split or not.
This can be even more problematic if we have set also the option "autosave" and the deletion of the rest of chuks can not be reversed.
This can be obviously a nasty surprise for some users with complex projects, as all chucks of the project will disappear except the one being processed.
Mi recommendation is warn about it in the script menu, or simply only delete the chuks created for the split process and not everything else.

ExportPoints in Metashape

Can someone help me in exporting clipped point cloud using python code in Metashape. I am using 1.6.4 version of Agisoft

Export height map from depth map.

Hi,
as the title says, how do I convert the depth map to height map?

I tried using altoff + depth, but it doesn't seem to be quite right./(ㄒoㄒ)/~~

Location of older Python API Wheels?

Hi,

We have some scripts that use an older version of the Metashape API; some users are using newer versions of the API which causes the scripts to fail. We plan to update the scripts, but for ease we'd also just like to point users to the wheels of the versions we used.

I cannot find the URL containing the wheel for Windows and Linux version 1.8.4, nor can I find a page that easily provides links to all previous releases.

thanks

Gaussian splatting script does not include all tie points (?)

I am using the Gaussian Splatting export script but it seems like all the point3d_id's referenced in points3D.txt do not exist in the IDs in images.txt. However I am not familiar enough with the Metashape API to figure out what the issue is. I would continue to look into this but would appreciate any help in the meantime, thanks!

Attached are some sample reconstruction files demonstrating the issue; I have converted it to .txt format for easy reading.
images.txt
points3D.txt

Error: module 'rembg.bg' has no attribute 'get_model'

Hi,

I am trying to use the automatic_masking script, however while the installation procedure went smoothly when I tried to run the script on my images I got the following error message:

Error: module 'rembg.bg' has no attribute 'get_model'

Any idea how to resolve it?

Basic usage of the Python Module for Aligning pictures, dense point cloud generation etc.

I am getting the following error afterdefining the following.
In line doc = Metashape.document
AttributeError: module 'Metashape.Metashape' has no attribute 'document'

I am using the following code. Please let me know if I am missing something. Also, please correct other mistakes in the code if there are any.
import os
import Metashape
import numpy as np
pa='/home/nys09/'
pat='/home/nys09/Trial1Beamch_arc/'
b=[]
c=os.path.join(pa,"arc_imagelist_t1.txt")
images = open(c,"r+")
a = np.loadtxt(images,dtype=str)
for i in range(np.shape(a)[0]):
b.append(pat+str(a[i]))
doc = Metashape.document
chunk = doc.addChunk()
chunk.addPhotos(b)
camera = chunk.cameras[0]
camera.photo.meta["Exif/FocalLength"]
chunk.matchPhotos(accuracy=Metashape.HighAccuracy, generic_preselection=True,reference_preselection=False)
chunk.alignCameras()
doc.save(path = "project.psz", chunks = [doc.chunk])

Libraries imported in script can't access metashape

I'm trying to create a set of scripts, with one "metashape_util.py" script which is loaded in each of my individual scripts so that I don't have to rewrite much of the code

One big issue I am running into now is that if for example "toolset1.py" has the following code:

import metashape_util

and "metashape_util.py" has the following code:

found_major_version = ".".join(Metashape.app.version.split('.')[:2])

Then when I load "metashape_util.py" with the load script button in the console GUI, I get this error:

2020-03-19 21:44:57 Traceback (most recent call last):
2020-03-19 21:44:57 File "[...]/src/metashape_gliht_tools.py", line 20, in
2020-03-19 21:44:57 import metashape_util as mu
2020-03-19 21:44:57 File "[...]/src/metashape_util.py", line 8, in
2020-03-19 21:44:57 found_major_version = ".".join(Metashape.app.version.split('.')[:2]) #1.5 or 1.6
2020-03-19 21:44:57 NameError: name 'Metashape' is not defined
2020-03-19 21:44:57 Error: name 'Metashape' is not defined

Is there any suggested work around for this?

Metashape.app.document returns NoneType

Every example that calls Metashape.app.document fails because Metashape.app.document returns NoneType. Expect examples to work as listed in the documentation:

import Metashape
chunk = Metashape.app.document.addChunk()
chunk.addPhotos(["IMG_0001.jpg", "IMG_0002.jpg"])
camera = chunk.cameras[0]
camera.photo.meta["Exif/FocalLength"]
Traceback (most recent call last):

  File "<ipython-input-34-087caf902849>", line 2, in <module>
    chunk = Metashape.app.document.addChunk()

AttributeError: 'NoneType' object has no attribute 'addChunk'

System specs:

  • Windows 10
  • Python 3.7.4 64-bit
  • Metashape python api version 1.5 2
  • I do not have Agisoft Metashape installed

handle group in gaussian splatting export / issue with fisheye cam model

Hello,
Request regarding gaussian splatting export python script
as a pinhole model, would it be possible to handle fisheye and frame and handle cam groups as well during the export ?

here with 2 fisheye cameras

each has a fisheye model like that

image

when executing export gaussian splatting

results are like that (note the size of images.bin)
image

the script returns that error handled

2023-11-21 19:39:09 Camera 00457_AR (key = 3457) has unsupported sensor (key = 3)
2023-11-21 19:39:09 Camera 00458_AR (key = 3458) has unsupported sensor (key = 3)
2023-11-21 19:39:09 Camera 00459_AR (key = 3459) has unsupported sensor (key = 3)
2023-11-21 19:39:09 Camera 00460_AR (key = 3460) has unsupported sensor (key = 3)
2023-11-21 19:39:09 Camera 00461_AR (key = 3461) has unsupported sensor (key = 3)
2023-11-21 19:39:09 Camera 00462_AR (key = 3462) has unsupported sensor (key = 3)
2023-11-21 19:39:09 Camera 00463_AR (key = 3463) has unsupported sensor (key = 3)
2023-11-21 19:39:09 Camera 00464_AR (key = 3464) has unsupported sensor (key = 3)
2023-11-21 19:39:09 Camera 00465_AR (key = 3465) has unsupported sensor (key = 3)
2023-11-21 19:39:09 Camera 00466_AR (key = 3466) has unsupported sensor (key = 3)
2023-11-21 19:39:09 Camera 00467_AR (key = 3467) has unsupported sensor (key = 3)
2023-11-21 19:39:09 Camera 00468_AR (key = 3468) has unsupported sensor (key = 3)
2023-11-21 19:39:09 Camera 00469_AR (key = 3469) has unsupported sensor (key = 3)
2023-11-21 19:39:09 Camera 00470_AR (key = 3470) has unsupported sensor (key = 3)
2023-11-21 19:39:09 Camera 00471_AR (key = 3471) has unsupported sensor (key = 3)
2023-11-21 19:39:09 Camera 00472_AR (key = 3472) has unsupported sensor (key = 3)
2023-11-21 19:39:09 Camera 00473_AR (key = 3473) has unsupported sensor (key = 3)
2023-11-21 19:39:09 Camera 00474_AR (key = 3474) has unsupported sensor (key = 3)
2023-11-21 19:39:09 Camera 00475_AR (key = 3475) has unsupported sensor (key = 3)
2023-11-21 19:39:09 Camera 00476_AR (key = 3476) has unsupported sensor (key = 3)
2023-11-21 19:39:09 Camera 00477_AR (key = 3477) has unsupported sensor (key = 3)
2023-11-21 19:39:09 Camera 00478_AR (key = 3478) has unsupported sensor (key = 3)
2023-11-21 19:39:09 Camera 00479_AR (key = 3479) has unsupported sensor (key = 3)
2023-11-21 19:39:09 Camera 00480_AR (key = 3480) has unsupported sensor (key = 3)
2023-11-21 19:39:09 Camera 00481_AR (key = 3481) has unsupported sensor (key = 3)
2023-11-21 19:39:10 Found 0 cropped projections
2023-11-21 19:39:10 Saved 0 calibrations
2023-11-21 19:39:10 Saved 0 cameras
2023-11-21 19:39:12 Saved 408837 points from 408837 tracks
2023-11-21 19:39:12
2023-11-21 19:39:12 Done
2023-11-21 19:39:12 -----------------------------------

Multi-frame chunk, script blocked in the activ frame

Hello,

I want to create a small script to export estimated coordinates from a multi-frame chunk using the function saveReference. So I created a loop as you can see in the following script. The problem is I only obtain the coordinates of the active frame. It create the right number of file but they all have the same coordinates of the frame that is open in Metashape.

I can find anything about that problem so I'll be glad if someone as an idea about this issue.

import Metashape as ms
import os
doc = ms.app.document
path="suivi_reperes/"
i=0
for frame in doc.chunks[5].frames: #I'm only interested in this chunk number 5
file_name=path+'reperes_t'+str(i) frame.saveReference(file_name,PhotoScan.ReferenceFormatCSV,items=PhotoScan.ReferenceItemsMarkers,columns="n,[u|v|w],")
i+=1

Feature Request:Neus camera format

The colmap created by the Gaussian splatting can be used by img2poses.py in https://github.com/Totoro97/NeuS/tree/main/preprocess_custom_data. However, in most cases it will cause "Don't need to run COLMAP
Post-colmap
Cameras 5
Images # 35
Traceback (most recent call last):
File "E:\dataprep\imgs2poses.py", line 17, in
gen_poses(args.scenedir, args.match_type)
File "E:\dataprep\pose_utils.py", line 264, in gen_poses
save_poses(basedir, poses, pts3d, perm)
File "E:\dataprep\pose_utils.py", line 67, in save_poses
cams[ind-1] = 1
IndexError: list assignment index out of range" Or

"Don't need to run COLMAP
Post-colmap
Cameras 5
Images # 55
ERROR: the correct camera poses for current points cannot be accessed
Done with imgs2poses". This means that the output is different from standard colmap output.

export_for_gaussian_splatting.py coordinate Issue

I have a project using WGS / UTM zone 32618 when I export.

the gaussian splatting is jumping all over the place and then settles. This is due to the coordinate system and being very far away from 0,0,0.

I tried changing the coordinate system to local coordinates but the gaussian is just a blurry mess.

Split_in_chunks

I use Metashape Pro for processing large aerial data which takes days to complete in some cases. Power supply is an issue and when there is a power cut, i lose many hours (days) of work since the script does not continue from where it was interrupted.

export model raise problem in mesh Texture

I used the code below to export model:
doc = Metashape.Document()
chunk = doc.addChunk()
chunk.addPhotos(photos)
chunk.matchPhotos(keypoint_limit=40000, tiepoint_limit=10000, generic_preselection=True, reference_preselection=True)
chunk.alignCameras()
chunk.optimizeCameras()

chunk.buildDepthMaps(downscale=2, filter_mode=Metashape.MildFiltering)
chunk.buildModel(source_data=Metashape.DepthMapsData)
chunk.buildUV(page_count=2, texture_size=4096)
chunk.buildTexture(texture_size=4096, ghosting_filter=True)
has_transform = chunk.transform.scale and chunk.transform.rotation and chunk.transform.translation

if has_transform:
    chunk.buildDenseCloud()
    chunk.buildDem(source_data=Metashape.PointCloudData)
    chunk.buildOrthomosaic(surface_data=Metashape.ElevationData)

chunk.exportModel(output_folder + "/model.obj", texture_format=Metashape.ImageFormat.ImageFormatPNG)
chunk.exportCameras(output_folder + "/cameras.xml")

t1 = time.time()
print("Processing finished, results saved to " + output_folder + ".", t1 - t0)

but the texture is not right:
m4OZKFi1R4
can you help me with this problem? @Jean-Roc @VladimirPobedinskiy @PolarNick239 @Vineg @matjash

Copy_bounding_box.py will malfunction if the project has unrelated multiple chunks

The script seems to work in the way that we select and open a chunk. Now If we use the script it will copy the bounding box of any other existing Chunk in the project.
The only way it works OK is if the project only has two Chunks, the origin and a compatible destiny.

If the project has any other unrelated Chunk it generates multiple problems:

  • The script will paste on all them the bounding boxes, no matter his number. Not only that, multiple unrelated Chucks in some way confuses the script and paste a incorrect identical bounding box to all Chunks, even to the original Chunk. That means that if we don't notice it and save we will have all Chunks with a identical incorrect bounding Box.

My suggestion is:

  • If any solution is expensive at least warn about it in the instructions, script or info dialogue.
  • But obviously the ideal solution would be that we can define what is the destiny of the pasted bounding box instead being pasted everywhere. This could be done with a double operation, copy and then paste (with dialogue or two separated scripts).
  • Or as alternative that only paste the original bounding box in the selected Chucks, and leave intact anything else. In this case, we select and open a Chunk and we select (but don't open) the destiny Chuck. Then the script would copy the bounding box of the opened Chunk over the selected Chunk.

Metashape footprint script empty shapefile

I have Metashape Pro 1.5.1 and recently loaded the image footprints script. The menu shows up fine, and when the script runs a footprints group gets created in the left menu, but it's empty and exporting leads to an empty shapefile. Is there any customization to the script that is necessary, and do all images have to be aligned with a mesh and point cloud for this script to do its job properly? Thank you for the development efforts

Merge camera calibration groups by lens type

Is there a script to merge camera calibration groups by lens type?

I understand that the camera calibration groups cameras by camera serial name.
To merge by lens it is a very slow and manual process to select all cameras with the same lens and merge groups.

Does a script exist to do this?

export_for_gaussian_splatting.py Issue with "cropped/unsupported sensors"

I'd like to express my gratitude for the superb conversion scripts you've provided (export_for_gaussian_splatting.py). The rendering results I've achieved using Metashape significantly outperform those from COLMAP.

Nevertheless, I've encountered a couple of challenges:

Cropped/Unsupported Sensors: On certain occasions, I've noticed "cropped/unsupported sensors" messages, even when Metashape successfully aligns all the images.

Incorrect Projection Values: I've debugged the scripts and printed the "unproject" and "project" values for the "right, left, top, and bottom" parameters. Some inconsistencies have been observed. For instance, the left value is greater than the right, and there are extremely large negative values post-projection.

Given these issues, I have a few questions:

Why might these anomalies be occurring?
Is there a recommended approach to rectify them?
If opting for undistortion leads to fewer views, does the script offer an option to bypass the undistortion step?
I'd appreciate any insights or guidance you can provide on this matter. Thank you in advance!

@PolarNick239

split in chunks script not working

Hello there,

I am a newbie to using scripts,

I have 1250 photos to proecess and to prepare DEM and Orthophoto however since my hardware limits me up I wanted to split my work into chunks to work fluently without any crashes

I aligned all the photos firstly and then I used the script split in chunks however split in chunks command only does duplicate my dataset but nothing all

I am using Agisoft Metashape 1.8

Any help would be appreciated .

Error del script footprints_to_shapes.py

Hola, he intentado usar el script footprints_to_shapes.py con buenos resultados con pocas fotos, pero cuando intento hacerlo en un proyecto con 15000 imágenes el programa no responde y se cuelga.

Can't load script, "ImportError: No module named 'PySide2'

I can't load split_in_chunks_dialog.py on one of my installs of Metashape.

2020-01-28 11:22:09     from PySide2 import QtGui, QtCore, QtWidgets
2020-01-28 11:22:09 ImportError: No module named 'PySide2'
2020-01-28 11:22:09 Error: No module named 'PySide2'

It seems the python install doesn't have PySide2 library available, but where should it be installed?

This is if I load the script in via the Console in Metashape 1.5.1

split_in_chunks_dialog always mess the bounding boxes

The result of this script is always a messed bounding box. This can be currently solved with the script included in the package where we can copy back the old bounding box from the original model.

It would be nicer and more elegant if this could be done automatically after merged the pieces. Having said that there is a clear workaround as explained.

bounding_box_to_coordinate_system.py

hello,I want to use python scripts in photoscan, but I met some problems, could I get some help?
you use it in release 1.4, so could I use in Release 1.2, or should I update my photoscan?
then, how to use these scripts? when i use the tools->run scripts, nothing happened.
thanks for your reply.

split_in_chunks_dialog.py doesn't split the chunk?

I tried running this script in Metashape 1.5.1, but it seems to just duplicate my chunk (I set a 2 x 2 split as test), with all photos in each one.

I'm looking through the code and can't figure out at what point it actually does any splitting. I see it is recalculating the region, but it seems to have no effect?

Way to remove/replace custom menu items?

Is there a way to remove existing menu items? While debugging it gets messy if I keep uploading them several times.

Ideally just hold on to a reference for the newly added item and delete it with QtWidgets would work? Not sure how to find that though for an item I've added.

Export all depth map levels

Hi,
The line code "depth = chunk.depth_maps[camera].image()" gets the depth map level 1. How can I get all depth map levels?
Thank you in advance :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.