Forum

Author Topic: Refine marker location with python scripts  (Read 259 times)

xinglei

  • Newbie
  • *
  • Posts: 4
    • View Profile
Refine marker location with python scripts
« on: January 18, 2019, 11:23:14 AM »
Hi!

I detected Non-coded targets(Circle markers), and I want to refine the calculated marker positions( inaccurate detection). But there are too many calculated positions, redefining them takes me a lot of time.

Is there a function can solve this problem in python?

Thanks!
 

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 9869
    • View Profile
Re: Refine marker location with python scripts
« Reply #1 on: January 18, 2019, 01:26:28 PM »
Hello xinglei,

Do you have any information regarding the measured locations of the non-coded targets? If you have a list of the targets, you can import reference data from CSV file using "ignore labels" parameter, that should automatically compare the detected non-coded targets (distribution of the marker instances in space) with the distribution of the points in the CSV file and automatically assign the labels to the corresponding points.
Best regards,
Alexey Pasumansky,
AgiSoft LLC

xinglei

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Refine marker location with python scripts
« Reply #2 on: January 18, 2019, 04:07:55 PM »
Hello Alexey!

Thanks for your help. I have no any information regarding the measured locations of the non-coded targets.I just want to change marker icon  [1.bmp]  to icon  [1.bmp]  automatically.

Best regards,
XingLei
« Last Edit: January 18, 2019, 04:10:12 PM by xinglei »

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 9869
    • View Profile
Re: Refine marker location with python scripts
« Reply #3 on: January 21, 2019, 01:22:14 PM »
Hello Xing Lei,

In order to place the pinned projection in the suggested location defined by other projections (and indicated by the gray flag), please use the following code:

Code: [Select]
import Metashape
chunk = Metashape.app.document.chunk #active chunk
for marker in chunk.markers:
for camera in chunk.cameras:
if camera in marker.projections.keys():
continue #skipping cameras that already do have projections
if not camera.transform:
continue #skipping Not Aligned cameras
       
x, y  = camera.project(marker.position)
if (0 <= x < camera.sensor.width) and (0 <= y < camera.sensor.height):
marker.projections[camera] = Metashape.Marker.Projection(Metashape.Vector([x,y]), True)
Best regards,
Alexey Pasumansky,
AgiSoft LLC