Agisoft Metashape
Agisoft Metashape => Python and Java API => Topic started by: JulienGroenenboom on October 17, 2014, 03:42:06 PM
-
Hello,
I have tried to use a couple of (adjusted) scripts that were available at the forum, but I didn't work for me... So I hope that someone can give me a hint or script that can help me out.
I would like to transform georeferenced coordinates(x,y,z) in my model to pixel coordinates(somewhere between 0-width,0-height) on a certain photo. I use coordinatesystem EPSG::28992.
I have tried the scripts below, but they didn't give the right pixel coordinates.
import PhotoScan as ps
crs = PhotoScan.CoordinateSystem()
crs.init("EPSG::28992")
#test1
photo_0 = ps.app.document.activeChunk.photos[0]
currentChunk = PhotoScan.app.document.activeChunk
point_geocentric = currentChunk.projection.unproject(PhotoScan.Vector((74183.609,453380.738,3.388)))
(imgx, imgy) = photo_0.project(point_geocentric)
print (imgx, imgy)
#test2
a_camera = photo_0;
transform_matrix = currentChunk.transform * a_camera.transform
point_geocentric.size = 4
point_geocentric[3] = 1
point_local = transform_matrix.inv() * point_geocentric
point_local.size = 3
(image_x, image_y) = a_camera.project(point_local)
print (image_x,image_y)
print("Done")
Thank you in advance.
-
Hello Julien,
I suggest the following:
point3D = PhotoScan.Vector([74183.609, 453380.738, 3.388])
point_geocentric = currentChunk.projection.unproject(point3D)
point_internal = currentChunk.transform.inv().mulp(point_geocentric)
imgx, imgy = photo_0.project(point_internal)
-
Thank you Alexey, it works.