1
Agisoft Viewer / Re: [Contextcapture 3mx] Can't open layer
« on: October 08, 2024, 11:45:06 PM »
Still happens on latest Viewer. Model produced in iTwin capture modeler(a.k.a. Contextcapture). Sent an email.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
#export cameras coordinates and orientation as omega,phi,kappa (OPK) using exportCameras function
#compatibility: Agisoft PhotoScan Professional 1.2.6
# Define: Cameras output file
CamerasOPKFile = PhotoScan.app.getSaveFileName("Please specify export path and filename/opk:")
# Define: Coordinate system
CoordinateSystemEPSG = "EPSG::32632"
# DEFINE PROCESSING SETTINGS
print("---Defining processing settings...")
# INIT ENVIRONMENT
import PhotoScan
import math
doc = PhotoScan.app.document
chunk = doc.chunk
# SET COORDINATE SYSTEM
print("---Settings coordinate system...")
# init coordinate system object
#CoordinateSystem = PhotoScan.CoordinateSystem()
#chunk.crs = PhotoScan.CoordinateSystem( CoordinateSystemEPSG)
if not(CoordinateSystem.init(CoordinateSystemEPSG)):
app.messageBox("Coordinate system EPSG code not recognized!")
# define coordinate system in chunk
#chunk.crs = CoordinateSystem
#chunk.projection = CoordinateSystem
# EXPORT DATA:
# EXPORT CAMERAS
print("---Exporting camera positions...")
if not(chunk.exportCameras(CamerasOPKFile, "opk")):
app.messageBox("Exporting Cameras OPK failed!")
print("exported cameras to",CamerasOPKFile)
#export cameras coordinates and orientation as omega,phi,kappa (OPK)
#compatibility: Agisoft PhotoScan Professional 1.2.6
import PhotoScan
import math
path = PhotoScan.app.getSaveFileName("Please specify export path and filename:")
file = open(path, "wt")
#chunk = PhotoScan.app.document.activeChunk
doc = PhotoScan.app.document
chunk = doc.chunk
if chunk.transform:
#T = chunk.transform
T = chunk.transform.matrix
else:
T = PhotoScan.Matrix().diag([1,1,1,1])
print("Script started")
for camera in chunk.cameras:
if camera.transform:
coords = T.mulp(camera.center)
#x, y, z = T.mulp(camera.center)
#omega, phi, kappa = PhotoScan.utils.mat2opk(T.rotation)
m = chunk.transform.matrix * camera.transform * PhotoScan.Matrix().diag([1,-1,-1,1]) #camera transformation matrix has been multiplied by 180-degree rotation matrix, since the direction of Z axis in camera system is inverted compared to the world coordinate system.
rotation = m.rotation()
omega, phi, kappa = PhotoScan.utils.mat2opk(rotation)
print(camera.label)
print(rotation)
#print(omega, phi, kappa)
#print(x)
file.write(camera.label + "\t{:.5f}".format(coords[0]) + "\t{:.5f}".format(coords[1]) + "\t{:.5f}".format(coords[2]) + "\t{:.5f}".format(omega)+"\t{:.5f}".format(phi)+"\t{:.5f}".format(kappa)+"\n")
#yaw, pitch, roll = PhotoScan.utils.mat2ypr(PhotoScan.utils.opk2mat(PhotoScan.Vector((omega, phi, kappa))).t())
file.close()
print("Script finished")