Hello,
Can you please check on smaller dense cloud, if the following code provides the desired result and save for each dense cloud point the following information:
point_id, XYZ geographic coordinates and list of cameras and related 2D projections in pixel coordinates:
import Metashape
output = Metashape.app.getSaveFileName("Specify the path to output file:", filter = "*.txt")
chunk = Metashape.app.document.chunk
T = chunk.transform.matrix
crs = chunk.crs
point_cloud = chunk.point_cloud
aligned_cameras = [c for c in chunk.cameras if c.transform and c.type == Metashape.Camera.Type.Regular]
pc_reader = Metashape.PointCloud.Reader()
pc_reader.open(point_cloud)
read_step = 1000
n_points = point_cloud.point_count
file = open(output, "wt")
point_id = 0
for step in range(n_points // read_step + 1 * bool (n_points % read_step)):
points = pc_reader.read(read_step)
for point in points:
point_int = point.position
point_geo = crs.project(T.mulp(point_int))
file.write("{:d},{:.6f},{:.6f},{:.6f}\n".format(point_id, point_geo.x, point_geo.y, point_geo.z))
for camera in aligned_cameras:
vect_2D = camera.project(point_int)
if not vect_2D:
continue
if (0 <= vect_2D.x < camera.sensor.width) and (0 <= vect_2D.y < camera.sensor.height):
file.write("{:s},{:.2f},{:.2f}\n".format(camera.label, vect_2D.x, vect_2D.y))
point_id += 1
file.flush()
pc_reader.reset()
file.close()
print("Done")