Forum

Author Topic: Importing 2D marker positions on photos to export estimated 3D marker positions  (Read 4189 times)

JayS

  • Newbie
  • *
  • Posts: 7
    • View Profile
Hello Agisoft Community,

I am working with PhotoScan Pro Version 1.4.0,
I have developed a script to load images and cameras (calibrated position information) into PhotoScan. Now I have a list of 2D coordinates for each image. I want to place a marker at those given locations on each image and then export the estimated position of the marker in 3D. I have read the Python API guide but I am still confused about how to do this. A few community posts suggest the following:

import PhotoScan
doc = PhotoScan.app.document

local_chunk = doc.chunk

## import photos and cameras ... ##

marker = local_chunk.addMarker()
marker.projections[local_chunk.cameras[0]] = (100,100)

But this produces a TypeError: invalid item value

Also, is there anyway I can import a text file or something with all of the marker positions for each camera and do this?
Finally, I just want to add that I have NOT created a mesh or point cloud as I only care about getting the estimated position of these markers in 3D

Thanks,
- Jay S






Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14853
    • View Profile
Hello Jay,

You need to correct the projection assignment line as following:
Code: [Select]
marker.projections[local_chunk.cameras[0]] = PhotoScan.Marker.Projection((100,100), True)
The Boolean flag means, whether the projection is pinned (True) or not (False).
Best regards,
Alexey Pasumansky,
Agisoft LLC

JayS

  • Newbie
  • *
  • Posts: 7
    • View Profile
Hello Alexey,

That worked!
I can see the rays and all of my markers were placed on each image. For some reason It is not being displayed on the 3D model, Do you know why that might be?

**UPDATE**
Solved the problem, I was creating many different markers instead of assigning the same marker to multiple images,

Thanks again
« Last Edit: February 14, 2018, 10:13:12 PM by JayS »

JayS

  • Newbie
  • *
  • Posts: 7
    • View Profile
Quick question,

What would the script look like to get the estimated coordinates of that given marker?

Thanks,
- Jay S

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14853
    • View Profile
Hello Jay,

In the internal chunk's coordinate system it is accessible via:
Code: [Select]
marker.position
If the chunk is georeferenced, then additional transformation is required:
Code: [Select]
chunk.crs.project(chunk.transform.matrix.mulp(marker.position))
Best regards,
Alexey Pasumansky,
Agisoft LLC