Author Topic: Marker removal iteration  (Read 4461 times)


  • Newbie
  • *
  • Posts: 4
    • View Profile
Marker removal iteration
« on: May 10, 2015, 09:54:04 PM »
Greetings all,
I am working on testing the importance of ground control density and configuration in model creation.  To do this I would like to create a model with GCPs then use some python script to withhold several different GCP configurations and have different exports, such as camera OPK, and DEMs. 

I am pretty new to python but have experience with program R and Matlab.   I am able to run basic model with Agisoft in Python, but am unsure how to go about a few things. 

How does one turn on and off markers in python code?
I would like a script to load a *.psz, turn off a few gcps, optimize, and run the model again, so I see this heading towards a loop of sorts. 

Any tips would be great.  Thanks!

Code: [Select]
import os
import PhotoScan

# Define: Home directory (later this is referred as ".")
HomeDirectory = "F:\\Backyard_Experiment\\time1"

# Set home folder

doc ="time1.psz")
chunk = doc.chunk

# Remove markers
???? something along the lines of

M.projections[P] = None  #but I don’t know which images the GCPs are in.  This ideally will be randomly generated points. 

Could one have the markers set in Agisoft, then import different csv’s with a subset of the points, so not all GCPs would have a xyz with them.

# If I wanted to have k4=TRUE how do I add that?

chunk.matchPhotos(accuracy=PhotoScan.HighAccuracy, preselection=PhotoScan.GenericPreselection)
chunk.buildModel(surface=PhotoScan.Arbitrary, interpolation=PhotoScan.EnabledInterpolation)
chunk.buildTexture(blending=PhotoScan.MosaicBlending, size=4096)

# Define: Cameras output file – loop to create dynamic names needed….
CamerasOPKFile = ".\\CameraOrientations_PhotoScan.opk"

#  I am doing something wrong here……?
chunk.exportCameras(CamerasOPKFile, "opk", chunk.projection, 'xyz')

#…..Export DEM?
GroundAlt = GroundAlt / N_points
# calculate Ground sampling distance
GroundSamplingDistance = math.fabs(CamAlt-GroundAlt) / focal_length
# round it to next millimeter
GroundSamplingDistance = math.ceil(GroundSamplingDistance * 1000)/1000

print("---Exporting Digital Surface Model(s)...")
for Resolution in DSMResolutions:
   if Resolution == 0:
      Resolution = GroundSamplingDistance
   FileName = ".\\DSM_PixelSize=" + str(Resolution) + "m.tif"
   print("File: " + FileName)
   if not(chunk.exportDem(FileName, format="tif", dx=Resolution, dy=Resolution, projection=chunk.projection)):
      app.messageBox("Exporting DSM failed: " + FileName)
« Last Edit: May 10, 2015, 09:58:33 PM by Cowboy_2 »

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14342
    • View Profile
Re: Marker removal iteration
« Reply #1 on: May 11, 2015, 11:24:20 AM »
Hello Cowboy_2,

Operation of checking/unchecking of the marker instance in the Reference pane can be performed using marker.reference.enabled flag from Python API.
Best regards,
Alexey Pasumansky,
Agisoft LLC


  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Marker removal iteration
« Reply #2 on: May 13, 2015, 12:14:20 AM »
Thanks for the quick reply Alexey,

Sorry for my ignorance, but I am unsure how to use that code.  If I have markers named (point 1, point 2, and so on) where do I designated which marker to turn on and off?

Import PhotoScan

maker.reference.enabled = point 1?

I have been working to try and understand Python better, but haven't found an easy resource to use to aid me in understanding the Agisoft/python scripting. 

thanks again!


  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Marker removal iteration
« Reply #3 on: August 12, 2015, 01:14:34 AM »
You may use something like
Code: [Select]
for marker in chunk.markers:
    if marker.label == 'point 1':
        marker.reference.enabled = False
in order to uncheck a marker called 'point 1'. If you have a variable pointing to that marker, you could also just use its reference.enabled attribute and set it to False.

Hopefully this is what you were looking for.