1
Python and Java API / Marquee select and remove
« on: June 06, 2023, 08:16:37 AM »
Hi i was wondering if there was a script to define a marquee selection across multiple chunks to remove?
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.
import Metashape, math
doc = Metashape.app.document
chunk = doc.chunk
region = chunk.region
T = chunk.transform.matrix
m = Metashape.Vector([1E+1, 1E+1, 1E+1])
M = -m
for point in chunk.point_cloud.points:
if not point.valid:
continue
coord = T * point.coord
for i in range(3):
m[i] = min(m[i], coord[i])
M[i] = max(M[i], coord[i])
center = (M + m) / 2
size = M - m
region.center = T.inv().mulp(center)
region.size = size * (2 / T.scale())
region.rot = T.rotation().t()
chunk.region = region
print("Script finished.")
import PhotoScan
import Metashape
import sys
def_recunc = 15
paramNo = len(sys.argv)
recunc = float(sys.argv[2] if paramNo == 5 else def_recunc)
for chunk in PhotoScan.app.document.chunks:
f = PhotoScan.PointCloud.Filter()
f.init(chunk, Metashape.PointCloud.Filter.ReconstructionUncertainty)
f.removePoints(recunc)
print("ReconstructionUncertainty Level: ")
print(recunc)
import PhotoScan, math
doc = PhotoScan.app.document
chunk = doc.chunk
region = chunk.region
T = chunk.transform.matrix
m = PhotoScan.Vector([10E+10, 10E+10, 10E+10])
M = -m
for point in chunk.point_cloud.points:
if not point.valid:
continue
coord = T * point.coord
for i in range(3):
m[i] = min(m[i], coord[i])
M[i] = max(M[i], coord[i])
center = (M + m) / 2
size = M - m
region.center = T.inv().mulp(center)
region.size = size * (5 / T.scale())
region.rot = T.rotation().t()
chunk.region = region
print("Script finished.")