Forum

Author Topic: GPS point to define bounding box / Georeferencing pointcloud  (Read 2816 times)

venkatg

  • Newbie
  • *
  • Posts: 4
    • View Profile
GPS point to define bounding box / Georeferencing pointcloud
« on: November 22, 2016, 10:43:59 PM »
Hello,

I'm using the pre-release Agisoft v1.3 Python API for the following workflow:

Code: [Select]
#Create a photoscan doc and a chunk object
doc = PhotoScan.app.document
doc.save(newPhotoScanProject)
chunk = doc.addChunk()

##load photos
.......

##Load reference from Exif data
chunk.loadReferenceExif(load_rotation=True, load_accuracy=False)
crs = PhotoScan.CoordinateSystem("EPSG::4326")
chunk.crs = crs
chunk.updateTransform()

#align photos
chunk.matchPhotos(accuracy=PhotoScan.HighAccuracy, preselection=PhotoScan.ReferencePreselection)
chunk.alignCameras()

#Export pointcloud
sparseFile = "sparsePointCloud.ply"
chunk.exportPoints(sparseFile, source = PhotoScan.PointCloudData, binary=True, precision=6, normals=True, colors=True, format = PhotoScan.PointsFormatPLY, projection=chunk.crs )

#TODO: Convert Region of interest defined in geographic coordinates to local coordinates
#For instance: bBoxCenter = PhotoScan.Vector([40.246537, -74.586480, 3.740638564235713]) 

1) How can I convert a GPS point (specified in lat, lon or UTM) into the chunk frame to set it as chunk.region.center?
2) Is my above exportPoints() usage correct to generate a georeferenced pointcloud?

Thanks!
« Last Edit: November 22, 2016, 11:42:55 PM by venkatg »

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14927
    • View Profile
Re: GPS point to define bounding box / Georeferencing pointcloud
« Reply #1 on: December 02, 2016, 10:02:42 AM »
Hello venkatg,

To convert the coordinates of the point from the geographic coordinate system into internal coordinate system of the chunk you need to use the following code:
Code: [Select]
point = PhotoScan.Vector([40.246537, -74.586480, 3.740638564235713]) #in geographic coordinates
T = chunk.transform.matrix
crs = chunk.crs

point_geoc = chunk.crs.unproject(point)
point_internal = T.inv().mulp(point_geoc)
Best regards,
Alexey Pasumansky,
Agisoft LLC