1
Python and Java API / Re: Input our own markers and theirs coordinates
« on: June 12, 2018, 06:12:13 PM »
Yes, the two topics are related. And the solution for the other one can works here, thank you.
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.
T = chunk.transform.matrix
ptSrcT = T.inv().mulp(chunk.crs.unproject(ptSrc))
ptDstT = T.inv().mulp(chunk.crs.unproject(ptDst))
pT = chunk.model.pickPoint(ptSrcT, ptDstT)
m = chunk.addMarker(pT)
v2 = PhotoScan.Vector([float(tabResetSrcO[idM][0]), float(tabResetSrcO[idM][1]), float(tabResetSrcO[idM][2])])
v3 = PhotoScan.Vector([float(srcP[0]), float(srcP[1]), float(srcP[2])])
p = chunk.model.pickPoint(v2,v3)
if(not(p is None)):
m = chunk.addMarker()
m.label = myOwnLabel
m.reference.location = p
v = PhotoScan.Vector([myPoint[0], myPoint[1], myPoint[2]])
m = chunk.addMarker()
m.reference.location = v
import PhotoScan #(at the begining of your script)
#and then, in order to open PhotoScan, you call
app = PhotoScan.Application()
doc = app.document
#To save :
doc.save(#path + project name#)
#add a new chunk :
chunk = doc.addChunk()
#add photos :
chunk.addPhotos(photoList) # photoList = a tab with strings
app = PhotoScan.Application()
doc = app.document
os.chdir(pathProject)
doc.open(projectName)
chunk = doc.chunk
v = PhotoScan.Vector([myPoint[0], myPoint[1], myPoint[2]])
m = chunk.addMarker(v, visibility = True)
m.Reference.projection = v
If you want the total marker error:
Code: [Select]
doc = PhotoScan.app.document
chunk = doc.chunk
for marker in chunk.markers:
est = chunk.crs.project(chunk.transform.matrix.mulp(marker.position)) # Gets estimated marker coordinate
ref = marker.reference.location
if est and ref:
error = (est - ref).norm() # The .norm() method gives the total error. Removing it gives X/Y/Z error
print(marker.label, error)
That code gives the same error values for me.