Hello Everyone,
I have used the projected markers and the GCP's to get the error of markers. I have used ETRS89 / UTM zone 32N (N-E) (EPSG::3044) coordinate system. But I get a huge error. I have also attached the code for projecting marker and to get the error. Kindly help me to reduce the error of the markers projected. Thank you.
ch = Metashape.app.document.chunk
chunk = Metashape.app.document.chunk
out_crs = Metashape.CoordinateSystem("EPSG::3044")
for camera in chunk.cameras:
if camera.reference.location:
camera.reference.location = Metashape.CoordinateSystem.transform(camera.reference.location, chunk.crs, out_crs)
for marker in chunk.markers:
if marker.reference.location:
marker.reference.location = Metashape.CoordinateSystem.transform(marker.reference.location, chunk.crs, out_crs)
chunk.crs = out_crs
# file = open('C:\\Program Files\\Agisoft\\Metashape Pro', "markers_projections_rgb_center.txt") #input file
file = open("marker_center_A_Manual.txt") #input file
eof = False
line = file.readline()
if not len(line):
eof = True
while not eof:
sp_line = line.rsplit(",", 3) #splitting read line by four parts
y = float(sp_line[3]) #y- coordinate of the current projection in pixels
x = float(sp_line[2]) #x- coordinate of the current projection in pixels
path = sp_line[0] #camera label
marker_name = sp_line[1] #marker label
flag = 0
for i in range (len(ch.cameras)):
if ch.cameras[i].label == path: #searching for the camera
for j in range (len(ch.markers)): #searching for the marker (comparing with all the marker labels in chunk)
if ch.markers[j].label == marker_name:
ch.markers[j].projections[ch.cameras[i]] = Metashape.Marker.Projection(Metashape.Vector([x,y]), True) #setting up marker projection of the correct photo)
flag = 1
break
if not flag:
marker = ch.addMarker()
marker.label = marker_name
marker.projections[ch.cameras[i]] = Metashape.Marker.Projection(Metashape.Vector([x,y]), True)
break
line = file.readline() #reading the line from input file
if not len(line):
eof = True
break # EOF
file.close()
doc = env.app.document
env_type = 1
#chunk = env.app.document.chunk
#chunk = env.app.document.addChunk()
chunk = Metashape.app.document.chunk
path = "C:\\Program Files\\Agisoft\\Metashape Pro\\ipi-measurement-gcp.txt"
chunk.importReference(path, format = env.ReferenceFormatCSV, delimiter=",", columns="nxyz", create_markers=True)
chunk = Metashape.app.document.chunk
for marker in chunk.markers:
source = marker.reference.location
estim = chunk.crs.project(chunk.transform.matrix.mulp(marker.position))
error = estim - source
total = error.norm()
print(marker.label, error.x, error.y, error.z, total)