Hello,
I've incorporated the code from here;
https://www.agisoft.com/forum/index.php?topic=7543.0In to a script I'm putting together, that also utilises the MC32 script found here;
https://www.lancaster.ac.uk/staff/jamesm/software/sfm_georef.htmI'm trying to automate the process of ensuring the bounding box is larger than the point cloud for the Monte Carlo analysis to run successfully (both python scripts runs flawlessly within Photoscan/Metashape) but when I'm running the analysis through SfM_Georef, anywhere between 50-90% of the Monte Carlo iterations are rejected due to the bounding box being too small.
Is there a way to say, add 20% or 20m in the X,Y, and Z of the box within this?;
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
coord.size = 3
coord = chunk.crs.project(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(chunk.crs.unproject(center))
region.size = size * (1 / T.scale())
v_t = T * PhotoScan.Vector( [0,0,0,1] )
v_t.size = 3
R = chunk.crs.localframe(v_t) * T
region.rot = R.rotation().t()
chunk.region = region
print("Script finished.")
Report to moderator Logged
Cheers,
Leon