Forum

Author Topic: Setting camera accuracy with Python  (Read 2357 times)

gordon.freeman

  • Newbie
  • *
  • Posts: 1
    • View Profile
Setting camera accuracy with Python
« on: December 18, 2015, 04:52:47 PM »
Hello!

I am working with Photoscan Professional Edition and would like to set the camera accuracy to 0.1m using a python script, in the same way, as I can change the camera accuracy in the reference pane using reference settings. Here I can change the camera accuracy from 10m to 0.1m. Can I do this in my python script as well, for all cameras?

Greetings Marcel

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 9890
    • View Profile
Re: Setting camera accuracy with Python
« Reply #1 on: December 18, 2015, 05:32:52 PM »
Hello Marcel,

If you wish to change the accuracy for all the cameras (change the default accuracy for the chunk), use the following line:
Code: [Select]
PhotoScan.app.document.chunk.accuracy_cameras = (x, y, z)where x, y, z are values in corresponding direction. Could be the same number for all three, of course.

To change the accuracy for certain camera use:
Code: [Select]
camera.reference.accuracy = (x, y, z)
Best regards,
Alexey Pasumansky,
AgiSoft LLC

jeroenvdborre

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Setting camera accuracy with Python
« Reply #2 on: October 13, 2016, 02:58:34 PM »
Dear,

I am using your suggestion, but I get the error message "TypeError: floating point value expected".
What could be the reason?

My code is:

import math
import PhotoScan
doc = PhotoScan.app.document
chunk = doc.chunk

for chunk in doc.chunks:
   ...
   chunk.accuracy_cameras = (1, 1, 1)
   PhotoScan.app.update()

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 9890
    • View Profile
Re: Setting camera accuracy with Python
« Reply #3 on: October 13, 2016, 10:33:32 PM »
Hello jeroenvdborre,

Which version you are using? It seems that you might be using some old version, so please update to the version 1.2.6.
Best regards,
Alexey Pasumansky,
AgiSoft LLC

jeroenvdborre

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Setting camera accuracy with Python
« Reply #4 on: October 14, 2016, 10:04:33 AM »
Yes I was using an older version. Now it works indeed. Thanks.

jansawicki

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Setting camera accuracy with Python
« Reply #5 on: January 31, 2019, 06:35:15 PM »
Hello Marcel,

If you wish to change the accuracy for all the cameras (change the default accuracy for the chunk), use the following line:
Code: [Select]
PhotoScan.app.document.chunk.accuracy_cameras = (x, y, z)where x, y, z are values in corresponding direction. Could be the same number for all three, of course.

To change the accuracy for certain camera use:
Code: [Select]
camera.reference.accuracy = (x, y, z)


Can someone pleasy verify my code? I am trying to itterate through cameras and set various accuracies for each camera, although I am having a problem to change even one of them. Below code brings no error messages but doesn't update the data in Reference tab.

Code: [Select]
import Metashape

doc = Metashape.app.document
chunk = doc.chunk
camera = chunk.cameras[0]
camera.Reference.accuracy = (5,5,5)

print(camera.Reference.accuracy)

Thanks,
Jan

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 9890
    • View Profile
Re: Setting camera accuracy with Python
« Reply #6 on: January 31, 2019, 06:52:59 PM »
Hello Jan,

If you wish to define the accuracy globally for all the cameras:
Code: [Select]
import Metashape
doc = Metashape.app.document
chunk = doc.chunk
chunk.camera_location_accuracy = Metashape.Vector([5,5,5])

to define accuracy individually for each camera:
Code: [Select]
import Metashape
doc = Metashape.app.document
chunk = doc.chunk
for camera in chunk.cameras:
     camera.reference.location_accuracy = Metashape.Vector([5,5,5])
I just suggest to restart Metashape instance that you are working in, as camera.Reference assignment could break the proper work of Python API in the Console.
Best regards,
Alexey Pasumansky,
AgiSoft LLC

jansawicki

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Setting camera accuracy with Python
« Reply #7 on: February 01, 2019, 11:28:43 AM »
It worked, thanks!