Forum

Author Topic: how can I rename the maker label in rectangular array shape using python script?  (Read 1205 times)

lyhour

  • Newbie
  • *
  • Posts: 41
    • View Profile
Excuse me everyone, I use the automatic detection function in agisoft api. Thus, I get the label of each marker. However, I want to rename the label in the order as in the figure attachment. How can I do it in python script ?

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14847
    • View Profile
Hello lyhour,

Are the markers in your projects already aligned to some plane (XY, XZ or YZ)? And is the number of markers per line known in advance?
Best regards,
Alexey Pasumansky,
Agisoft LLC

lyhour

  • Newbie
  • *
  • Posts: 41
    • View Profile
Dear Alex,

Thank very much. I solve it already. I am writing this script to rename it. Do you have alternative coding ?
Code: [Select]
#---- rename the maker corresponding to coordinate by sort algorithm
xy_coord = list()
for marker in chunk.markers:
x_tmp,y_tmp,z_tmp = chunk.crs.project(chunk.transform.matrix.mulp(marker.position))
xy_coord.append([x_tmp,y_tmp])
tmp_coord = sorted(xy_coord, key=lambda k: [k[0], k[1]]) # sort coordinate base on x axis first.
k = 0
for i in range(len(tmp_coord)):
k += 1
for marker in chunk.markers:
x,y,z = chunk.crs.project(chunk.transform.matrix.mulp(marker.position))
if x == tmp_coord[i][0] and y == tmp_coord[i][1]:
marker.label = "gcp" + str(k)
break