I am running into an issue fairly often that the pointcloud created with python is inaccurate, in some cases by meters. The same cameras run through the GUI (with a batch process) is giving accurate results consistently.
Attached are side by side:
Camera location reports, LHS python with 2.5Meter camera location errors, and RHS Batch Processed with 5cm camera location errors.
Of note (?) when I open the python processed project, it lists all of the camera accuracies as 10m, whereas the batch processed project lists updated accuracies for each camera.
Metashape gui opened after running python workflow on LHS, batch processed project on RHS
Batch process xml attached. Python below.
Any help is appreciated.
chunk = doc.addChunk()
chunk.addPhotos(photos)
coordinateSystem = "COMPD_CS[\"CCMP + Geoid09\",PROJCS[\"GDA94 / MGA zone 55\",GEOGCS[\"GDA94\",DATUM[\"Geocentric Datum of Australia 1994\",SPHEROID[\"GRS 1980\",6378137,298.257222101,AUTHORITY[\"EPSG\",\"7019\"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY[\"EPSG\",\"6283\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.01745329251994328,AUTHORITY[\"EPSG\",\"9102\"]],AUTHORITY[\"EPSG\",\"4283\"]],PROJECTION[\"Transverse_Mercator\",AUTHORITY[\"EPSG\",\"9807\"]],PARAMETER[\"latitude_of_origin\",0],PARAMETER[\"central_meridian\",147],PARAMETER[\"scale_factor\",0.9996],PARAMETER[\"false_easting\",500000],PARAMETER[\"false_northing\",10000000],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],AUTHORITY[\"EPSG\",\"28355\"]],VERT_CS[\"AHD height\",VERT_DATUM[\"Australian Height Datum\",2005,AUTHORITY[\"EPSG\",\"5111\"]],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],AUTHORITY[\"EPSG\",\"5711\"]]]"
Metashape.CoordinateSystem.addGeoid(input_directory + "\\AUSGeoid09.tif" )
try:
my_sensor = chunk.sensors[0]
my_sensor.type = Metashape.Sensor.Type.Frame
my_calib = Metashape.Calibration()
my_calib.width = my_sensor.width
my_calib.height = my_sensor.height
my_calib.load(str(cameraCalibration[0]), format=Metashape.CalibrationFormatXML)
my_sensor.user_calib = my_calib
except IndexError as e:
print("Problem loading camera calibration .xml from project folder, press enter to continue anyway")
input()
for camera in chunk.cameras:
camera.sensor = my_sensor
chunk.matchPhotos(progress = progress_print, keypoint_limit = 70000, tiepoint_limit = 7000, downscale=0, generic_preselection = True, reference_preselection = True, reference_preselection_mode=Metashape.ReferencePreselectionSource, filter_mask=False, filter_stationary_points=True, keypoint_limit_per_mpx=1000, guided_matching=False, )
chunk.alignCameras(progress = progress_print, adaptive_fitting = False, reset_alignment = False)
chunk.buildDepthMaps(progress = progress_print, downscale = 8, filter_mode = Metashape.NoFiltering)
chunk.buildPointCloud(progress = progress_print, source_data=Metashape.DepthMapsData, point_colors=True, point_confidence=False,
keep_depth=True, uniform_sampling=True, points_spacing=0.05)
if chunk.point_cloud:
chunk.exportPointCloud(output_folder + '/' + projectName + '.laz', crs = Metashape.CoordinateSystem(coordinateSystem), format = Metashape.PointCloudFormatLAZ, source_data = Metashape.PointCloudData)