Forum

Author Topic: Edit Camera.center coords  (Read 9130 times)

IvanShubin

  • Newbie
  • *
  • Posts: 3
    • View Profile
Edit Camera.center coords
« on: June 14, 2013, 01:14:10 PM »
Help me. How to set the coordinates for a camera. I tried а script:

         for cam in doc.activeChunk.cameras:
            if cam.label == (geo_date[0]+".JPG"):
               vec = PhotoScan.Vector()
               vec.x = float(geo_date[1])
               vec.y = float(geo_date[2])
               vec.z = float(geo_date[3])   
               cam.center = vec

A consol showed me a error:
      
Traceback (most recent call last):
  File "C:/dev/photoscan/load_photo.py", line 35, in <module>
    cam.center = vec      
AttributeError: attribute 'center' of 'PhotoScan.Camera' objects is not writable

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14847
    • View Profile
Re: Edit Camera.center coords
« Reply #1 on: June 14, 2013, 01:41:28 PM »
Hello Ivan,

Do you need to input geographic coordinates for camera positions according to flight log?

For this task you should use chunk.ground_control.locations. The modified code should be something like the following:

Code: [Select]
for cam in doc.activeChunk.ground_control.locations.items():
    if cam[0].label == (geo_date[0]+".JPG"):
            cam[1].coord = ( float(geo_date[1]),  float(geo_date[2]),  float(geo_date[3]))
Best regards,
Alexey Pasumansky,
Agisoft LLC

xabierr

  • Jr. Member
  • **
  • Posts: 84
    • View Profile
Re: Edit Camera.center coords
« Reply #2 on: July 15, 2013, 08:08:20 AM »
I would like to replace source coordinates with the estimated coordinates (after optimization) and replace source z values with 0.

My attempt to do this is below but not sure how to call estimated coordinates instead of the source coordinates (cam.coord[0] and cam.coord[1]):

for cam in doc.activeChunk.ground_control.locations.items():
        cam[1].coord = (cam[1].coord[0],cam[1].coord[1],0)

cheers,

Javier

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14847
    • View Profile
Re: Edit Camera.center coords
« Reply #3 on: July 15, 2013, 03:00:46 PM »
Hello Javier,

Estimated coordinates are not accessible easily, but you can recalculate them from camera coordinate system:

Code: [Select]
chunk = PhotoScan.app.document.activeChunk
camera = chunk.cameras[0]

vc = camera.center
vc.size = 4
vc.w = 1

vt = chunk.transform * vc
vt = chunk.projection.project(vt)

So in the vt vector you'll have estimated coordinates.
Best regards,
Alexey Pasumansky,
Agisoft LLC

IvanShubin

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Edit Camera.center coords
« Reply #4 on: September 03, 2013, 08:36:33 AM »
Hello. How to transform coordinates from the geocentric coordinates system to the chunk coordinates system?

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14847
    • View Profile
Re: Edit Camera.center coords
« Reply #5 on: September 03, 2013, 12:25:22 PM »
Hello Ivan,

You should use chunk.crs.project(...) function to transform geocentric coordinates to chunk coordinate system (real-world).

In case you need to access internal chunk coordinates then you should use product of chunk.transform.inv() matrix and vector in geocentric coordinates (extended to four dimensions).
« Last Edit: September 03, 2013, 01:07:38 PM by Alexey Pasumansky »
Best regards,
Alexey Pasumansky,
Agisoft LLC

Seb_B

  • Newbie
  • *
  • Posts: 38
    • View Profile
Re: Edit Camera.center coords
« Reply #6 on: March 26, 2015, 03:35:45 PM »
Hello,

What is the code for PS 1.1 to extract the estimated camera location?

vt = chunk.transform * vc         doesn't seem to work!

Thank you
« Last Edit: March 26, 2015, 03:45:00 PM by Seb_B »

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14847
    • View Profile
Re: Edit Camera.center coords
« Reply #7 on: March 26, 2015, 03:49:27 PM »
Hello Sebastien,

Please try the following one:

Code: [Select]
v_est = chunk.crs.project(chunk.transform.matrix.mulp(camera.center))
Best regards,
Alexey Pasumansky,
Agisoft LLC

Seb_B

  • Newbie
  • *
  • Posts: 38
    • View Profile
Re: Edit Camera.center coords
« Reply #8 on: March 26, 2015, 03:58:01 PM »
I tried
v_est = chunk.crs.project(chunk.transform.matrix.mulp(camera.center))

It does not work. May be because I don't have crs, I am working on local coodinates.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14847
    • View Profile
Re: Edit Camera.center coords
« Reply #9 on: March 26, 2015, 03:58:35 PM »
Then you can omit chunk.crs.project function.
Best regards,
Alexey Pasumansky,
Agisoft LLC

Seb_B

  • Newbie
  • *
  • Posts: 38
    • View Profile
Re: Edit Camera.center coords
« Reply #10 on: March 26, 2015, 04:00:05 PM »
Great! Thank you!