Forum

Author Topic: Access estimated data from python  (Read 3399 times)

SamirGFX

  • Newbie
  • *
  • Posts: 3
    • View Profile
Access estimated data from python
« on: May 07, 2015, 02:56:11 PM »
Hello all,

I am trying to write a camera and marker exporter for Maya from PhotoScan, and I am having some issues.

-When trying to get the location of cameras or markers with reference data applied to them the location returned is incorrect.

Ex case:
*Chunk has some markers without reference data.
*Original camera position in 3D returned by camera.transform.col(3) is (say) (10,10,10)
*Update markers by inserting some reference data.
*Try to get marker position after updating marker with reference data by calling marker.position, it's the ORIGINAL position.
*Try to get marker position by calling marker.reference.location, it's the new position (makes sense because these are the values that I entered)
*Try to get another marker -that has no reference data- position by calling marker.position, it's the old position (although it has been moved in 3D space in response to another marker reference data update!)
*Try to get the camera position again, it's wrong!
*Try to get the camera position by using camera.reference.location, "location" property is None (makes sense as no reference data for the camera has been entered)

Now this is very weird, because I expect the python API marker.position to return the new position of the marker even if that marker has no reference data because it's position is already updated using another marker reference data after clicking the "update" button. And the same is expected for Cameras!

After some digging I discovered that PhotoScan gives other markers/cameras an estimated location (which makes sense as they move in accordance to other markers/cameras), and these data can be found in the "Reference" tap when clicking the "Export" button to save it in a CSV file.

Now question is:
I can't find anything in the python API that gives me access to these estimated data except "loadReference" and "saveReference" functions in "Chunk" type which only write files to HDD.
I don't want to parse the CSV file written on the hard disk just to get the correct location for markers and cameras.
I want to get these values from memory like any other values in PhotoScan, is this is possible ?

Thanks in advance.

SamirGFX

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Access estimated data from python
« Reply #1 on: May 07, 2015, 05:59:53 PM »
Never mind I found how to calculate it

doc = PhotoScan.app.document
chunk = doc.chunk

marker0 = chunk.markers[0]

if(chunk.crs != None):
    estPos = chunk.crs.project(chunk.transform.matrix.mulp(marker0.position))
else:
    estPos = chunk.transform.matrix.mulp(marker0.position)


And the same applies for cameras.
« Last Edit: May 07, 2015, 06:01:32 PM by SamirGFX »