Forum

Author Topic: Creating Markers by using python script  (Read 6076 times)

StevenShi

  • Newbie
  • *
  • Posts: 9
    • View Profile
Creating Markers by using python script
« on: July 25, 2017, 02:24:47 PM »
We are working on a project that import some 2D points on capture image as markers in PhotoScan,then got the 3D coordinates of these 2D points on processed model.All the process was done by using python script.

Now,we got some troubles.If we import markers via an txt file,the txt file includes the 2D coordinates on image.We use this way(marker.projection[camera] = (imgX,imgY)) to add marker on image,but it can't estimated the marker's position on other image unless you use the Right+Click>Create Marker on one image.Right click way can estimate the marker's position on other image automatically.

How to use python script to achieve the same effect in using the Right+Click>Create Marker. Just add marker on one image,then estimate the marker's position on other image automatically.

By the way,I confuse about the new python script API Utils.createMarkers(chunk,projections) method,the document show that projections parameter is the list of(camera,x,y,r)tuple,what's the r mean? 

Thanks

StevenShi

tuqubao

  • Newbie
  • *
  • Posts: 3
    • View Profile
how to creating Markers by using python script ?
« Reply #1 on: July 27, 2017, 03:50:46 PM »
We are working on a project that import some 2D points on capture image as markers in PhotoScan,then got the 3D coordinates of these 2D points on processed model.All the process was done by using python script.

Now,we got some troubles.If we import markers via an txt file,the txt file includes the 2D coordinates on image.We use this way(marker.projection[camera] = (imgX,imgY)) to add marker on image,but it can't estimated the marker's position on other image unless you use the Right+Click>Create Marker on one image.Right click way can estimate the marker's position on other image automatically.

How to use python script to achieve the same effect in using the Right+Click>Create Marker. Just add marker on one image,then estimate the marker's position on other image automatically.

By the way,I confuse about the new python script API Utils.createMarkers(chunk,projections) method,the document show that projections parameter is the list of(camera,x,y,r)tuple,what's the r mean? 

Thanks

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14839
    • View Profile
Re: Creating Markers by using python script
« Reply #2 on: July 27, 2017, 04:00:04 PM »
Hello StevenShi,

In order to reproduce the behavior of guided marker placement approach (Create Marker option in GUI), you can use the following code:
Code: [Select]
chunk = PhotoScan.app.document.chunk
camera = chunk.cameras[0]
point2D = PhotoScan.Vector([imgX,imgY]) # coordinates of the point on the given photo
sensor = camera.sensor
calibration = sensor.calibration
x = chunk.point_cloud.pickPoint(camera.center, camera.transform.mulp(sensor.calibration.unproject(point2D)))
chunk.addMarker(point = x)
note that you can use pickPoint also using the dense cloud or mesh as a source, if they are present in the project.




Best regards,
Alexey Pasumansky,
Agisoft LLC

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14839
    • View Profile
Re: Creating Markers by using python script
« Reply #3 on: July 27, 2017, 04:08:09 PM »
As for the createMarker() function, it should be used when you are using the external non-coded target detection algorithm and have only coordinates and radius of the targets for every camera (without knowing the correspondence between the target projections).

So passing such list to the function will run the procedure that will find the correspondences between the loaded projections and create the marker instances. Invalid projections will be discarded. Radius parameter (r) is applicable to the circular targets, and can be specified as zero for cross targets, for example, where radius is not applicable.
Best regards,
Alexey Pasumansky,
Agisoft LLC

StevenShi

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Creating Markers by using python script
« Reply #4 on: August 02, 2017, 01:57:57 PM »
Hello,Alexey Pasumansky,

We tried your python script,it works well,thanks very much.